diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-19 15:20:19 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-19 15:20:19 +0000 |
commit | a0b65deaa6e999132779e26f2b448dfa8662963c (patch) | |
tree | a95b27955dfdab804007b22c857171a8fe4bc84a /configmgr | |
parent | cf49371243377a126dca9acecf3f7d0a62a47920 (diff) |
MWS_SRX644: migrate branch mws_srx644 -> HEAD
Diffstat (limited to 'configmgr')
200 files changed, 4924 insertions, 5227 deletions
diff --git a/configmgr/prj/build.lst b/configmgr/prj/build.lst index 91f16e0b92b5..d06f880644ea 100644 --- a/configmgr/prj/build.lst +++ b/configmgr/prj/build.lst @@ -3,7 +3,6 @@ cg configmgr usr1 - all cg_mkout NULL cg configmgr\source\cmdtools nmake - all cg_cmdtools cg_misc NULL cg configmgr\source\cppugen nmake - all cg_cppugen NULL cg configmgr\source\misc nmake - all cg_misc cg_cppugen NULL -cg configmgr\source\session nmake - all cg_session cg_cppugen NULL cg configmgr\source\data nmake - all cg_data cg_cppugen NULL cg configmgr\source\tree nmake - all cg_tree cg_cppugen NULL cg configmgr\source\treecache nmake - all cg_trcache cg_cppugen NULL @@ -13,6 +12,6 @@ cg configmgr\source\api nmake - all cg_api cg_cppugen NULL cg configmgr\source\api2 nmake - all cg_api2 cg_cppugen NULL cg configmgr\source\treemgr nmake - all cg_treemgr cg_cppugen NULL cg configmgr\source\registry nmake - all cg_reg cg_cppugen NULL -cg configmgr\util nmake - all cg_util cg_api cg_api2 cg_cmdtools cg_misc cg_reg cg_session cg_trcache cg_data cg_tree cg_treemgr cg_xml cg_backend cg_localbe NULL +cg configmgr\util nmake - all cg_util cg_api cg_api2 cg_cmdtools cg_misc cg_reg cg_trcache cg_data cg_tree cg_treemgr cg_xml cg_backend cg_localbe NULL cg configmgr\source\localbe nmake - all cg_localbe cg_cppugen NULL diff --git a/configmgr/source/api/confeventhelpers.cxx b/configmgr/source/api/confeventhelpers.cxx index e1228c1d1f0b..21cb4a63012c 100644 --- a/configmgr/source/api/confeventhelpers.cxx +++ b/configmgr/source/api/confeventhelpers.cxx @@ -2,9 +2,9 @@ * * $RCSfile: confeventhelpers.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: hr $ $Date: 2002-02-21 14:07:21 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,9 +63,6 @@ #include <string.h> #include "confeventhelpers.hxx" -#ifndef INCLUDED_CONFIGMGR_NAMECREATOR_HXX -#include "namecreator.hxx" -#endif #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif @@ -211,7 +208,7 @@ void ConfigChangesBroadcasterImpl::dispatchInner using namespace configuration; try { - OSL_ASSERT(pTarget.isValid()); + OSL_ASSERT(pTarget.is()); OSL_ASSERT( Path::hasPrefix( _aTargetPath, _aChangeLocation ) ); RelativePath aLocalPath = Path::stripPrefix( _aTargetPath, _aChangeLocation ); @@ -246,7 +243,7 @@ void ConfigChangesBroadcasterImpl::dispatchOuter IConfigBroadcaster* pSource ) { - OSL_ASSERT(pTarget.isValid()); + OSL_ASSERT(pTarget.is()); OSL_ASSERT( Path::hasPrefix( _aChangeLocation, _aTargetPath) ); pTarget->nodeChanged(_aChangedDataAccessor, rBaseChange, _aChangeLocation, pSource); diff --git a/configmgr/source/api/confeventhelpers.hxx b/configmgr/source/api/confeventhelpers.hxx index 7babc1c0609d..b7c4ecebee15 100644 --- a/configmgr/source/api/confeventhelpers.hxx +++ b/configmgr/source/api/confeventhelpers.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confeventhelpers.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -195,10 +195,10 @@ namespace configmgr INodeListener& operator*() const { return *m_pListener; } // needed to allow if (info) ... struct HasListener; - operator HasListener const*() const { return reinterpret_cast<HasListener*>(m_pListener.getBodyPtr()); } + operator HasListener const*() const { return reinterpret_cast<HasListener*>(m_pListener.get()); } bool operator < (NodeListenerInfo const& aInfo) const - { return std::less<INodeListener*>()(m_pListener.getBodyPtr(), aInfo.m_pListener.getBodyPtr()); } + { return std::less<INodeListener*>()(m_pListener.get(), aInfo.m_pListener.get()); } bool operator == (NodeListenerInfo const& aInfo) const { return !!( m_pListener == aInfo.m_pListener); } diff --git a/configmgr/source/api/confevents.cxx b/configmgr/source/api/confevents.cxx index a0a8e7f7186e..5c2806e42121 100644 --- a/configmgr/source/api/confevents.cxx +++ b/configmgr/source/api/confevents.cxx @@ -2,9 +2,9 @@ * * $RCSfile: confevents.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: hr $ $Date: 2002-02-21 14:07:21 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -123,9 +123,9 @@ namespace configmgr ///////////////////////////////////////////////////////////////////////// // IConfigBroadcaster implementation - void ConfigChangeBroadcaster::addListener(AbsolutePath const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pHandler) + void ConfigChangeBroadcaster::addListener(AbsolutePath const& aName, RequestOptions const & _aOptions, INodeListenerRef const& pHandler) { - if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,true)) + if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_aOptions,true)) { pHelper->addListener(aName, pHandler); } @@ -133,9 +133,9 @@ namespace configmgr OSL_ASSERT(false); } - void ConfigChangeBroadcaster::removeListener(const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pHandler) + void ConfigChangeBroadcaster::removeListener(RequestOptions const & _aOptions, INodeListenerRef const& pHandler) { - if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,false)) + if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_aOptions,false)) { pHelper->removeListener( pHandler); } diff --git a/configmgr/source/api/makefile.mk b/configmgr/source/api/makefile.mk index ab54f03f9c47..4ca3956e27ea 100644 --- a/configmgr/source/api/makefile.mk +++ b/configmgr/source/api/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: dg $ $Date: 2000-11-30 08:17:49 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:18:24 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -74,32 +74,10 @@ ENABLE_EXCEPTIONS=TRUE # --- Files ------------------------------------- SLOFILES= \ - $(SLO)$/encodename.obj \ $(SLO)$/confevents.obj \ $(SLO)$/confeventhelpers.obj \ $(SLO)$/confsvccomponent.obj - -# $(SLO)$/useradminimpl.obj \ -# $(SLO)$/readaccessimpl.obj \ -# $(SLO)$/confaccessfactory.obj \ -# $(SLO)$/cfgupdatehelper.obj \ -# $(SLO)$/nodepropset.obj \ -# $(SLO)$/confreadaccess.obj \ -# $(SLO)$/confgroupaccess.obj \ -# $(SLO)$/confsetaccess.obj \ -# $(SLO)$/confupdateimpl.obj \ -# $(SLO)$/confupdateaccess.obj \ -# $(SLO)$/confbaseelement.obj \ -# $(SLO)$/confbaseaccess.obj \ -# $(SLO)$/confaccess.obj \ -# $(SLO)$/confsvccomponent.obj \ -# $(SLO)$/confeventhelpers.obj \ -# $(SLO)$/confprovider.obj \ -# $(SLO)$/confproviderimpl.obj \ -# $(SLO)$/confchangesset.obj \ -# $(SLO)$/changenotifier.obj \ - # --- Targets ---------------------------------- .INCLUDE : target.mk diff --git a/configmgr/source/api2/accessimpl.cxx b/configmgr/source/api2/accessimpl.cxx index 1d80433f1569..12fe46faa384 100644 --- a/configmgr/source/api2/accessimpl.cxx +++ b/configmgr/source/api2/accessimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: accessimpl.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,15 +80,18 @@ #ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_ #include "confignotifier.hxx" #endif -#ifndef CONFIGMGR_API_ENCODENAME_HXX_ -#include "encodename.hxx" -#endif #ifndef CONFIGMGR_API_PROPERTYINFOIMPL_HXX_ #include "propertyinfohelper.hxx" #endif #ifndef CONFIGMGR_TREEITERATORS_HXX_ #include "treeiterators.hxx" #endif +#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_ +#include "attributes.hxx" +#endif +#ifndef CONFIGMGR_API_APITYPES_HXX_ +#include "apitypes.hxx" +#endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> @@ -132,7 +135,7 @@ namespace configmgr using configuration::Name; using configuration::AbsolutePath; using configuration::RelativePath; - using configuration::Attributes; + using node::Attributes; //----------------------------------------------------------------------------------- // Constructors @@ -535,7 +538,7 @@ OUString implGetExactName(NodeSetInfoAccess& rNode, const OUString& rApproximate return rApproximateName; } -// XNameAccess +// XProperty //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- @@ -568,6 +571,87 @@ beans::Property implGetAsProperty(NodeAccess& rNode) OSL_ASSERT(!"Unreachable code"); return Property(); } +// XPropertySetInfo +//----------------------------------------------------------------------------------- + +//----------------------------------------------------------------------------------- +uno::Sequence< css::beans::Property > implGetProperties( NodeAccess& rNode ) throw (uno::RuntimeException) +{ + CollectPropertyInfo aCollect; + + try + { + GuardedNodeDataAccess lock( rNode ); + + lock.getTree().dispatchToChildren(lock.getNode(), aCollect); + } + catch (configuration::Exception& ex) + { + ExceptionMapper e(ex); + e.setContext( rNode.getUnoInstance() ); + e.unhandled(); + } + + return makeSequence( aCollect.list() ); +} + +//----------------------------------------------------------------------------------- +css::beans::Property implGetPropertyByName( NodeAccess& rNode, const OUString& aName ) + throw (css::beans::UnknownPropertyException, uno::RuntimeException) +{ + try + { + GuardedNodeDataAccess lock( rNode ); + + Tree aTree( lock.getTree() ); + NodeRef const aNode( lock.getNode() ); + + Name aChildName = configuration::validateChildOrElementName(aName,aTree,aNode); + + AnyNodeRef aChildNode = configuration::getChildOrElement(aTree,aNode, aChildName); + + if (!aChildNode.isValid()) + { + OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Property not found by implementation"); + + OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property. Property '") ); + sMessage += aName; + sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") ); + sMessage += aTree.getAbsolutePath(aNode).toString(); + + Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); + throw css::beans::UnknownPropertyException( sMessage, xContext ); + } + + Attributes aChildAttributes = aTree.getAttributes(aChildNode); + uno::Type aApiType = aChildNode.isNode() ? getUnoInterfaceType() : aTree.getUnoType(aChildNode.toValue()); + + return helperMakeProperty( aChildName,aChildAttributes,aApiType, aTree.hasNodeDefault(aChildNode) ); + } + catch (configuration::InvalidName& ex) + { + ExceptionMapper e(ex); + Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); + throw css::beans::UnknownPropertyException( e.message(), xContext ); + } + catch (configuration::Exception& ex) + { + ExceptionMapper e(ex); + e.setContext( rNode.getUnoInstance() ); + e.unhandled(); + } + + // unreachable, but still there to make some compilers happy + OSL_ASSERT(!"Unreachable code"); + return css::beans::Property(); +} + + +//----------------------------------------------------------------------------------- +sal_Bool implHasPropertyByName( NodeAccess& rNode, const OUString& Name ) throw (uno::RuntimeException) +{ + return implHasByName(rNode, Name); +} // XNameAccess //----------------------------------------------------------------------------------- @@ -833,48 +917,6 @@ OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode) return rNode.getElementInfo(lock.getDataAccessor()).getTemplateInfo().getTemplatePathString(); } -// XStringEscape -//----------------------------------------------------------------------------------- -OUString SAL_CALL implEscapeString(NodeAccess& rNode, const OUString& aString) - throw(css::lang::IllegalArgumentException, RuntimeException) -{ - OUString sRet; - try - { - sRet = escaped_name::escapeString(aString,0,1); - } - catch (css::lang::IllegalArgumentException& ex) - { - ex.Context = rNode.getUnoInstance(); - throw; - } - catch (uno::Exception& ex) - { - throw RuntimeException(ex.Message, rNode.getUnoInstance()); - } - return sRet; -} - -OUString SAL_CALL implUnescapeString(NodeAccess& rNode, const OUString& aEscapedString) - throw(css::lang::IllegalArgumentException, RuntimeException) -{ - OUString sRet; - try - { - sRet = escaped_name::unescapeString(aEscapedString,0,1); - } - catch (css::lang::IllegalArgumentException& ex) - { - ex.Context = rNode.getUnoInstance(); - throw; - } - catch (uno::Exception& ex) - { - throw RuntimeException(ex.Message, rNode.getUnoInstance()); - } - return sRet; -} - //----------------------------------------------------------------------------------- } // namespace configapi diff --git a/configmgr/source/api2/accessimpl.hxx b/configmgr/source/api2/accessimpl.hxx index f1fcd674f037..96ef6fdd67d2 100644 --- a/configmgr/source/api2/accessimpl.hxx +++ b/configmgr/source/api2/accessimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: accessimpl.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,6 @@ #ifndef CONFIGMGR_API_BASEACCESSIMPL_HXX_ #define CONFIGMGR_API_BASEACCESSIMPL_HXX_ -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAME_HPP_ #include <com/sun/star/container/XHierarchicalName.hpp> #endif @@ -87,17 +83,18 @@ #ifndef _COM_SUN_STAR_BEANS_XPROPERTY_HPP_ #include <com/sun/star/beans/XProperty.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif #ifndef _COM_SUN_STAR_BEANS_XPROPERTYWITHSTATE_HPP_ #include <com/sun/star/beans/XPropertyWithState.hpp> #endif -#ifndef _COM_SUN_STAR_UTIL_XSTRINGESCAPE_HPP_ -#include <com/sun/star/util/XStringEscape.hpp> -#endif namespace configmgr { namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; /* implementations of the interfaces supported by a (parent) node within the configuration tree. @@ -160,6 +157,17 @@ namespace configmgr css::beans::Property implGetAsProperty(NodeAccess& rNode) throw(uno::RuntimeException); + // XPropertySetInfo + uno::Sequence< css::beans::Property > implGetProperties( NodeAccess& rNode ) + throw (uno::RuntimeException); + + css::beans::Property implGetPropertyByName( NodeAccess& rNode, const OUString& aName ) + throw (css::beans::UnknownPropertyException, uno::RuntimeException); + + sal_Bool implHasPropertyByName( NodeAccess& rNode, const OUString& Name ) + throw (uno::RuntimeException); + + // XPropertyWithState css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode) throw (uno::RuntimeException); @@ -176,12 +184,6 @@ namespace configmgr OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode) throw(uno::RuntimeException); - // XStringEscape - OUString SAL_CALL implEscapeString(NodeAccess& rNode, const OUString& aString) - throw(css::lang::IllegalArgumentException, uno::RuntimeException); - - OUString SAL_CALL implUnescapeString(NodeAccess& rNode, const OUString& aEscapedString) - throw(css::lang::IllegalArgumentException, uno::RuntimeException); } } diff --git a/configmgr/source/api2/apifactory.cxx b/configmgr/source/api2/apifactory.cxx index 1359d98b3af8..b67f0dbef941 100644 --- a/configmgr/source/api2/apifactory.cxx +++ b/configmgr/source/api2/apifactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: apifactory.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -108,7 +108,7 @@ Factory::Factory(ObjectRegistryHolder pRegistry) : m_pRegistry(pRegistry) , m_aTunnelID() { - OSL_ENSURE(pRegistry.isValid(), "ERROR: Factory requires a Object Registry"); + OSL_ENSURE(pRegistry.is(), "ERROR: Factory requires a Object Registry"); } //----------------------------------------------------------------------------- @@ -276,7 +276,7 @@ void Factory::revokeElement(NodeID const& aNodeID, NodeElement& rElement) } //----------------------------------------------------------------------------- -TreeElement* Factory::makeAccessRoot(Tree const& aTree, vos::ORef< OOptions >const& _xOptions) +TreeElement* Factory::makeAccessRoot(Tree const& aTree, RequestOptions const& _aOptions) { OSL_PRECOND( !aTree.isEmpty() , "ERROR: Configuration: Making element from tree requires valid tree"); if (aTree.isEmpty()) return 0; @@ -297,7 +297,8 @@ TreeElement* Factory::makeAccessRoot(Tree const& aTree, vos::ORef< OOptions >con if (0 == pRet) { TemplateHolder aTemplate = implGetSetElementTemplate(aTree,aRoot); - pRet = doCreateAccessRoot(aTree,aTemplate.get(), _xOptions); + vos::ORef<OOptions> xOptions = new OOptions(_aOptions); + pRet = doCreateAccessRoot(aTree,aTemplate.get(), xOptions); implHaveNewElement (aNodeID,pRet); } return pRet; diff --git a/configmgr/source/api2/apifactory.hxx b/configmgr/source/api2/apifactory.hxx index 5b39e3341b2c..68ea5cb9fa58 100644 --- a/configmgr/source/api2/apifactory.hxx +++ b/configmgr/source/api2/apifactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apifactory.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,12 +62,12 @@ #ifndef CONFIGMGR_API_FACTORY_HXX_ #define CONFIGMGR_API_FACTORY_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_MISC_OPTIONS_HXX_ #include "options.hxx" #endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif #ifndef _RTL_REF_HXX_ #include <rtl/ref.hxx> @@ -97,6 +97,7 @@ namespace configmgr } namespace configapi { + namespace uno = com::sun::star::uno; typedef uno::XInterface UnoInterface; typedef uno::Reference< uno::XInterface > UnoInterfaceRef; typedef uno::Any UnoAny; @@ -110,11 +111,11 @@ namespace configmgr // used to register objects class ObjectRegistry; - typedef vos::ORef<ObjectRegistry> ObjectRegistryHolder; + typedef rtl::Reference<ObjectRegistry> ObjectRegistryHolder; typedef cppu::OImplementationId UnoTunnelID; // used to create UNO objects - class Factory : NotCopyable + class Factory : Noncopyable { ObjectRegistryHolder m_pRegistry; UnoTunnelID const m_aTunnelID; @@ -137,7 +138,7 @@ namespace configmgr NodeElement* findElement(configuration::NodeID const& aNode); NodeElement* makeGroupMember(configuration::Tree const& aTree, configuration::NodeRef const& aNode); - TreeElement* makeAccessRoot(configuration::Tree const& aTree, vos::ORef< OOptions >const& _xOptions); + TreeElement* makeAccessRoot(configuration::Tree const& aTree, RequestOptions const& _aOptions); SetElement* makeSetElement(configuration::ElementTree const& aTree); SetElement* findSetElement(configuration::ElementRef const& aElement); diff --git a/configmgr/source/api2/apifactoryimpl.cxx b/configmgr/source/api2/apifactoryimpl.cxx index 935b13654424..db47c1eff6d5 100644 --- a/configmgr/source/api2/apifactoryimpl.cxx +++ b/configmgr/source/api2/apifactoryimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: apifactoryimpl.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,7 @@ #include "template.hxx" #include "noderef.hxx" #include "objectregistry.hxx" +#include "attributes.hxx" namespace configmgr { diff --git a/configmgr/source/api2/apinodeaccess.hxx b/configmgr/source/api2/apinodeaccess.hxx index 7d7ee40a90df..eeded8b77de6 100644 --- a/configmgr/source/api2/apinodeaccess.hxx +++ b/configmgr/source/api2/apinodeaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apinodeaccess.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,7 +62,9 @@ #ifndef CONFIGMGR_API_NODEACCESS_HXX_ #define CONFIGMGR_API_NODEACCESS_HXX_ -#include "apitypes.hxx" +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif namespace osl { class Mutex; } @@ -94,6 +96,7 @@ namespace configmgr class ApiTreeImpl; + namespace uno = com::sun::star::uno; typedef uno::XInterface UnoInterface; typedef uno::Any UnoAny; @@ -101,7 +104,7 @@ namespace configmgr // these objects just provide the pieces needed to navigate and manipulate trees and nodes // The common part of all nodes, provides all you need to read and listen - class NodeAccess : NotCopyable + class NodeAccess : Noncopyable { public: virtual ~NodeAccess(); @@ -184,7 +187,7 @@ namespace configmgr // Guarding and locking implementations /// guards a NodeAccess; provides an object (read) lock, ensures object was not disposed - class NodeReadGuardImpl : NotCopyable + class NodeReadGuardImpl : Noncopyable { osl::MutexGuard m_aLock; NodeAccess& m_rNode; diff --git a/configmgr/source/api2/apinodeupdate.hxx b/configmgr/source/api2/apinodeupdate.hxx index 7117e922bf4c..4a9678d0c015 100644 --- a/configmgr/source/api2/apinodeupdate.hxx +++ b/configmgr/source/api2/apinodeupdate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apinodeupdate.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,14 +62,15 @@ #ifndef CONFIGMGR_API_NODEUPDATE_HXX_ #define CONFIGMGR_API_NODEUPDATE_HXX_ -#include "apitypes.hxx" - #ifndef CONFIGMGR_API_NODEACCESS_HXX_ #include "apinodeaccess.hxx" #endif #ifndef CONFIGMGR_ACCESSOR_HXX #include "accessor.hxx" #endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif namespace configmgr { @@ -151,7 +152,7 @@ namespace configmgr // Guarding and locking implementations /// guards a NodeGroupAccess, or NodeSetAccess; provides an object (write)/provider(read) lock; ensures object was not disposed - class UpdateGuardImpl : NotCopyable + class UpdateGuardImpl : Noncopyable { memory::Accessor m_aDataAccess; osl::MutexGuard m_aViewLock; diff --git a/configmgr/source/api2/apinotifierimpl.hxx b/configmgr/source/api2/apinotifierimpl.hxx index 836b584c0771..80154c92fc3d 100644 --- a/configmgr/source/api2/apinotifierimpl.hxx +++ b/configmgr/source/api2/apinotifierimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apinotifierimpl.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,6 @@ #ifndef CONFIGMGR_API_NOTIFIERIMPL_HXX_ #define CONFIGMGR_API_NOTIFIERIMPL_HXX_ -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ #include <com/sun/star/container/XChild.hpp> #endif @@ -86,6 +82,7 @@ namespace configmgr { namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; /* implementations of the event notification interfaces supported by a node within the configuration tree. diff --git a/configmgr/source/api2/apitreeaccess.hxx b/configmgr/source/api2/apitreeaccess.hxx index 0518203a33e5..9d98a3334336 100644 --- a/configmgr/source/api2/apitreeaccess.hxx +++ b/configmgr/source/api2/apitreeaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apitreeaccess.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,15 +62,15 @@ #ifndef CONFIGMGR_API_TREEACCESS_HXX_ #define CONFIGMGR_API_TREEACCESS_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_ACCESSOR_HXX #include "accessor.hxx" #endif #ifndef CONFIGMGR_MISC_OPTIONS_HXX_ #include "options.hxx" #endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif namespace osl { class Mutex; } @@ -99,6 +99,7 @@ namespace configmgr namespace configapi { //----------------------------------------------------------------------------- + namespace uno = com::sun::star::uno; typedef uno::XInterface UnoInterface; typedef uno::Any UnoAny; //----------------------------------------------------------------------------- @@ -115,7 +116,7 @@ namespace configmgr // these objects just provide the pieces needed to navigate and manipulate trees and nodes // A common base class for 'element' classes - class NodeElement : NotCopyable + class NodeElement : Noncopyable { public: typedef ServiceImplementationInfo ServiceInfo; @@ -202,7 +203,7 @@ namespace configmgr }; //----------------------------------------------------------------------------- /// guards a TreeElement; provides an object (read) lock, ensures object was not disposed - class TreeReadGuardImpl : NotCopyable + class TreeReadGuardImpl : Noncopyable { osl::MutexGuard m_aViewLock; TreeElement& m_rTree; diff --git a/configmgr/source/api2/apitreeimplobj.cxx b/configmgr/source/api2/apitreeimplobj.cxx index 10d442a06a12..b5fe8afe4d86 100644 --- a/configmgr/source/api2/apitreeimplobj.cxx +++ b/configmgr/source/api2/apitreeimplobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: apitreeimplobj.cxx,v $ * - * $Revision: 1.33 $ + * $Revision: 1.34 $ * - * last change: $Author: jb $ $Date: 2002-10-15 15:03:52 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -171,7 +171,7 @@ void ApiTreeImpl::ComponentAdapter::setComponent( aGuard.clear(); - if (xOld.is()) xOld->removeEventListener(this); + if (xOld.is()) try { xOld->removeEventListener(this); } catch (uno::Exception & ) {} if (xComp.is()) xComp->addEventListener(this); } } @@ -251,8 +251,8 @@ void ApiTreeImpl::ComponentAdapter::clear() aGuard.clear(); - if (xParent.is()) xParent->removeEventListener(this); - if (xProvider.is()) xProvider->removeEventListener(this); + if (xParent.is()) try { xParent ->removeEventListener(this); } catch (uno::Exception & ) {} + if (xProvider.is()) try { xProvider->removeEventListener(this); } catch (uno::Exception & ) {} } //----------------------------------------------------------------------------- @@ -262,7 +262,7 @@ class ApiRootTreeImpl::NodeListener : public INodeListener ApiRootTreeImpl* pParent; IConfigBroadcaster* pSource; - vos::ORef< OOptions > m_xOptions; + TreeOptions m_xOptions; AbsolutePath m_aLocationPath; public: NodeListener(ApiRootTreeImpl& _rParent) @@ -288,31 +288,42 @@ public: { if (pNew != pSource) { - if (pSource) - pSource->removeListener(m_xOptions, this); - - pSource = pNew; - if (pNew) + OSL_ENSURE(m_xOptions.isValid(),"Cannot set IConfigListener without Options"); + if (m_xOptions.isValid()) { - OSL_ENSURE(!m_aLocationPath.isRoot(), "Cannot register for notifications: no location set"); - pNew->addListener(m_aLocationPath, m_xOptions, this); + if (pSource) + pSource->removeListener(m_xOptions->getRequestOptions(), this); + + pSource = pNew; + if (pNew) + { + OSL_ENSURE(!m_aLocationPath.isRoot(), "Cannot register for notifications: no location set"); + pNew->addListener(m_aLocationPath, m_xOptions->getRequestOptions(), this); + } } + else + pSource = 0; } } } - void setLocation(AbsolutePath const& _aLocation, vos::ORef< OOptions > const& _xOptions) + void setLocation(AbsolutePath const& _aLocation, TreeOptions const& _xOptions) { + OSL_ASSERT(_xOptions.isValid()); + osl::MutexGuard aGuard(mutex); if (pSource && pParent) - pSource->removeListener(m_xOptions, this); + { + OSL_ASSERT(m_xOptions.isValid()); + pSource->removeListener(m_xOptions->getRequestOptions(), this); + } m_aLocationPath = _aLocation; m_xOptions = _xOptions; if (pSource && pParent) - pSource->addListener(m_aLocationPath, m_xOptions, this); + pSource->addListener(m_aLocationPath, m_xOptions->getRequestOptions(), this); } void unbind() @@ -322,7 +333,8 @@ public: pParent = 0; if (pSource) { - pSource->removeListener(m_xOptions, this); + OSL_ASSERT(m_xOptions.isValid()); + pSource->removeListener(m_xOptions->getRequestOptions(), this); m_xOptions.unbind(); m_aLocationPath = AbsolutePath::root(); } @@ -339,7 +351,7 @@ public: if (pSource) { IConfigBroadcaster* pOrgSource = pSource; - vos::ORef< OOptions > xOptions = m_xOptions; + TreeOptions xOptions = m_xOptions; pSource = 0; m_xOptions.unbind(); @@ -347,7 +359,8 @@ public: aGuard.clear(); - pOrgSource->removeListener(xOptions, this); + OSL_ASSERT(xOptions.isValid()); + pOrgSource->removeListener(xOptions->getRequestOptions(), this); } } } @@ -379,13 +392,16 @@ inline configuration::DefaultProvider createDefaultProvider( ApiProvider& rProvider, configuration::Tree const& aTree, - vos::ORef< OOptions >const& _xOptions + TreeOptions const& _xOptions ) { OProviderImpl& rProviderImpl = rProvider.getProviderImpl(); rtl::Reference< IConfigDefaultProvider > xDefaultProvider = rProviderImpl.getDefaultProvider(); - return configuration::DefaultProvider::create(aTree,_xOptions,xDefaultProvider,&rProviderImpl); + OSL_ASSERT(_xOptions.isValid()); + RequestOptions const aOptions = _xOptions.isValid() ? _xOptions->getRequestOptions() : RequestOptions(); + + return configuration::DefaultProvider::create(aTree,aOptions,xDefaultProvider,&rProviderImpl); } //------------------------------------------------------------------------- static @@ -444,7 +460,7 @@ ApiTreeImpl::~ApiTreeImpl() } //------------------------------------------------------------------------- -ApiRootTreeImpl::ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, configuration::Tree const& aTree, vos::ORef< OOptions >const& _xOptions) +ApiRootTreeImpl::ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, configuration::Tree const& aTree, TreeOptions const& _xOptions) : m_aTreeImpl(pInstance, rProvider, aTree.getRef(), createDefaultProvider(rProvider, aTree, _xOptions)) , m_pNotificationListener(NULL) , m_xOptions(_xOptions) @@ -456,7 +472,7 @@ ApiRootTreeImpl::ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider //------------------------------------------------------------------------- ApiRootTreeImpl::~ApiRootTreeImpl() { - if (m_pNotificationListener.isValid()) + if (m_pNotificationListener.is()) { m_pNotificationListener->setSource(0); m_pNotificationListener->clearParent(); @@ -554,11 +570,11 @@ bool ApiRootTreeImpl::disposeTree() // ensure our provider stays alive UnoInterfaceRef xKeepProvider( m_aTreeImpl.getUnoProviderInstance() ); - vos::ORef<NodeListener> xListener = m_pNotificationListener; - if (xListener.isValid()) + rtl::Reference<NodeListener> xListener = m_pNotificationListener; + if (xListener.is()) { xListener->clearParent(); - xListener.unbind(); + xListener.clear(); } bool bDisposed = m_aTreeImpl.disposeTreeNow(); @@ -774,12 +790,12 @@ IConfigBroadcaster* ApiRootTreeImpl::implSetNotificationSource(IConfigBroadcaste { osl::MutexGuard aGuard(getApiTree().getApiLock()); - IConfigBroadcaster* pOld = m_pNotificationListener.isValid() ? m_pNotificationListener->getSource() : 0; + IConfigBroadcaster* pOld = m_pNotificationListener.is() ? m_pNotificationListener->getSource() : 0; if (pOld != pNew) { OSL_ENSURE(m_xOptions.isValid(), "Cannot change notification source without options"); - if (!m_pNotificationListener.isValid()) + if (!m_pNotificationListener.is()) m_pNotificationListener = new NodeListener(*this); m_pNotificationListener->setSource(pNew); @@ -805,7 +821,7 @@ void ApiRootTreeImpl::implSetLocation(configuration::Tree const& _aTree) m_aLocationPath = configuration::AbsolutePath::root(); } - if (!m_pNotificationListener.isValid()) + if (!m_pNotificationListener.is()) m_pNotificationListener = new NodeListener(*this); OSL_ENSURE(!m_aLocationPath.isRoot() && !m_aLocationPath.isDetached(), "Cannot reregister for notifications: setting empty location"); @@ -826,8 +842,9 @@ void ApiRootTreeImpl::releaseData() OSL_ENSURE( !m_aLocationPath.isRoot() && !m_aLocationPath.isDetached(), "Location still needed to release data" ); OSL_ENSURE( m_xOptions.isValid(), "Options still needed to release data" ); - getApiTree().getProvider().getProviderImpl().releaseSubtree(m_aLocationPath,m_xOptions); + getApiTree().getProvider().getProviderImpl().releaseSubtree(m_aLocationPath,m_xOptions->getRequestOptions()); m_xOptions.unbind(); + m_aLocationPath = configuration::AbsolutePath::detachedRoot(); } // --------------------------------------------------------------------------------------------------- @@ -854,11 +871,11 @@ void ApiRootTreeImpl::disposing(IConfigBroadcaster* pSource) // ensure our provider stays alive UnoInterfaceRef xKeepProvider( m_aTreeImpl.getUnoProviderInstance() ); - vos::ORef<NodeListener> xListener = m_pNotificationListener; - if (xListener.isValid()) + rtl::Reference<NodeListener> xListener = m_pNotificationListener; + if (xListener.is()) { xListener->clearParent(); - xListener.unbind(); + xListener.clear(); } if (m_aTreeImpl.disposeTreeNow()) @@ -1077,11 +1094,11 @@ void ApiRootTreeImpl::nodeDeleted(data::Accessor const& _aChangedDataAccessor, A // ensure our provider stays alive UnoInterfaceRef xKeepProvider( m_aTreeImpl.getUnoProviderInstance() ); - vos::ORef<NodeListener> xListener = m_pNotificationListener; - if (xListener.isValid()) + rtl::Reference<NodeListener> xListener = m_pNotificationListener; + if (xListener.is()) { xListener->clearParent(); - xListener.unbind(); + xListener.clear(); } if (m_aTreeImpl.disposeTreeNow()) diff --git a/configmgr/source/api2/apitreeimplobj.hxx b/configmgr/source/api2/apitreeimplobj.hxx index 3a679f36c42d..b3e8e5d9a084 100644 --- a/configmgr/source/api2/apitreeimplobj.hxx +++ b/configmgr/source/api2/apitreeimplobj.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apitreeimplobj.hxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,6 @@ #ifndef CONFIGMGR_API_TREEIMPLOBJECTS_HXX_ #define CONFIGMGR_API_TREEIMPLOBJECTS_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef CONFIGMGR_CONFIGNODE_HXX_ #include "noderef.hxx" #endif @@ -81,10 +77,16 @@ #ifndef CONFIGMGR_MISC_OPTIONS_HXX_ #include "options.hxx" #endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif #ifndef _VOS_REF_HXX_ #include <vos/ref.hxx> #endif +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif #ifndef _OSL_MUTEX_HXX_ #include <osl/mutex.hxx> #endif @@ -119,16 +121,17 @@ namespace configmgr typedef vos::ORef<NotifierImpl> NotifierImplHolder; //----------------------------------------------------------------------------- class ObjectRegistry; - typedef vos::ORef<ObjectRegistry> ObjectRegistryHolder; + typedef rtl::Reference<ObjectRegistry> ObjectRegistryHolder; typedef uno::XInterface UnoInterface; typedef uno::Reference<UnoInterface> UnoInterfaceRef; typedef uno::Reference<com::sun::star::script::XTypeConverter> UnoTypeConverter; + typedef vos::ORef< OOptions > TreeOptions; //----------------------------------------------------------------------------- // API object implementation wrappers //------------------------------------------------------------------------- - class ApiProvider : NotCopyable + class ApiProvider : Noncopyable { Factory& m_rFactory; OProviderImpl& m_rProviderImpl; @@ -146,7 +149,7 @@ namespace configmgr //----------------------------------------------------------------------------- //------------------------------------------------------------------------- - class ApiTreeImpl : NotCopyable + class ApiTreeImpl : Noncopyable { class ComponentAdapter; typedef uno::Reference<ComponentAdapter> ComponentRef; @@ -221,17 +224,17 @@ namespace configmgr { typedef configuration::AbsolutePath AbsolutePath; typedef configuration::DefaultProvider DefaultProvider; - vos::ORef< OOptions > m_xOptions; + TreeOptions m_xOptions; public: - explicit ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, configuration::Tree const& aTree, vos::ORef< OOptions >const& _xOptions); + explicit ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, configuration::Tree const& aTree, TreeOptions const& _xOptions); ~ApiRootTreeImpl(); ApiTreeImpl& getApiTree() { return m_aTreeImpl; } ApiTreeImpl const& getApiTree() const { return m_aTreeImpl; } AbsolutePath const & getLocation() const { return m_aLocationPath; } - vos::ORef< OOptions > getOptions() const { return m_xOptions; } + TreeOptions getOptions() const { return m_xOptions; } // self-locked methods for dispose handling bool disposeTree(); @@ -257,7 +260,7 @@ namespace configmgr private: ApiTreeImpl m_aTreeImpl; AbsolutePath m_aLocationPath; - vos::ORef<NodeListener> m_pNotificationListener; + rtl::Reference<NodeListener> m_pNotificationListener; }; //----------------------------------------------------------------------------- } diff --git a/configmgr/source/api2/broadcaster.cxx b/configmgr/source/api2/broadcaster.cxx index fb1071d26099..2a7c43b3bb59 100644 --- a/configmgr/source/api2/broadcaster.cxx +++ b/configmgr/source/api2/broadcaster.cxx @@ -2,9 +2,9 @@ * * $RCSfile: broadcaster.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: jb $ $Date: 2002-10-15 15:06:26 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -426,18 +426,29 @@ namespace configmgr if (configapi::fillEventDataFromResolved(aEvent,aChange,bMore)) { - + // Catch only RuntimeExceptions here: vetoableChange issues its veto by throwing + // a PropertyVetoException (which is not a RuntimeException) if (pListeners) { ListenerIterator aIterator(*pListeners); while (aIterator.hasMoreElements()) + try + { aIterator.next()->vetoableChange(aEvent); + } + catch (uno::RuntimeException & ) + {} } if (pSpecial) { ListenerIterator aIterator(*pSpecial); while (aIterator.hasMoreElements()) + try + { aIterator.next()->vetoableChange(aEvent); + } + catch (uno::RuntimeException & ) + {} } } } @@ -469,6 +480,7 @@ namespace configmgr ContainerListenerIterator aIterator(*pContainerListeners); while (aIterator.hasMoreElements()) + try { uno::Reference<XContainerListener> xListener( aIterator.next() ); OSL_ASSERT( xListener.is() ); @@ -497,6 +509,8 @@ namespace configmgr break; } } + catch (uno::Exception &) + {} } } @@ -513,7 +527,7 @@ namespace configmgr { PropertyListenerIterator aIterator(*pPropertyListeners); while (aIterator.hasMoreElements()) - aIterator.next()->propertyChange(rEvent); + try { aIterator.next()->propertyChange(rEvent); } catch (uno::Exception & ) {} } ListenerContainer* pSpecialListeners = pNotifierImpl->m_aListeners.getSpecialContainer( aChange.location.getChangingValueID() ); @@ -521,7 +535,7 @@ namespace configmgr { PropertyListenerIterator aIterator(*pSpecialListeners); while (aIterator.hasMoreElements()) - aIterator.next()->propertyChange(rEvent); + try { aIterator.next()->propertyChange(rEvent); } catch (uno::Exception & ) {} } ++pCurEvent; @@ -634,7 +648,7 @@ namespace configmgr { ListenerIterator aIterator(*pContainer); while (aIterator.hasMoreElements()) - aIterator.next()->propertiesChange(aPropertyEvents); + try { aIterator.next()->propertiesChange(aPropertyEvents); } catch (uno::Exception & ) {} } } } @@ -760,7 +774,7 @@ namespace configmgr { ListenerIterator aIterator(*pContainer); while (aIterator.hasMoreElements()) - aIterator.next()->propertiesChange(aPropertyEvents); + try { aIterator.next()->propertiesChange(aPropertyEvents); } catch (uno::Exception & ) {} } } } @@ -1173,7 +1187,7 @@ namespace configmgr aGuardRoot.clear(); while (aIter.hasMoreElements()) - aIter.next()->changesOccurred(aEvent); + try { aIter.next()->changesOccurred(aEvent); } catch (uno::Exception & ) {} } } } @@ -1219,7 +1233,7 @@ Broadcaster::~Broadcaster() } // --------------------------------------------------------------------------------------------------- -void Broadcaster::queryConstraints(NodeChange const& aChange) throw(com::sun::star::beans::PropertyVetoException) +void Broadcaster::queryConstraints(NodeChange const& aChange) throw(beans::PropertyVetoException) { OSL_ENSURE(aChange.isChange(),"Constraint query without a change !"); @@ -1229,14 +1243,29 @@ void Broadcaster::queryConstraints(NodeChange const& aChange) throw(com::sun::st } // --------------------------------------------------------------------------------------------------- -void Broadcaster::queryConstraints(NodeChanges const& aChanges, bool bSingleBase) throw(com::sun::star::beans::PropertyVetoException) +void Broadcaster::queryConstraints(NodeChanges const& aChanges, bool bSingleBase) throw(beans::PropertyVetoException) { OSL_ENSURE(!aChanges.isEmpty(),"Constraint query without a change !"); - NodeChangesInformation aInfos; - if (m_pImpl->translateChanges(aInfos,aChanges,bSingleBase)) + try + { + NodeChangesInformation aInfos; + if (m_pImpl->translateChanges(aInfos,aChanges,bSingleBase)) + { + m_pImpl->queryConstraints(aInfos); + } + } + catch (beans::PropertyVetoException & ) + { + throw; + } + catch (uno::Exception & ) + { + OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners"); + } + catch (configuration::Exception & ) { - m_pImpl->queryConstraints(aInfos); + OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners"); } } // --------------------------------------------------------------------------------------------------- @@ -1265,11 +1294,22 @@ void Broadcaster::notifyListeners(NodeChanges const& aChanges, bool bSingleBase) { OSL_ENSURE(!aChanges.isEmpty(),"Notifying without a change !"); - NodeChangesInformation aInfos; - if (m_pImpl->translateChanges(aInfos,aChanges, bSingleBase)) + try { - m_pImpl->notifyListeners(aInfos); - m_pImpl->notifyRootListeners(aInfos); + NodeChangesInformation aInfos; + if (m_pImpl->translateChanges(aInfos,aChanges, bSingleBase)) + { + m_pImpl->notifyListeners(aInfos); + m_pImpl->notifyRootListeners(aInfos); + } + } + catch (uno::Exception & ) + { + OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners"); + } + catch (configuration::Exception & ) + { + OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners"); } } // --------------------------------------------------------------------------------------------------- @@ -1278,11 +1318,22 @@ void Broadcaster::notifyListeners(NodeChangesInformation const& aChanges, bool b { OSL_ENSURE(!aChanges.empty(),"Notifying without a change !"); - NodeChangesInformation aInfos; - if (m_pImpl->translateChanges(aInfos,aChanges, bSingleBase)) + try + { + NodeChangesInformation aInfos; + if (m_pImpl->translateChanges(aInfos,aChanges, bSingleBase)) + { + m_pImpl->notifyListeners(aInfos); + m_pImpl->notifyRootListeners(aInfos); + } + } + catch (uno::Exception & ) + { + OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners"); + } + catch (configuration::Exception & ) { - m_pImpl->notifyListeners(aInfos); - m_pImpl->notifyRootListeners(aInfos); + OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners"); } } // --------------------------------------------------------------------------------------------------- diff --git a/configmgr/source/api2/broadcaster.hxx b/configmgr/source/api2/broadcaster.hxx index 237f88f37c8d..3e5e92620042 100644 --- a/configmgr/source/api2/broadcaster.hxx +++ b/configmgr/source/api2/broadcaster.hxx @@ -2,9 +2,9 @@ * * $RCSfile: broadcaster.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: hr $ $Date: 2001-09-27 18:43:10 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,7 +66,6 @@ #include <com/sun/star/beans/PropertyVetoException.hpp> #endif -#include "apitypes.hxx" #include <vos/ref.hxx> namespace configmgr diff --git a/configmgr/source/api2/committer.cxx b/configmgr/source/api2/committer.cxx index fda5e81760ca..bee2cc287343 100644 --- a/configmgr/source/api2/committer.cxx +++ b/configmgr/source/api2/committer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: committer.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:19:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,9 +67,6 @@ #ifndef CONFIGMGR_ROOTTREE_HXX_ #include "roottree.hxx" #endif -#ifndef CONFIGMGR_CMTREEMODEL_HXX -#include "cmtreemodel.hxx" -#endif #ifndef CONFIGMGR_API_PROVIDERIMPL2_HXX_ #include "confproviderimpl2.hxx" #endif @@ -79,6 +76,9 @@ #ifndef CONFIGMGR_TREEACCESSOR_HXX #include "treeaccessor.hxx" #endif +#ifndef CONFIGMGR_TREECHANGELIST_HXX +#include "treechangelist.hxx" +#endif namespace configmgr { @@ -133,10 +133,14 @@ void Committer::commit() OSL_PRECOND(!m_rTree.getLocation().isRoot(),"INTERNAL ERROR: Empty location used."); OSL_PRECOND(m_rTree.getOptions().isValid(),"INTERNAL ERROR: Invalid Options used."); + if (!m_rTree.getOptions().isValid()) return; + + RequestOptions aOptions = m_rTree.getOptions()->getRequestOptions(); + ITreeManager* pUpdateProvider = getUpdateProvider(); OSL_ASSERT(pUpdateProvider); - memory::Segment * pCacheSegment = pUpdateProvider->getDataSegment(m_rTree.getLocation(),m_rTree.getOptions()); + memory::Segment * pCacheSegment = pUpdateProvider->getDataSegment(m_rTree.getLocation(),aOptions); OSL_ASSERT(rApiTree.getSourceData() == pCacheSegment); memory::UpdateAccessor aUpdateAccessor(pCacheSegment); @@ -145,7 +149,7 @@ void Committer::commit() Tree aTree( aUpdateAccessor.accessor(), rApiTree.getTree()); if (!aTree.hasChanges()) return; - TreeChangeList aChangeList(m_rTree.getOptions(), + TreeChangeList aChangeList(aOptions, aTree.getRootPath(), aTree.getAttributes(aTree.getRootNode())); diff --git a/configmgr/source/api2/confignotifier.hxx b/configmgr/source/api2/confignotifier.hxx index 1b98e9b631c8..12ef2a942cba 100644 --- a/configmgr/source/api2/confignotifier.hxx +++ b/configmgr/source/api2/confignotifier.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confignotifier.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: hr $ $Date: 2001-09-27 18:43:10 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,14 +62,23 @@ #ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_ #define CONFIGMGR_CONFIGNOTIFIER_HXX_ -#include "apitypes.hxx" +#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" +#endif +#ifndef CONFIGMGR_CONFIGPATH_HXX_ #include "configpath.hxx" +#endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif #include <vos/ref.hxx> #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> #endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif namespace com { namespace sun { namespace star { namespace beans @@ -214,7 +223,7 @@ namespace configmgr class TreeElement; /// guards a NodeAccess; provides a simple lock for non-data access, does not check for disposed state - class DisposeGuardImpl : NotCopyable + class DisposeGuardImpl : Noncopyable { osl::MutexGuard m_aLock; public: diff --git a/configmgr/source/api2/confprovider2.cxx b/configmgr/source/api2/confprovider2.cxx index c304b04c841f..3425b89ec278 100644 --- a/configmgr/source/api2/confprovider2.cxx +++ b/configmgr/source/api2/confprovider2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: confprovider2.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,9 +66,18 @@ #ifndef CONFIGMGR_API_PROVIDERIMPL2_HXX_ #include "confproviderimpl2.hxx" #endif +#ifndef CONFIGMGR_API_FACTORY_HXX_ +#include "confapifactory.hxx" +#endif #ifndef CONFIGMGR_BOOTSTRAP_HXX_ #include "bootstrap.hxx" #endif +#ifndef CONFIGMGR_BOOTSTRAPCONTEXT_HXX_ +#include "bootstrapcontext.hxx" +#endif +#ifndef CONFIGMGR_WRAPEXCEPTION_HXX +#include "wrapexception.hxx" +#endif #ifndef _CONFIGMGR_TRACER_HXX_ #include "tracer.hxx" #endif @@ -79,8 +88,9 @@ #ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> #endif -#ifndef __SGI_STL_ALGORITHM +#ifndef INCLUDED_ALGORITHM #include <algorithm> +#define INCLUDED_ALGORITHM #endif #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> @@ -107,34 +117,63 @@ namespace configmgr namespace { - typedef uno::Reference< uno::XInterface > (OConfigurationProviderImpl::*CreatorFunc)(const uno::Sequence< uno::Any >& aArguments); - struct ServiceCreationInfo - { - ServiceRegistrationInfo const* info; - CreatorFunc create; - }; - - AsciiServiceName const aProviderServices[] = + //------------------------------------------------------------------------ + AsciiServiceName const aConfigProviderServices[] = { "com.sun.star.configuration.ConfigurationProvider", 0 }; - AsciiServiceName const aLocalAdminProviderServices[] = + AsciiServiceName const aAdminProviderServices[] = { "com.sun.star.configuration.AdministrationProvider", 0 }; - ServiceImplementationInfo const aProviderInfo = + //------------------------------------------------------------------------ + + ServiceImplementationInfo const aConfigProviderInfo = { "com.sun.star.comp.configuration.ConfigurationProvider", - aProviderServices, + aConfigProviderServices, 0 }; - ServiceImplementationInfo const aLocalAdminProviderInfo = + ServiceImplementationInfo const aAdminProviderInfo = + { + "com.sun.star.comp.configuration.AdministrationProvider", + aAdminProviderServices, + aConfigProviderServices + }; + //------------------------------------------------------------------------ + + AsciiServiceName const + aDefaultProviderServiceAndImplName = A_DefaultProviderServiceAndImplName; + + //------------------------------------------------------------------------ + + AsciiServiceName const aDefaultProviderServices[] = { - "com.sun.star.comp.configuration.LocalAdministrationProvider", - aLocalAdminProviderServices, - aProviderServices + aDefaultProviderServiceAndImplName, + 0 + }; + //------------------------------------------------------------------------ + + ServiceRegistrationInfo const aDefaultProviderInfo = + { + aDefaultProviderServiceAndImplName, + aDefaultProviderServices + }; + SingletonRegistrationInfo const aDefaultProviderSingletonInfo = + { + A_DefaultProviderSingletonName, + aDefaultProviderServiceAndImplName, + aDefaultProviderServiceAndImplName, + 0 + }; + //------------------------------------------------------------------------ + typedef uno::Reference< uno::XInterface > (OConfigurationProviderImpl::*CreatorFunc)(const uno::Sequence< uno::Any >& aArguments); + struct ServiceCreationInfo + { + ServiceRegistrationInfo const* info; + CreatorFunc create; }; static sal_Int32 getCreateServiceDataCount() @@ -153,6 +192,7 @@ namespace configmgr "getCreateServiceData : inconsistent data !"); return createServiceData; } + //------------------------------------------------------------------------ } static ServiceCreationInfo const* findCreationInfo( const OUString& aServiceSpecifier ) @@ -192,52 +232,95 @@ namespace configmgr //= OConfigurationProvider //============================================================================= // service info export - const ServiceRegistrationInfo* getConfigurationProviderServices() + const ServiceRegistrationInfo* getConfigurationProviderServiceInfo() { - return getRegistrationInfo(&aProviderInfo); + return getRegistrationInfo(&aConfigProviderInfo); } - const ServiceRegistrationInfo* getLocalAdminProviderServices() + const ServiceRegistrationInfo* getAdminProviderServiceInfo() { - return getRegistrationInfo(&aLocalAdminProviderInfo); + return getRegistrationInfo(&aAdminProviderInfo); + } + + const ServiceRegistrationInfo* getDefaultProviderServiceInfo() + { + return &aDefaultProviderInfo; + } + + const SingletonRegistrationInfo* getDefaultProviderSingletonInfo() + { + return &aDefaultProviderSingletonInfo; } //----------------------------------------------------------------------------- - // provider instantiation - uno::Reference< uno::XInterface > SAL_CALL instantiateConfigProvider( uno::Reference< lang::XMultiServiceFactory > const& rServiceManager, ConnectionSettings const& _aSettings ) + uno::Reference<uno::XInterface> SAL_CALL + getDefaultConfigProviderSingleton( CreationContext const& xContext ) { - OConfigurationProvider* pNewProvider = new OConfigurationProvider(rServiceManager,&aProviderInfo); - uno::Reference< lang::XMultiServiceFactory > aRet( pNewProvider ); + OSL_ENSURE( xContext.is(), "ERROR: NULL context has no singletons" ); - ::rtl::OUString const sService(RTL_CONSTASCII_USTRINGPARAM("configuration")); + UnoContextTunnel aTunnel; + aTunnel.passthru( xContext ); - ConnectionSettings aSettings(_aSettings); - aSettings.setUserSession(sService); + uno::Reference<uno::XInterface> xResult; - pNewProvider->connect(aSettings); + if (xContext.is()) + try + { + OUString aSingletonName = SINGLETON(A_DefaultProviderSingletonName); + uno::Any aResult = xContext->getValueByName(aSingletonName); + aResult >>= xResult; + } + catch (uno::Exception & ) + { + // to do: really use the tunneled failure when that is set properly + if ( aTunnel.recoverFailure(true).hasValue() ) + { + // have a failure, but can't recover it + // -> try to regenerate + instantiateDefaultProvider(xContext); - return aRet; + OSL_ENSURE(false, "Cannot recreate configuration backend instantiation failure - using generic error"); + } + // cannot recover any failure + throw; + } + + return xResult; } + // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------- + #define TUNNEL_ALL_EXCEPTIONS() \ + WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS1( UnoContextTunnel::tunnelFailure, true) + + // ---------------------------------------------------------------------------- + // ------------------------------------------------------------------------ - uno::Reference< uno::XInterface > SAL_CALL instantiateLocalAdminProvider( uno::Reference< lang::XMultiServiceFactory > const& rServiceManager, ConnectionSettings const& _aSettings ) + uno::Reference< uno::XInterface > SAL_CALL instantiateDefaultProvider( OProvider::CreationContext const & xTargetContext ) { - OConfigurationProvider* pNewProvider = new OConfigurationProvider(rServiceManager,&aLocalAdminProviderInfo); - uno::Reference< lang::XMultiServiceFactory > aRet( pNewProvider ); + CreationContext xContext = UnoContextTunnel::recoverContext(xTargetContext); + + ServiceImplementationInfo const * pProviderInfo = + ContextReader::testAdminService(xContext,true) ? &aAdminProviderInfo : &aConfigProviderInfo; - ConnectionSettings aSettings(_aSettings); - aSettings.setAdminSession(); + OConfigurationProvider* pNewProvider = new OConfigurationProvider(xContext,pProviderInfo); + uno::Reference< lang::XMultiServiceFactory > aRet( pNewProvider ); - pNewProvider->connect(aSettings); + try + { + pNewProvider->connect(); + } + TUNNEL_ALL_EXCEPTIONS() return aRet; } //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- OConfigurationProvider::OConfigurationProvider( - const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory, + CreationContext const & xContext, const ServiceImplementationInfo* pServices ) - :OProvider(_xServiceFactory,pServices) + :OProvider(xContext,pServices) ,m_pImpl(NULL) { registerProperty(rtl::OUString::createFromAscii("PrefetchNodes"), ID_PREFETCH, 0,&m_aPrefetchNodes, ::getCppuType(static_cast< uno::Sequence< rtl::OUString > const * >(0) )); @@ -250,13 +333,13 @@ namespace configmgr } //----------------------------------------------------------------------------- - void OConfigurationProvider::connect(const ConnectionSettings& _rSettings) throw (uno::Exception) + void OConfigurationProvider::connect() throw (uno::Exception) { OSL_ENSURE( m_pImpl == NULL, "Error: Configuration Provider already is connected"); - std::auto_ptr<OConfigurationProviderImpl> pNewImpl( new OConfigurationProviderImpl(this, m_xServiceFactory) ); + std::auto_ptr<OConfigurationProviderImpl> pNewImpl( new OConfigurationProviderImpl(this, m_xContext) ); - implConnect(*pNewImpl,_rSettings); + implConnect(*pNewImpl,ContextReader(m_xContext)); m_pImpl = pNewImpl.release(); } @@ -380,13 +463,13 @@ namespace configmgr uno::Sequence< OUString > aNodeList; rValue >>= aNodeList; - ::vos::ORef<OOptions> xOptions(new OOptions(m_pImpl->getDefaultOptions())); + RequestOptions const aOptions = m_pImpl->getDefaultOptions(); for (sal_Int32 i = 0; i < aNodeList.getLength(); i++) { using namespace configuration; AbsolutePath aModulePath = AbsolutePath::makeModulePath(aNodeList[i], AbsolutePath::NoValidate()); - m_pImpl->fetchSubtree(aModulePath , xOptions); + m_pImpl->fetchSubtree(aModulePath , aOptions); } } diff --git a/configmgr/source/api2/confprovider2.hxx b/configmgr/source/api2/confprovider2.hxx index bdd0095a7bd1..07d3805d69c6 100644 --- a/configmgr/source/api2/confprovider2.hxx +++ b/configmgr/source/api2/confprovider2.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confprovider2.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,12 +89,10 @@ namespace configmgr OConfigurationProviderImpl* m_pImpl; uno::Sequence< ::rtl::OUString > m_aPrefetchNodes; - protected: - OConfigurationProvider(const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory, ServiceImplementationInfo const* pServices); - void connect(const ConnectionSettings& _rSettings) throw (uno::Exception); + public: + OConfigurationProvider(CreationContext const & xContext, ServiceImplementationInfo const* pServices); + void connect() throw (uno::Exception); - friend uno::Reference< uno::XInterface > SAL_CALL instantiateConfigProvider( uno::Reference< lang::XMultiServiceFactory > const& rServiceManager, ConnectionSettings const& _aSettings ); - friend uno::Reference< uno::XInterface > SAL_CALL instantiateLocalAdminProvider( uno::Reference< lang::XMultiServiceFactory > const& rServiceManager, ConnectionSettings const& _aSettings ); public: ~OConfigurationProvider(); @@ -119,9 +117,9 @@ namespace configmgr throw (::com::sun::star::uno::Exception); // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual uno::Any SAL_CALL queryInterface( const uno::Type & rType ) throw(uno::RuntimeException); //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw(uno::RuntimeException); protected: virtual void SAL_CALL disposing(); diff --git a/configmgr/source/api2/confproviderimpl2.cxx b/configmgr/source/api2/confproviderimpl2.cxx index b466644ab842..872ee1c28857 100644 --- a/configmgr/source/api2/confproviderimpl2.cxx +++ b/configmgr/source/api2/confproviderimpl2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: confproviderimpl2.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:21:39 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -107,8 +107,8 @@ namespace configmgr //= OConfigurationProviderImpl //============================================================================= //----------------------------------------------------------------------------------- - OConfigurationProviderImpl::OConfigurationProviderImpl(OConfigurationProvider* _pProvider, const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory) - :OProviderImpl(_pProvider, _xServiceFactory) + OConfigurationProviderImpl::OConfigurationProviderImpl(OConfigurationProvider* _pProvider, CreationContext const & xContext) + :OProviderImpl(_pProvider, xContext) { } //-------------------------------------------------------------------------- @@ -120,46 +120,18 @@ namespace configmgr // extract the args OUString sPath; sal_Int32 nLevels; - vos::ORef<OOptions> xOptions = new OOptions(getDefaultOptions()); - OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, xOptions); + RequestOptions aOptions = getDefaultOptions(); + + OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, aOptions); CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath)); CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels); - if (!xOptions->canUseCache()) CFG_TRACE_INFO_NI("config provider: Ignoring cache for request"); - - OUString sUser = xOptions->getUser(); - if (sUser.getLength()) - { - if (xOptions->getDefaultUser() == sUser) - { - OSL_ASSERT(xOptions->isForSessionUser()); - OSL_ASSERT(xOptions->getUser() == sUser); - // respecified the actual user - CFG_TRACE_WARNING_NI("config provider: User should not be specified again when creating an Access"); - OSL_ENSURE(false,"config provider: User should not be specified again when creating an Access"); - } - else if (!xOptions->getDefaultUser().getLength() ) - { - // have no default user - cannot tell whether the argument is the wrong one - CFG_TRACE_WARNING_NI("config provider: No user should be specified, when creating an Access - user parameter is ignored"); - OSL_ENSURE(false,"config provider: No user should be specified, when creating an Access - user parameter is ignored"); - } - else - { - // specified a different user - CFG_TRACE_ERROR_NI("config provider: Cannot access foreign user data"); - throw lang::IllegalArgumentException(OUString::createFromAscii("config provider: Cannot access foreign user data"),this->getProviderInstance(), -1); - } - // user should always be the default user! - xOptions->setUser(xOptions->getDefaultUser()); - } - // create the access object uno::Reference< uno::XInterface > xReturn; - NodeElement* pElement = buildReadAccess(sPath, xOptions, nLevels); + NodeElement* pElement = buildReadAccess(sPath, aOptions, nLevels); if (pElement != 0) { xReturn = pElement->getUnoInstance(); @@ -180,53 +152,18 @@ namespace configmgr // extract the args OUString sPath; sal_Int32 nLevels; - vos::ORef<OOptions> xOptions = new OOptions(getDefaultOptions()); - OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, xOptions); + RequestOptions aOptions = getDefaultOptions(); + + OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, aOptions); CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath)); CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels); - if (!xOptions->canUseCache()) - { - CFG_TRACE_INFO_NI("config provider: Ignoring cache for request"); - OSL_ENSURE( !xOptions->getLazyWrite(), "WARNING: Async writing is enabled for non-cached node. Results may be unexpected."); - if (xOptions->getLazyWrite()) - CFG_TRACE_WARNING_NI("config provider: Async writing is enabled for non-cached node. Results may be unexpected."); - } - - - OUString sUser = xOptions->getUser(); - if (sUser.getLength()) - { - if (xOptions->getDefaultUser() == sUser) - { - OSL_ASSERT(xOptions->isForSessionUser()); - OSL_ASSERT(xOptions->getUser() == sUser); - // respecified the actual user - CFG_TRACE_WARNING_NI("config provider: User should not be specified again when creating an Access"); - OSL_ENSURE(false,"config provider: User should not be specified again when creating an Access"); - } - else if (!xOptions->getDefaultUser().getLength() ) - { - // have no default user - cannot tell whether the argument is the wrong one - CFG_TRACE_WARNING_NI("config provider: No user should be specified, when creating an Access - user parameter is ignored"); - OSL_ENSURE(false,"config provider: No user should be specified, when creating an Access - user parameter is ignored"); - } - else - { - // specified a different user - CFG_TRACE_ERROR_NI("config provider: Cannot access foreign user data"); - throw lang::IllegalArgumentException(OUString::createFromAscii("config provider: Cannot access foreign user data"),this->getProviderInstance(), -1); - } - // user should always be the default user! - xOptions->setUser(xOptions->getDefaultUser()); - } - // create the access object uno::Reference< uno::XInterface > xReturn; - NodeElement* pElement = buildUpdateAccess(sPath, xOptions, nLevels); + NodeElement* pElement = buildUpdateAccess(sPath, aOptions, nLevels); if (pElement != 0) { xReturn = pElement->getUnoInstance(); diff --git a/configmgr/source/api2/confproviderimpl2.hxx b/configmgr/source/api2/confproviderimpl2.hxx index 5f73c89d47f4..073c57e6ca17 100644 --- a/configmgr/source/api2/confproviderimpl2.hxx +++ b/configmgr/source/api2/confproviderimpl2.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confproviderimpl2.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-11-09 11:23:57 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,7 +89,7 @@ namespace configmgr uno::Reference<uno::XInterface> createUpdateAccess( uno::Sequence<uno::Any> const& aArgs) CFG_UNO_THROW_ALL( ); private: OConfigurationProviderImpl(OConfigurationProvider* _pProvider, - const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory); + CreationContext const & xContext); }; } // namespace configmgr diff --git a/configmgr/source/api2/elementaccess.cxx b/configmgr/source/api2/elementaccess.cxx index 3e5edecd55b3..cb9d91ac7bfe 100644 --- a/configmgr/source/api2/elementaccess.cxx +++ b/configmgr/source/api2/elementaccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: elementaccess.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2001-02-05 10:05:51 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,8 +70,8 @@ namespace configmgr { //----------------------------------------------------------------------------------- - using namespace configapi; + namespace uno = com::sun::star::uno; using uno::Reference; using uno::Sequence; using uno::Any; @@ -92,7 +92,7 @@ void SAL_CALL BasicInnerElement::release() throw() { if (1 == m_refCount) { - implDisposeObject( getNodeAccess(), getElementClass() ); + configapi::implDisposeObject( getNodeAccess(), getElementClass() ); } BaseImplHelper::release(); } @@ -102,7 +102,7 @@ void SAL_CALL BasicSetElement::release() throw() { if (1 == m_refCount) { - implDisposeObject( getNodeAccess(), getElementClass() ); + configapi::implDisposeObject( getNodeAccess(), getElementClass() ); } BaseImplHelper::release(); } @@ -112,7 +112,7 @@ void SAL_CALL BasicRootElement::release() throw() { if (1 == m_refCount) { - implDisposeObject( getNodeAccess(), getElementClass() ); + configapi::implDisposeObject( getNodeAccess(), getElementClass() ); } BaseImplHelper::release(); } @@ -122,7 +122,7 @@ void SAL_CALL BasicUpdateElement::release() throw() { if (1 == m_refCount) { - implDisposeObject( getNodeAccess(), getElementClass() ); + configapi::implDisposeObject( getNodeAccess(), getElementClass() ); } BaseImplHelper::release(); } @@ -134,25 +134,25 @@ void SAL_CALL BasicUpdateElement::release() throw() uno::Sequence<sal_Int8> SAL_CALL BasicInnerElement::getImplementationId( ) throw(uno::RuntimeException) { - return implGetImplementationId( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence<sal_Int8> SAL_CALL BasicSetElement::getImplementationId( ) throw(uno::RuntimeException) { - return implGetImplementationId( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence<sal_Int8> SAL_CALL BasicRootElement::getImplementationId( ) throw(uno::RuntimeException) { - return implGetImplementationId( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence<sal_Int8> SAL_CALL BasicUpdateElement::getImplementationId( ) throw(uno::RuntimeException) { - return implGetImplementationId( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- @@ -162,13 +162,13 @@ uno::Sequence<sal_Int8> SAL_CALL BasicUpdateElement::getImplementationId( ) thr Reference< uno::XInterface > SAL_CALL BasicInnerElement::getParent( ) throw(RuntimeException) { - return implGetParent( getNodeAccess(), getElementClass() ); + return configapi::implGetParent( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- Reference< uno::XInterface > SAL_CALL BasicSetElement::getParent( ) throw(RuntimeException) { - return implGetParent( getNodeAccess(), getElementClass() ); + return configapi::implGetParent( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- @@ -176,14 +176,14 @@ Reference< uno::XInterface > SAL_CALL BasicSetElement::getParent( ) throw(Runti void SAL_CALL BasicInnerElement::setParent( const Reference< uno::XInterface >& xParent ) throw(css::lang::NoSupportException, RuntimeException) { - implSetParent( getNodeAccess(), getElementClass(), xParent ); + configapi::implSetParent( getNodeAccess(), getElementClass(), xParent ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicSetElement::setParent( const Reference< uno::XInterface >& xParent ) throw(css::lang::NoSupportException, RuntimeException) { - implSetParent( getNodeAccess(), getElementClass(), xParent ); + configapi::implSetParent( getNodeAccess(), getElementClass(), xParent ); } //----------------------------------------------------------------------------------- @@ -193,50 +193,50 @@ void SAL_CALL BasicSetElement::setParent( const Reference< uno::XInterface >& xP OUString SAL_CALL BasicInnerElement::getName( ) throw(RuntimeException) { - return implGetName( getNodeAccess(), getElementClass() ); + return configapi::implGetName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- OUString SAL_CALL BasicSetElement::getName( ) throw(RuntimeException) { - return implGetName( getNodeAccess(), getElementClass() ); + return configapi::implGetName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- OUString SAL_CALL BasicRootElement::getName( ) throw(RuntimeException) { - return implGetName( getNodeAccess(), getElementClass() ); + return configapi::implGetName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- OUString SAL_CALL BasicUpdateElement::getName( ) throw(RuntimeException) { - return implGetName( getNodeAccess(), getElementClass() ); + return configapi::implGetName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- void SAL_CALL BasicInnerElement::setName( const OUString& aName ) throw(RuntimeException) { - implSetName( getNodeAccess(), getElementClass(), aName ); + configapi::implSetName( getNodeAccess(), getElementClass(), aName ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicSetElement::setName( const OUString& aName ) throw(RuntimeException) { - implSetName( getNodeAccess(), getElementClass(), aName ); + configapi::implSetName( getNodeAccess(), getElementClass(), aName ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicRootElement::setName( const OUString& aName ) throw(RuntimeException) { - implSetName( getNodeAccess(), getElementClass(), aName ); + configapi::implSetName( getNodeAccess(), getElementClass(), aName ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::setName( const OUString& aName ) throw(RuntimeException) { - implSetName( getNodeAccess(), getElementClass(), aName ); + configapi::implSetName( getNodeAccess(), getElementClass(), aName ); } //----------------------------------------------------------------------------------- @@ -247,14 +247,14 @@ void SAL_CALL BasicUpdateElement::setName( const OUString& aName ) throw(Runtime void SAL_CALL BasicRootElement::addChangesListener( const Reference< css::util::XChangesListener >& xListener ) throw(RuntimeException) { - implAddListener( getNodeAccess(), xListener ); + configapi::implAddListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::addChangesListener( const Reference< css::util::XChangesListener >& xListener ) throw(RuntimeException) { - implAddListener( getNodeAccess(), xListener ); + configapi::implAddListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- @@ -262,14 +262,14 @@ void SAL_CALL BasicUpdateElement::addChangesListener( const Reference< css::util void SAL_CALL BasicRootElement::removeChangesListener( const Reference< css::util::XChangesListener >& xListener ) throw(RuntimeException) { - implRemoveListener( getNodeAccess(), xListener ); + configapi::implRemoveListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::removeChangesListener( const Reference< css::util::XChangesListener >& xListener ) throw(RuntimeException) { - implRemoveListener( getNodeAccess(), xListener ); + configapi::implRemoveListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- @@ -279,19 +279,19 @@ void SAL_CALL BasicUpdateElement::removeChangesListener( const Reference< css::u void SAL_CALL BasicSetElement::dispose( ) throw(uno::RuntimeException) { - implDispose( getElementClass() ); + configapi::implDispose( getElementClass() ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicRootElement::dispose( ) throw(uno::RuntimeException) { - implDispose( getElementClass() ); + configapi::implDispose( getElementClass() ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::dispose( ) throw(uno::RuntimeException) { - implDispose( getElementClass() ); + configapi::implDispose( getElementClass() ); } //----------------------------------------------------------------------------------- @@ -299,21 +299,21 @@ void SAL_CALL BasicUpdateElement::dispose( ) throw(uno::RuntimeException) void SAL_CALL BasicSetElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - implAddListener( getNodeAccess(), xListener ); + configapi::implAddListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicRootElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - implAddListener( getNodeAccess(), xListener ); + configapi::implAddListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - implAddListener( getNodeAccess(), xListener ); + configapi::implAddListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- @@ -321,21 +321,21 @@ void SAL_CALL BasicUpdateElement::addEventListener( const uno::Reference< css::l void SAL_CALL BasicSetElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - implRemoveListener( getNodeAccess(), xListener ); + configapi::implRemoveListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicRootElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - implRemoveListener( getNodeAccess(), xListener ); + configapi::implRemoveListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - implRemoveListener( getNodeAccess(), xListener ); + configapi::implRemoveListener( getNodeAccess(), xListener ); } //----------------------------------------------------------------------------------- @@ -345,75 +345,75 @@ void SAL_CALL BasicUpdateElement::removeEventListener( const uno::Reference< css OUString SAL_CALL BasicInnerElement::getImplementationName( ) throw(uno::RuntimeException) { - return implGetImplementationName( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- OUString SAL_CALL BasicSetElement::getImplementationName( ) throw(uno::RuntimeException) { - return implGetImplementationName( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- OUString SAL_CALL BasicRootElement::getImplementationName( ) throw(uno::RuntimeException) { - return implGetImplementationName( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- OUString SAL_CALL BasicUpdateElement::getImplementationName( ) throw(uno::RuntimeException) { - return implGetImplementationName( getNodeAccess(), getElementClass() ); + return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicInnerElement::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) { - return implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); + return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); } //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicSetElement::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) { - return implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); + return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); } //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicRootElement::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) { - return implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); + return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); } //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicUpdateElement::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) { - return implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); + return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); } //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- uno::Sequence< OUString > SAL_CALL BasicInnerElement::getSupportedServiceNames( ) throw(uno::RuntimeException) { - return implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); + return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence< OUString > SAL_CALL BasicSetElement::getSupportedServiceNames( ) throw(uno::RuntimeException) { - return implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); + return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence< OUString > SAL_CALL BasicRootElement::getSupportedServiceNames( ) throw(uno::RuntimeException) { - return implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); + return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence< OUString > SAL_CALL BasicUpdateElement::getSupportedServiceNames( ) throw(uno::RuntimeException) { - return implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); + return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); } //----------------------------------------------------------------------------------- @@ -426,7 +426,7 @@ uno::Sequence< OUString > SAL_CALL BasicUpdateElement::getSupportedServiceNames OUString SAL_CALL BasicSetElement::getTemplateName( ) throw(uno::RuntimeException) { - return implGetTemplateName( getElementClass() ); + return configapi::implGetTemplateName( getElementClass() ); } //----------------------------------------------------------------------------------- @@ -436,7 +436,7 @@ OUString SAL_CALL BasicSetElement::getTemplateName( ) throw(uno::RuntimeExceptio sal_Int64 SAL_CALL BasicSetElement::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier ) throw(uno::RuntimeException) { - return implGetSomething( getElementClass(), aIdentifier); + return configapi::implGetSomething( getElementClass(), aIdentifier); } //----------------------------------------------------------------------------------- @@ -450,26 +450,26 @@ sal_Int64 SAL_CALL BasicSetElement::getSomething( const uno::Sequence< sal_Int8 css::lang::Locale SAL_CALL BasicRootElement::getLocale( ) throw(uno::RuntimeException) { - return implGetLocale( getElementClass() ); + return configapi::implGetLocale( getElementClass() ); } //----------------------------------------------------------------------------------- css::lang::Locale SAL_CALL BasicUpdateElement::getLocale( ) throw(uno::RuntimeException) { - return implGetLocale( getElementClass() ); + return configapi::implGetLocale( getElementClass() ); } //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- void SAL_CALL BasicRootElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException) { - implSetLocale( getElementClass(), eLocale ); + configapi::implSetLocale( getElementClass(), eLocale ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicUpdateElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException) { - implSetLocale( getElementClass(), eLocale ); + configapi::implSetLocale( getElementClass(), eLocale ); } //----------------------------------------------------------------------------------- @@ -479,19 +479,19 @@ void SAL_CALL BasicUpdateElement::setLocale( const css::lang::Locale& eLocale ) void SAL_CALL BasicUpdateElement::commitChanges( ) throw(css::lang::WrappedTargetException, uno::RuntimeException) { - implCommitChanges( getElementClass() ); + configapi::implCommitChanges( getElementClass() ); } //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicUpdateElement::hasPendingChanges( ) throw(uno::RuntimeException) { - return implHasPendingChanges( getElementClass() ); + return configapi::implHasPendingChanges( getElementClass() ); } //----------------------------------------------------------------------------------- uno::Sequence< css::util::ElementChange > SAL_CALL BasicUpdateElement::getPendingChanges( ) throw(uno::RuntimeException) { - return implGetPendingChanges( getElementClass() ); + return configapi::implGetPendingChanges( getElementClass() ); } //----------------------------------------------------------------------------------- diff --git a/configmgr/source/api2/elementaccess.hxx b/configmgr/source/api2/elementaccess.hxx index cbcd513ae418..1fd7642cbbf3 100644 --- a/configmgr/source/api2/elementaccess.hxx +++ b/configmgr/source/api2/elementaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: elementaccess.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2001-02-05 10:05:51 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,15 +100,12 @@ #include <cppuhelper/implbase6.hxx> #endif -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - namespace configmgr { //----------------------------------------------------------------------------- namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; //----------------------------------------------------------------------------- namespace configapi diff --git a/configmgr/source/api2/elementimpl.cxx b/configmgr/source/api2/elementimpl.cxx index a2f4ab967d01..038f9b53553b 100644 --- a/configmgr/source/api2/elementimpl.cxx +++ b/configmgr/source/api2/elementimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: elementimpl.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,9 @@ #ifndef CONFIGMGR_API_TRANSLATECHANGES_HXX_ #include "translatechanges.hxx" #endif +#ifndef CONFIGMGR_API_APITYPES_HXX_ +#include "apitypes.hxx" +#endif #ifndef CONFIGMGR_CONFIGSET_HXX_ #include "configset.hxx" diff --git a/configmgr/source/api2/elementimpl.hxx b/configmgr/source/api2/elementimpl.hxx index 78ed4c324931..af150d0dce36 100644 --- a/configmgr/source/api2/elementimpl.hxx +++ b/configmgr/source/api2/elementimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: elementimpl.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,6 @@ #ifndef CONFIGMGR_API_ELEMENTIMPL_HXX_ #define CONFIGMGR_API_ELEMENTIMPL_HXX_ -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> #endif @@ -86,6 +82,7 @@ namespace configmgr { namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; /* implementations of the interfaces supported by a (parent) node within the configuration tree. diff --git a/configmgr/source/api2/groupaccess.cxx b/configmgr/source/api2/groupaccess.cxx index 2f010c575cde..1ce2eaced095 100644 --- a/configmgr/source/api2/groupaccess.cxx +++ b/configmgr/source/api2/groupaccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: groupaccess.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,7 +66,6 @@ namespace configmgr { - using namespace configapi; using uno::Reference; using uno::Sequence; @@ -77,14 +76,14 @@ namespace configmgr //------------------------------------------------------------------------------------------------------------------ OUString SAL_CALL BasicGroupAccess::getHierarchicalName( ) throw(RuntimeException) { - return implGetHierarchicalName( getNode() ); + return configapi::implGetHierarchicalName( getNode() ); } //------------------------------------------------------------------------------------------------------------------ OUString SAL_CALL BasicGroupAccess::composeHierarchicalName( const OUString& sRelativeName ) throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, RuntimeException) { - return implComposeHierarchicalName( getNode(), sRelativeName ); + return configapi::implComposeHierarchicalName( getNode(), sRelativeName ); } //------------------------------------------------------------------------------------------------------------------ @@ -95,13 +94,13 @@ OUString SAL_CALL BasicGroupAccess::composeHierarchicalName( const OUString& sRe //----------------------------------------------------------------------------------- uno::Type SAL_CALL BasicGroupAccess::getElementType( ) throw(RuntimeException) { - return implGetElementType( getNode() ); + return configapi::implGetElementType( getNode() ); } //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicGroupAccess::hasElements( ) throw(RuntimeException) { - return implHasElements( getNode() ); + return configapi::implHasElements( getNode() ); } // XExactName @@ -109,7 +108,7 @@ sal_Bool SAL_CALL BasicGroupAccess::hasElements( ) throw(RuntimeException) OUString SAL_CALL BasicGroupAccess::getExactName( const OUString& rApproximateName ) throw(RuntimeException) { - return implGetExactName( getNode(), rApproximateName); + return configapi::implGetExactName( getNode(), rApproximateName); } // XProperty @@ -117,7 +116,7 @@ OUString SAL_CALL BasicGroupAccess::getExactName( const OUString& rApproximateNa css::beans::Property SAL_CALL BasicGroupAccess::getAsProperty( ) throw(uno::RuntimeException) { - return implGetAsProperty( getNode() ); + return configapi::implGetAsProperty( getNode() ); } // XNameAccess @@ -125,34 +124,34 @@ css::beans::Property SAL_CALL BasicGroupAccess::getAsProperty( ) throw(uno::Run sal_Bool SAL_CALL BasicGroupAccess::hasByName( const OUString& sName ) throw(RuntimeException) { - return implHasByName( getNode(), sName); + return configapi::implHasByName( getNode(), sName); } //----------------------------------------------------------------------------------- Any SAL_CALL BasicGroupAccess::getByName( const OUString& sName ) throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, RuntimeException) { - return implGetByName( getNode(), sName ); + return configapi::implGetByName( getNode(), sName ); } //----------------------------------------------------------------------------------- Sequence< OUString > SAL_CALL BasicGroupAccess::getElementNames( ) throw( RuntimeException) { - return implGetElementNames( getNode() ); + return configapi::implGetElementNames( getNode() ); } // XHierarchicalNameAccess //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicGroupAccess::hasByHierarchicalName( const OUString& sName ) throw(RuntimeException) { - return implHasByHierarchicalName( getNode(), sName); + return configapi::implHasByHierarchicalName( getNode(), sName); } //----------------------------------------------------------------------------------- Any SAL_CALL BasicGroupAccess::getByHierarchicalName( const OUString& sName ) throw(css::container::NoSuchElementException, RuntimeException) { - return implGetByHierarchicalName( getNode(), sName ); + return configapi::implGetByHierarchicalName( getNode(), sName ); } @@ -162,14 +161,14 @@ Any SAL_CALL BasicGroupAccess::getByHierarchicalName( const OUString& sName ) void SAL_CALL BasicGroupAccess::addContainerListener( const Reference< css::container::XContainerListener >& xListener ) throw(RuntimeException) { - implAddListener( getNode(), xListener ); + configapi::implAddListener( getNode(), xListener ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicGroupAccess::removeContainerListener( const Reference< css::container::XContainerListener >& xListener ) throw(RuntimeException) { - implRemoveListener( getNode(), xListener ); + configapi::implRemoveListener( getNode(), xListener ); } diff --git a/configmgr/source/api2/groupaccess.hxx b/configmgr/source/api2/groupaccess.hxx index b6d3605209e5..5dd46168fbfd 100644 --- a/configmgr/source/api2/groupaccess.hxx +++ b/configmgr/source/api2/groupaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: groupaccess.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,14 +85,11 @@ #include <cppuhelper/implbase6.hxx> #endif -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - namespace configmgr { namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; namespace configapi { class NodeGroupInfoAccess; } diff --git a/configmgr/source/api2/groupupdate.cxx b/configmgr/source/api2/groupupdate.cxx index db862ecc37e5..0352f023cc99 100644 --- a/configmgr/source/api2/groupupdate.cxx +++ b/configmgr/source/api2/groupupdate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: groupupdate.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,7 @@ #include "groupupdate.hxx" #include "updateimpl.hxx" #include "apinodeaccess.hxx" +#include "apitypes.hxx" #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> @@ -69,7 +70,6 @@ namespace configmgr { ////////////////////////////////////////////////////////////////////////////////// - using namespace configapi; using uno::Reference; using uno::Sequence; @@ -100,7 +100,7 @@ uno::Sequence< uno::Type > SAL_CALL BasicGroup::getTypes( ) throw (uno::RuntimeE { /*static ?*/ cppu::OTypeCollection aTypes( - getReferenceType(static_cast< css::container::XNameReplace *>(this)), + configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)), BasicGroupAccess::getTypes()); return aTypes.getTypes(); @@ -133,7 +133,7 @@ configapi::NodeGroupAccess& BasicGroup::getGroupNode() void SAL_CALL BasicGroup::replaceByName( const OUString& rName, const uno::Any& rElement ) throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) { - implReplaceByName( getGroupNode(), rName, rElement ); + configapi::implReplaceByName( getGroupNode(), rName, rElement ); } //----------------------------------------------------------------------------------- diff --git a/configmgr/source/api2/groupupdate.hxx b/configmgr/source/api2/groupupdate.hxx index 0070b5071343..344b7f6c8c9a 100644 --- a/configmgr/source/api2/groupupdate.hxx +++ b/configmgr/source/api2/groupupdate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: groupupdate.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,10 +68,6 @@ #include <com/sun/star/container/XNameReplace.hpp> #endif -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - //........................................................................ namespace configmgr { diff --git a/configmgr/source/api2/listenercontainer.cxx b/configmgr/source/api2/listenercontainer.cxx index cff13daf15e6..1f3ef35e98ff 100644 --- a/configmgr/source/api2/listenercontainer.cxx +++ b/configmgr/source/api2/listenercontainer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: listenercontainer.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-13 13:27:15 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,7 +98,7 @@ void DisposeNotifier::notify() { if (it->is()) { - (*it)->disposing(aEvent); + try { (*it)->disposing(aEvent); } catch (uno::Exception & ) {} it->clear(); } } diff --git a/configmgr/source/api2/listenercontainer.hxx b/configmgr/source/api2/listenercontainer.hxx index ef7dfd7fd03c..925cce54d5b6 100644 --- a/configmgr/source/api2/listenercontainer.hxx +++ b/configmgr/source/api2/listenercontainer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: listenercontainer.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: jb $ $Date: 2002-10-15 15:02:27 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,6 @@ #ifndef CONFIGMGR_API_LISTENERCONTAINER_HXX_ #define CONFIGMGR_API_LISTENERCONTAINER_HXX_ -#include "apitypes.hxx" - #ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ #include <com/sun/star/lang/XEventListener.hpp> #endif @@ -262,14 +260,14 @@ namespace configmgr * Call disposing on all object in all the containers that * support XEventListener. Then clear the container. */ - bool disposeAll(KeyFinder _aFinder) throw(uno::RuntimeException); + bool disposeAll(KeyFinder _aFinder) throw(); /** * Call disposing on all object in all the container for anIndex * and in the containers for the associated indices * support XEventListener. Then clear the container. */ - bool disposeOne( KeyFinder _aFinder, Index anIndex ) throw(uno::RuntimeException); + bool disposeOne( KeyFinder _aFinder, Index anIndex ) throw(); /** * Start disposing this object, leave the mutex locked for dispose processing @@ -289,7 +287,7 @@ namespace configmgr * @return <FALSE/> * if disposing had already been started before */ - void notifyDisposing(KeyFinder _aFinder) throw(uno::RuntimeException); + void notifyDisposing(KeyFinder _aFinder) throw(); /// mark the end of the dispose processing void endDisposing() throw(); @@ -334,7 +332,7 @@ namespace configmgr * the same pointer more than once. * @return the new count of elements in the container (or 0 if the object is ready being disposed). */ - sal_Int32 addListener( Index nIndex, const UnoType& aType, uno::Reference< lang::XEventListener > const& xListener) throw(uno::RuntimeException); + sal_Int32 addListener( Index nIndex, const UnoType& aType, uno::Reference< lang::XEventListener > const& xListener) throw(); /** * Remove an element from the container specified with the index and type. @@ -343,7 +341,7 @@ namespace configmgr * @param xListener the removed interface. * @return the new count of elements in the container (or 0 if the object is ready being disposed). */ - sal_Int32 removeListener( Index nIndex, const UnoType& aType, uno::Reference< lang::XEventListener > const& xListener) throw(uno::RuntimeException); + sal_Int32 removeListener( Index nIndex, const UnoType& aType, uno::Reference< lang::XEventListener > const& xListener) throw(); /** @@ -354,7 +352,7 @@ namespace configmgr * the same pointer more than once. * @return the new count of elements in the container (or 0 if the object is ready being disposed). */ - sal_Int32 addSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw(uno::RuntimeException); + sal_Int32 addSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw(); /** * Remove an element from the container specified with the key. @@ -363,7 +361,7 @@ namespace configmgr * @param xListener the removed interface. * @return the new count of elements in the container (or 0 if the object is ready being disposed). */ - sal_Int32 removeSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw(uno::RuntimeException); + sal_Int32 removeSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw(); private: void implFillDisposer(DisposeNotifier& aNotifier, KeyFinder _aFinder, Index nIndex); @@ -409,7 +407,7 @@ namespace configmgr } //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::disposeAll(KeyFinder _aFinder) throw(uno::RuntimeException) + bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::disposeAll(KeyFinder _aFinder) throw() { if (beginDisposing()) { @@ -422,7 +420,7 @@ namespace configmgr } //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::disposeOne(KeyFinder _aFinder, Index nIndex) throw(uno::RuntimeException) + bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::disposeOne(KeyFinder _aFinder, Index nIndex) throw() { // OSL_ENSURE(!isDisposed(),"Object is already disposed in toto"); @@ -467,7 +465,7 @@ namespace configmgr } //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::notifyDisposing(KeyFinder _aFinder) throw(uno::RuntimeException) + void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::notifyDisposing(KeyFinder _aFinder) throw() { OSL_ENSURE(isDisposing(),"Disposing isn't in progress on this object"); OSL_ENSURE(m_bDisposeLock,"Duplicate call for dispose notification or disposing is not taking place"); @@ -529,7 +527,7 @@ namespace configmgr } //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addListener( Index nIndex, const UnoType& aType, const uno::Reference< lang::XEventListener > & xListener ) throw(uno::RuntimeException) + sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addListener( Index nIndex, const UnoType& aType, const uno::Reference< lang::XEventListener > & xListener ) throw() { osl::ClearableMutexGuard aGuard( mutex() ); @@ -547,7 +545,7 @@ namespace configmgr { lang::EventObject aEvent(m_aContainers[nIndex].pInterface); aGuard.clear(); - xListener->disposing(aEvent); + try { xListener->disposing(aEvent); } catch (uno::Exception & ) {} } } @@ -558,7 +556,7 @@ namespace configmgr } //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw(uno::RuntimeException) + sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw() { osl::ClearableMutexGuard aGuard( mutex() ); @@ -574,7 +572,7 @@ namespace configmgr { lang::EventObject aEvent(m_aContainers[nIndex].pInterface); aGuard.clear(); - xListener->disposing(aEvent); + try { xListener->disposing(aEvent); } catch (uno::Exception & ) {} } } else @@ -585,7 +583,7 @@ namespace configmgr //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeListener( Index nIndex, const UnoType& aType, const uno::Reference< lang::XEventListener > & xListener ) throw(uno::RuntimeException) + sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeListener( Index nIndex, const UnoType& aType, const uno::Reference< lang::XEventListener > & xListener ) throw() { osl::MutexGuard aGuard( mutex() ); OSL_ENSURE( !isDisposed(), "object is disposed" ); @@ -602,7 +600,7 @@ namespace configmgr //----------------------------------------------------------------------------- template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw(uno::RuntimeException) + sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw() { osl::MutexGuard aGuard( mutex() ); OSL_ENSURE( !isDisposed(), "object is disposed" ); diff --git a/configmgr/source/api2/makefile.mk b/configmgr/source/api2/makefile.mk index a6de27ed0959..8360e5174b58 100644 --- a/configmgr/source/api2/makefile.mk +++ b/configmgr/source/api2/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: dg $ $Date: 2001-10-11 14:18:27 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:18:34 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -74,21 +74,15 @@ ENABLE_EXCEPTIONS=TRUE # --- Files ------------------------------------- SLOFILES= \ - $(SLO)$/adminimpl.obj \ - $(SLO)$/userimpl.obj \ - $(SLO)$/groupimpl.obj \ - $(SLO)$/confapifactory.obj \ $(SLO)$/broadcaster.obj \ $(SLO)$/listenercontainer.obj \ $(SLO)$/provider.obj \ $(SLO)$/providerimpl.obj \ - $(SLO)$/adminprovider.obj \ - $(SLO)$/adminproviderimpl.obj \ $(SLO)$/confprovider2.obj \ $(SLO)$/confproviderimpl2.obj \ $(SLO)$/accessimpl.obj \ $(SLO)$/apiaccessobj.obj \ - $(SLO)$/apiserviceinfo.obj \ + $(SLO)$/apiserviceinfo.obj \ $(SLO)$/apifactory.obj \ $(SLO)$/apifactoryimpl.obj \ $(SLO)$/apinodeaccess.obj \ @@ -111,6 +105,7 @@ SLOFILES= \ $(SLO)$/setobjects.obj \ $(SLO)$/setupdate.obj \ $(SLO)$/translatechanges.obj \ + $(SLO)$/treeiterators.obj \ $(SLO)$/updateimpl.obj \ diff --git a/configmgr/source/api2/notifierimpl.hxx b/configmgr/source/api2/notifierimpl.hxx index 66fa14e8b7e2..021f41b8cfaa 100644 --- a/configmgr/source/api2/notifierimpl.hxx +++ b/configmgr/source/api2/notifierimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: notifierimpl.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,6 @@ #ifndef CONFIGMGR_API_NOTIFIERIMPL_HXX_ #define CONFIGMGR_API_NOTIFIERIMPL_HXX_ -#include "apitypes.hxx" - #include "listenercontainer.hxx" #include "noderef.hxx" diff --git a/configmgr/source/api2/objectregistry.hxx b/configmgr/source/api2/objectregistry.hxx index 4021a817ca0b..dd46f317bb3d 100644 --- a/configmgr/source/api2/objectregistry.hxx +++ b/configmgr/source/api2/objectregistry.hxx @@ -2,9 +2,9 @@ * * $RCSfile: objectregistry.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: armin $ $Date: 2001-03-07 17:18:22 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,7 +62,6 @@ #ifndef CONFIGMGR_API_OBJECTREGISTRY_HXX_ #define CONFIGMGR_API_OBJECTREGISTRY_HXX_ -#include "apitypes.hxx" #include "noderef.hxx" #include <osl/mutex.hxx> diff --git a/configmgr/source/api2/propertyinfohelper.cxx b/configmgr/source/api2/propertyinfohelper.cxx index d79a2b74ac01..b088295fe7ad 100644 --- a/configmgr/source/api2/propertyinfohelper.cxx +++ b/configmgr/source/api2/propertyinfohelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: propertyinfohelper.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,6 +64,10 @@ #ifndef CONFIGMGR_CONFIGPATH_HXX_ #include "configpath.hxx" #endif +#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_ +#include "attributes.hxx" +#endif + #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HDL_ #include <com/sun/star/beans/PropertyAttribute.hdl> #endif @@ -78,7 +82,7 @@ namespace configmgr { //----------------------------------------------------------------------------- beans::Property helperMakeProperty(configuration::Name const& aName, - configuration::Attributes const aAttributes, + node::Attributes const aAttributes, uno::Type const& aType, bool bDefaultable ) throw(uno::RuntimeException) diff --git a/configmgr/source/api2/propertyinfohelper.hxx b/configmgr/source/api2/propertyinfohelper.hxx index da81eeb1f16a..b9dbf619ef19 100644 --- a/configmgr/source/api2/propertyinfohelper.hxx +++ b/configmgr/source/api2/propertyinfohelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: propertyinfohelper.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,17 +62,15 @@ #ifndef CONFIGMGR_API_PROPERTYINFOIMPL_HXX_ #define CONFIGMGR_API_PROPERTYINFOIMPL_HXX_ -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_ #include <com/sun/star/beans/Property.hpp> #endif +#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_ +#include <com/sun/star/uno/RuntimeException.hpp> +#endif namespace configmgr { - namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; namespace beans = ::com::sun::star::beans; diff --git a/configmgr/source/api2/propertysetaccess.cxx b/configmgr/source/api2/propertysetaccess.cxx index 56b1a925c6fc..6274b3199fd2 100644 --- a/configmgr/source/api2/propertysetaccess.cxx +++ b/configmgr/source/api2/propertysetaccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: propertysetaccess.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,7 +68,6 @@ namespace configmgr { ////////////////////////////////////////////////////////////////////////////////// - using namespace configapi; using uno::Reference; using uno::Sequence; @@ -88,7 +87,7 @@ namespace configmgr uno::Reference< beans::XPropertySetInfo > SAL_CALL BasicPropertySet::getPropertySetInfo( ) throw(uno::RuntimeException) { - return implGetPropertySetInfo( getNode(), NULL != maybeGetUpdateAccess() ); + return configapi::implGetPropertySetInfo( getNode(), NULL != maybeGetUpdateAccess() ); } // XHierarchicalPropertySet & XHierarchicalMultiPropertySet @@ -96,7 +95,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL BasicPropertySet::getProperty uno::Reference< beans::XHierarchicalPropertySetInfo > SAL_CALL BasicPropertySet::getHierarchicalPropertySetInfo( ) throw(uno::RuntimeException) { - return implGetHierarchicalPropertySetInfo( getNode() ); + return configapi::implGetHierarchicalPropertySetInfo( getNode() ); } ////////////////////////////////////////////////////////////////////////////////// @@ -125,7 +124,7 @@ void SAL_CALL BasicPropertySet::setPropertyValue( const OUString& aPropertyName, throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - implSetPropertyValue( getGroupNode(), aPropertyName, aValue ); + configapi::implSetPropertyValue( getGroupNode(), aPropertyName, aValue ); } // XMultiPropertySet @@ -134,7 +133,7 @@ void SAL_CALL BasicPropertySet::setPropertyValues( const uno::Sequence< OUString throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - implSetPropertyValues( getGroupNode(), PropertyNames, Values ); + configapi::implSetPropertyValues( getGroupNode(), PropertyNames, Values ); } // XHierarchicalPropertySet @@ -143,7 +142,7 @@ void SAL_CALL BasicPropertySet::setHierarchicalPropertyValue( const OUString& aP throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - implSetHierarchicalPropertyValue( getGroupNode(), aPropertyName, aValue ); + configapi::implSetHierarchicalPropertyValue( getGroupNode(), aPropertyName, aValue ); } // XMultiHierarchicalPropertySet @@ -152,7 +151,7 @@ void SAL_CALL BasicPropertySet::setHierarchicalPropertyValues( const uno::Sequen throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - implSetHierarchicalPropertyValues( getGroupNode(), PropertyNames, Values ); + configapi::implSetHierarchicalPropertyValues( getGroupNode(), PropertyNames, Values ); } @@ -164,7 +163,7 @@ void SAL_CALL BasicPropertySet::setHierarchicalPropertyValues( const uno::Sequen uno::Any SAL_CALL BasicPropertySet::getPropertyValue( const OUString& aPropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - return implGetPropertyValue( getNode(), aPropertyName ); + return configapi::implGetPropertyValue( getNode(), aPropertyName ); } // XMultiPropertySet @@ -172,7 +171,7 @@ uno::Any SAL_CALL BasicPropertySet::getPropertyValue( const OUString& aPropertyN uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames ) throw(uno::RuntimeException) { - return implGetPropertyValues( getNode(), aPropertyNames ); + return configapi::implGetPropertyValues( getNode(), aPropertyNames ); } // XHierarchicalPropertySet @@ -180,7 +179,7 @@ uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyValues( const un uno::Any SAL_CALL BasicPropertySet::getHierarchicalPropertyValue( const OUString& aPropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - return implGetHierarchicalPropertyValue( getNode(), aPropertyName ); + return configapi::implGetHierarchicalPropertyValue( getNode(), aPropertyName ); } // XMultiHierarchicalPropertySet @@ -188,7 +187,7 @@ uno::Any SAL_CALL BasicPropertySet::getHierarchicalPropertyValue( const OUString uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getHierarchicalPropertyValues( const uno::Sequence< OUString >& aPropertyNames ) throw(uno::RuntimeException) { - return implGetHierarchicalPropertyValues( getNode(), aPropertyNames ); + return configapi::implGetHierarchicalPropertyValues( getNode(), aPropertyNames ); } ////////////////////////////////////////////////////////////////////////////////// @@ -198,40 +197,40 @@ uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getHierarchicalPropertyValu void SAL_CALL BasicPropertySet::addVetoableChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XVetoableChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - implAddListener( getNode(), xListener, aPropertyName ); + configapi::implAddListener( getNode(), xListener, aPropertyName ); } void SAL_CALL BasicPropertySet::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - implAddListener( getNode(), xListener, aPropertyName ); + configapi::implAddListener( getNode(), xListener, aPropertyName ); } void SAL_CALL BasicPropertySet::addPropertiesChangeListener( const uno::Sequence< OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) throw(uno::RuntimeException) { - implAddListener( getNode(), xListener, aPropertyNames ); + configapi::implAddListener( getNode(), xListener, aPropertyNames ); } ////////////////////////////////////////////////////////////////////////////////// void SAL_CALL BasicPropertySet::removeVetoableChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XVetoableChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - implRemoveListener( getNode(), xListener, aPropertyName ); + configapi::implRemoveListener( getNode(), xListener, aPropertyName ); } //--------------------------------------------------------------------------------- void SAL_CALL BasicPropertySet::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - implRemoveListener( getNode(), xListener, aPropertyName ); + configapi::implRemoveListener( getNode(), xListener, aPropertyName ); } //--------------------------------------------------------------------------------- void SAL_CALL BasicPropertySet::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& xListener ) throw(uno::RuntimeException) { - implRemoveListener( getNode(), xListener ); + configapi::implRemoveListener( getNode(), xListener ); } //--------------------------------------------------------------------------------- @@ -242,7 +241,7 @@ void SAL_CALL BasicPropertySet::removePropertiesChangeListener( const uno::Refer void SAL_CALL BasicPropertySet::firePropertiesChangeEvent( const uno::Sequence< OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) throw(uno::RuntimeException) { - implFirePropertiesChangeEvent( getNode(),aPropertyNames , xListener ); + configapi::implFirePropertiesChangeEvent( getNode(),aPropertyNames , xListener ); } ////////////////////////////////////////////////////////////////////////////////// @@ -255,14 +254,14 @@ void SAL_CALL BasicPropertySet::firePropertiesChangeEvent( const uno::Sequence< beans::PropertyState SAL_CALL BasicPropertySet::getPropertyState( const OUString& sPropertyName ) throw(beans::UnknownPropertyException, uno::RuntimeException) { - return implGetPropertyState( getNode(), sPropertyName); + return configapi::implGetPropertyState( getNode(), sPropertyName); } //--------------------------------------------------------------------------------- uno::Sequence< beans::PropertyState > SAL_CALL BasicPropertySet::getPropertyStates( const uno::Sequence< OUString >& aPropertyNames ) throw(beans::UnknownPropertyException, uno::RuntimeException) { - return implGetPropertyStates( getNode(), aPropertyNames ); + return configapi::implGetPropertyStates( getNode(), aPropertyNames ); } //--------------------------------------------------------------------------------- @@ -272,21 +271,21 @@ uno::Sequence< beans::PropertyState > SAL_CALL BasicPropertySet::getPropertyStat void SAL_CALL BasicPropertySet::setPropertyToDefault( const OUString& sPropertyName ) throw(beans::UnknownPropertyException, uno::RuntimeException) { - implSetPropertyToDefault( getGroupNode(), sPropertyName); + configapi::implSetPropertyToDefault( getGroupNode(), sPropertyName); } //--------------------------------------------------------------------------------- void SAL_CALL BasicPropertySet::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException) { - implSetPropertiesToDefault( getGroupNode(), aPropertyNames); + configapi::implSetPropertiesToDefault( getGroupNode(), aPropertyNames); } //--------------------------------------------------------------------------------- void SAL_CALL BasicPropertySet::setAllPropertiesToDefault( ) throw (uno::RuntimeException) { - implSetAllPropertiesToDefault( getGroupNode() ); + configapi::implSetAllPropertiesToDefault( getGroupNode() ); } //--------------------------------------------------------------------------------- @@ -297,14 +296,14 @@ uno::Any SAL_CALL BasicPropertySet::getPropertyDefault( const OUString& sPropert throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - return implGetPropertyDefault( getNode(), sPropertyName); + return configapi::implGetPropertyDefault( getNode(), sPropertyName); } //--------------------------------------------------------------------------------- uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - return implGetPropertyDefaults( getNode(), aPropertyNames); + return configapi::implGetPropertyDefaults( getNode(), aPropertyNames); } //--------------------------------------------------------------------------------- diff --git a/configmgr/source/api2/propertysetaccess.hxx b/configmgr/source/api2/propertysetaccess.hxx index 1ee16a54b9e8..d6c808caf6b0 100644 --- a/configmgr/source/api2/propertysetaccess.hxx +++ b/configmgr/source/api2/propertysetaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: propertysetaccess.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,10 +86,6 @@ #include <cppuhelper/implbase6.hxx> #endif -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - namespace configmgr { ///////////////////////////////////////////////////////////////////////////////////////////// @@ -97,6 +93,7 @@ namespace configmgr namespace uno = css::uno; namespace lang = css::lang; namespace beans = css::beans; + using rtl::OUString; namespace configapi { diff --git a/configmgr/source/api2/propsetaccessimpl.cxx b/configmgr/source/api2/propsetaccessimpl.cxx index 1235f332b4e6..7ddd00645441 100644 --- a/configmgr/source/api2/propsetaccessimpl.cxx +++ b/configmgr/source/api2/propsetaccessimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: propsetaccessimpl.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,11 +88,14 @@ #ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_ #include "confignotifier.hxx" #endif +#ifndef CONFIGMGR_API_BROADCASTER_HXX_ +#include "broadcaster.hxx" +#endif #ifndef CONFIGMGR_API_APITYPES_HXX_ #include "apitypes.hxx" #endif -#ifndef CONFIGMGR_API_BROADCASTER_HXX_ -#include "broadcaster.hxx" +#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_ +#include "attributes.hxx" #endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ @@ -185,7 +188,7 @@ public: } private: - typedef configuration::Attributes NodeAttributes; + typedef node::Attributes NodeAttributes; void reset() { m_aProperties.clear(); } diff --git a/configmgr/source/api2/propsetaccessimpl.hxx b/configmgr/source/api2/propsetaccessimpl.hxx index 5acd712a975d..396b027f02e2 100644 --- a/configmgr/source/api2/propsetaccessimpl.hxx +++ b/configmgr/source/api2/propsetaccessimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: propsetaccessimpl.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,6 @@ #ifndef CONFIGMGR_API_PROPERTYSETIMPL_HXX_ #define CONFIGMGR_API_PROPERTYSETIMPL_HXX_ -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> #endif @@ -91,6 +87,7 @@ namespace configmgr namespace uno = ::com::sun::star::uno; namespace lang = ::com::sun::star::lang; namespace beans = ::com::sun::star::beans; + using rtl::OUString; /* implementations of the interfaces supported by a (parent) node within the configuration tree. diff --git a/configmgr/source/api2/provider.cxx b/configmgr/source/api2/provider.cxx index 21790d1be739..fd1fbcbefc02 100644 --- a/configmgr/source/api2/provider.cxx +++ b/configmgr/source/api2/provider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: provider.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:29 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,9 +68,6 @@ #include "bootstrap.hxx" #endif -#ifndef CONFIGMGR_CMTREEMODEL_HXX -#include "cmtreemodel.hxx" -#endif #ifndef _OSL_MUTEX_HXX_ #include <osl/mutex.hxx> #endif @@ -117,9 +114,12 @@ namespace configmgr virtual void SAL_CALL disposing(com::sun::star::lang::EventObject const& rEvt) throw() { - CFG_TRACE_INFO("Service Manager disposed, disposing the provider"); - if (m_pProvider) - m_pProvider->disposing(rEvt); + CFG_TRACE_INFO("Service Manager or context disposed, disposing the provider"); + if (OProvider* pProvider = m_pProvider) + { + m_pProvider = NULL; + pProvider->disposing(rEvt); + } } }; @@ -127,28 +127,85 @@ namespace configmgr //= OProvider //============================================================================= //----------------------------------------------------------------------------- - OProvider::OProvider(const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory, ServiceImplementationInfo const* pInfo) + OProvider::OProvider(CreationContext const & xContext, ServiceImplementationInfo const* pInfo) :ServiceComponentImpl(pInfo) ,OPropertyContainer(ServiceComponentImpl::rBHelper) - ,m_xServiceFactory(_xServiceFactory) + ,m_xContext(xContext) { - m_xDisposeListener = new OProviderDisposingListener(this); - uno::Reference<com::sun::star::lang::XComponent> xComponent(m_xServiceFactory, uno::UNO_QUERY); - if (xComponent.is()) - xComponent->addEventListener(m_xDisposeListener); + OSL_ENSURE(m_xContext.is(), "Creating a provider without a context"); + attachToContext(); } //----------------------------------------------------------------------------- OProvider::~OProvider() { - if (m_xDisposeListener.is() && m_xServiceFactory.is()) + discardContext(releaseContext()); + } + + //----------------------------------------------------------------------------- + void OProvider::attachToContext() + { + ::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex); + OSL_ASSERT(!m_xDisposeListener.is()); + if (m_xContext.is()) { - uno::Reference<com::sun::star::lang::XComponent> xComponent(m_xServiceFactory, uno::UNO_QUERY); - if (xComponent.is()) - xComponent->removeEventListener(m_xDisposeListener); + uno::Reference< lang::XComponent > xContextComp(m_xContext, uno::UNO_QUERY); + uno::Reference< lang::XComponent > xServiceMgrComp(m_xContext->getServiceManager(), uno::UNO_QUERY); + + m_xDisposeListener = new OProviderDisposingListener(this); + + if (xContextComp.is()) xContextComp ->addEventListener(m_xDisposeListener); + if (xServiceMgrComp.is()) xServiceMgrComp->addEventListener(m_xDisposeListener); + + OSL_ENSURE(xServiceMgrComp.is() || xContextComp.is(), + "Provider cannot detect shutdown -> no XComponent found"); } } + //----------------------------------------------------------------------------- + uno::Reference< lang::XComponent > OProvider::releaseContext() + { + ::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex); + + uno::Reference< lang::XComponent > xContextComp(m_xContext, uno::UNO_QUERY); + if (m_xDisposeListener.is() && m_xContext.is()) + { + uno::Reference< lang::XComponent > xServiceMgrComp(m_xContext->getServiceManager(), uno::UNO_QUERY); + + if (xContextComp.is()) + { + try { xContextComp ->removeEventListener(m_xDisposeListener); } + catch (uno::Exception & ) {} + } + + if (xServiceMgrComp.is()) + { + try { xServiceMgrComp->removeEventListener(m_xDisposeListener); } + catch (uno::Exception & ) {} + } + } + m_xDisposeListener = NULL; + m_xContext = NULL; + + return xContextComp; + } + //----------------------------------------------------------------------------- + + void OProvider::discardContext(uno::Reference< lang::XComponent > const & xContext) + { + if (xContext.is()) + { + uno::Reference< uno::XComponentContext > xCC(xContext,uno::UNO_QUERY); + OSL_ASSERT(xCC.is()); + + if (BootstrapContext::isWrapper(xCC)) + { + try { xContext->dispose(); } + catch (uno::Exception & ) {} + } + } + } + //----------------------------------------------------------------------------- // XTypeProvider //----------------------------------------------------------------------------- uno::Sequence< uno::Type > SAL_CALL OProvider::getTypes( ) throw(uno::RuntimeException) @@ -174,7 +231,7 @@ namespace configmgr } //----------------------------------------------------------------------------- - void OProvider::implConnect(OProviderImpl& _rFreshProviderImpl, const ConnectionSettings& _rSettings) throw(uno::Exception) + void OProvider::implConnect(OProviderImpl& _rFreshProviderImpl, const ContextReader& _rSettings) throw(uno::Exception) { if (!_rFreshProviderImpl.initSession(_rSettings)) throw uno::Exception(::rtl::OUString::createFromAscii("Could not connect to the configuration. Please check your settings."), THISREF() ); @@ -183,32 +240,19 @@ namespace configmgr //----------------------------------------------------------------------------- void SAL_CALL OProvider::disposing(com::sun::star::lang::EventObject const& rEvt) throw() { - { - ::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex); - m_xDisposeListener = NULL; - m_xServiceFactory = NULL; - } - dispose(); + releaseContext(); + this->dispose(); } //----------------------------------------------------------------------------- void SAL_CALL OProvider::disposing() { - { - ::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex); - if (m_xDisposeListener.is() && m_xServiceFactory.is()) - { - uno::Reference<com::sun::star::lang::XComponent> xComponent(m_xServiceFactory, uno::UNO_QUERY); - if (xComponent.is()) - xComponent->removeEventListener(m_xDisposeListener); - } - - m_xServiceFactory = NULL; - m_xDisposeListener = NULL; - } + uno::Reference< lang::XComponent > xComp = releaseContext(); ServiceComponentImpl::disposing(); OPropertyContainer::disposing(); + + discardContext( xComp ); } /* // com::sun::star::lang::XUnoTunnel diff --git a/configmgr/source/api2/provider.hxx b/configmgr/source/api2/provider.hxx index 9f5939a7fbcf..817616b20621 100644 --- a/configmgr/source/api2/provider.hxx +++ b/configmgr/source/api2/provider.hxx @@ -2,9 +2,9 @@ * * $RCSfile: provider.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:29 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,15 +65,15 @@ #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HDL_ #include <com/sun/star/lang/IllegalArgumentException.hdl> #endif #ifndef CONFIGMGR_API_SVCCOMPONENT_HXX_ #include "confsvccomponent.hxx" #endif -#ifndef _CONFIGMGR_COMMONTYPES_HXX_ -#include "commontypes.hxx" -#endif #ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> #endif @@ -96,7 +96,7 @@ namespace configmgr using ::vos::ORef; class Module; - class ConnectionSettings; + class ContextReader; class OProviderImpl; typedef ::cppu::ImplHelper1 < lang::XMultiServiceFactory @@ -121,7 +121,7 @@ namespace configmgr friend class OProviderDisposingListener; protected: - uno::Reference< lang::XMultiServiceFactory > m_xServiceFactory; + uno::Reference< uno::XComponentContext > m_xContext; uno::Reference< lang::XEventListener > m_xDisposeListener; public: @@ -131,7 +131,9 @@ namespace configmgr static void SAL_CALL operator delete( void * pMem ) throw() { ServiceComponentImpl::operator delete( pMem ); } - OProvider(const uno::Reference< lang::XMultiServiceFactory >& xServiceFactory, ServiceImplementationInfo const* pInfo); + typedef uno::Reference< uno::XComponentContext > CreationContext; + + OProvider(CreationContext const & xContext, ServiceImplementationInfo const* pInfo); virtual ~OProvider(); /// XTypeOProvider @@ -159,7 +161,7 @@ namespace configmgr protected: // creates a new session - void implConnect(OProviderImpl& rFreshProviderImpl, const ConnectionSettings& _rSettings) throw (uno::Exception); + void implConnect(OProviderImpl& rFreshProviderImpl, const ContextReader& _rSettings) throw (uno::Exception); protected: /// Component Helper override @@ -179,6 +181,10 @@ namespace configmgr uno::Any SAL_CALL queryPropertyInterface(uno::Type const& rType) throw (uno::RuntimeException) { return OPropertyContainer::queryInterface(rType);} + private: + void attachToContext(); + uno::Reference< lang::XComponent > releaseContext(); + void discardContext(uno::Reference< lang::XComponent > const & xContext); }; } // namespace configmgr diff --git a/configmgr/source/api2/providerimpl.cxx b/configmgr/source/api2/providerimpl.cxx index c77bb8256a84..ae0642d02c3f 100644 --- a/configmgr/source/api2/providerimpl.cxx +++ b/configmgr/source/api2/providerimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: providerimpl.cxx,v $ * - * $Revision: 1.55 $ + * $Revision: 1.56 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:25:01 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,9 +87,6 @@ #ifndef CONFIGMGR_BOOTSTRAP_HXX_ #include "bootstrap.hxx" #endif -#ifndef _CONFIGMGR_SESSION_CONFIGSESSION_HXX_ -#include "configsession.hxx" -#endif #ifndef CONFIGMGR_CACHEFACTORY_HXX_ #include "cachefactory.hxx" #endif @@ -187,25 +184,22 @@ namespace configmgr //============================================================================= //----------------------------------------------------------------------------- OProviderImpl::OProviderImpl(OProvider* _pProvider, CreationContext const & _xContext) - :m_xContext(_xContext) - ,m_pNewProviders(0) + :m_pNewProviders(0) ,m_pProvider(_pProvider) ,m_aTreeManagerMutex() ,m_pTreeManager(NULL) - ,m_pSession(NULL) + ,m_aDefaultOptions() { - OSL_ENSURE(m_xContext.is(), "Module::Module : missing service factory !"); + OSL_ENSURE(_xContext.is(), "OProviderImpl : NULL context !"); + + uno::Reference< lang::XMultiComponentFactory > xFactory = _xContext->getServiceManager(); + OSL_ENSURE(xFactory.is(), "OProviderImpl : missing service factory !"); + m_xTypeConverter = m_xTypeConverter.query( - m_xContext->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" )))); - OSL_ENSURE(m_xTypeConverter.is(), "Module::Module : could not create an instance of the type converter !"); + xFactory->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" )), + _xContext)); - m_xDefaultOptions = new OOptions(); - } - //----------------------------------------------------------------------------- - IConfigSession * OProviderImpl::getSession() const - { - OSL_ENSURE( m_pSession, "Trying to get the legacy session from a new-style provider" ); - return m_pSession; + OSL_ENSURE(m_xTypeConverter.is(), "Module::Module : could not create an instance of the type converter !"); } //----------------------------------------------------------------------------- rtl::Reference< TreeManager > OProviderImpl::maybeGetTreeManager() const CFG_NOTHROW() @@ -253,7 +247,7 @@ namespace configmgr } } //----------------------------------------------------------------------------- - bool OProviderImpl::initSession(const ConnectionSettings& _rSettings) + bool OProviderImpl::initSession(const ContextReader& _rSettings) { bool bNeedProfile = false; rtl::Reference< TreeManager > xNewTreeManager; @@ -261,7 +255,7 @@ namespace configmgr { this->implInitFromSettings(_rSettings,bNeedProfile); - xNewTreeManager = CacheFactory::instance().createCacheManager(_rSettings, m_xContext); + xNewTreeManager = CacheFactory::instance().createCacheManager(_rSettings.getBaseContext()); } else { @@ -281,12 +275,14 @@ namespace configmgr static ::rtl::OUString ssUserProfile(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")); AbsolutePath aProfileModule = AbsolutePath::makeModulePath(ssUserProfile, AbsolutePath::NoValidate()); - data::NodeAccess aProfileTree = xNewTreeManager->requestSubtree(aProfileModule, m_xDefaultOptions); + data::NodeAccess aProfileTree = xNewTreeManager->requestSubtree(aProfileModule, m_aDefaultOptions); if (aProfileTree.isValid()) + { implInitFromProfile(aProfileTree); - // should we clean this up ? - // m_pTreeMgr->releaseSubtree(ssUserProfile, m_xDefaultOptions); + // should we clean this up ? + // xNewTreeManager->releaseSubtree(aProfileModule, xTempOptions); + } } catch (uno::Exception& e) { @@ -299,7 +295,7 @@ namespace configmgr //----------------------------------------------------------------------------- // these can be overridden. default does nothing - void OProviderImpl::initFromSettings(const ConnectionSettings& , bool& ) + void OProviderImpl::initFromSettings(const ContextReader& , bool& ) { } //----------------------------------------------------------------------------- @@ -308,30 +304,27 @@ namespace configmgr } //----------------------------------------------------------------------------- // these implement the base class behavior - void OProviderImpl::implInitFromSettings(const ConnectionSettings& _rSettings, bool& rNeedProfile) + void OProviderImpl::implInitFromSettings(const ContextReader& _rSettings, bool& rNeedProfile) { bool bIntrinsicNeedProfile = true; - // if we have a user name, we have to add and remember it for the session - if (_rSettings.hasUser()) - { - // the username is also part of the connection settings - rtl::OUString sDefaultUser = _rSettings.getUser(); - m_xDefaultOptions->setDefaultUser(sDefaultUser); - } - if (_rSettings.hasLocale()) { bIntrinsicNeedProfile = false; rtl::OUString sDefaultLocale = _rSettings.getLocale(); - m_xDefaultOptions->setDefaultLocale(sDefaultLocale); + m_aDefaultOptions.setLocale(sDefaultLocale); + } + else if (_rSettings.isAdminService()) + { + bIntrinsicNeedProfile = false; + m_aDefaultOptions.setAllLocales(); } else - OSL_ASSERT(m_xDefaultOptions->getDefaultLocale().getLength() == 0); + OSL_ASSERT(!m_aDefaultOptions.hasLocale()); if (_rSettings.hasAsyncSetting()) { - m_xDefaultOptions->setLazyWrite( !!_rSettings.getAsyncSetting() ); + m_aDefaultOptions.enableAsync( !!_rSettings.getAsyncSetting() ); } // call the template method @@ -350,7 +343,7 @@ namespace configmgr OSL_ASSERT(aProfileNode.isValid()); // read the default locale for the user - if (m_xDefaultOptions->getDefaultLocale().getLength() == 0) + if (!m_aDefaultOptions.hasLocale()) { using configuration::Name; using configuration::makeNodeName; @@ -367,7 +360,7 @@ namespace configmgr rtl::OUString sDefaultLocale; if (aValue.getValue() >>= sDefaultLocale) { - m_xDefaultOptions->setDefaultLocale(sDefaultLocale); + m_aDefaultOptions.setLocale(sDefaultLocale); } else OSL_ENSURE(false, "Could not extract locale parameter into string"); @@ -385,7 +378,6 @@ namespace configmgr clearTreeManager(); delete m_pNewProviders; - delete m_pSession; } // --------------------------------- disposing --------------------------------- @@ -398,9 +390,6 @@ namespace configmgr if (xTM.is()) xTM->dispose(); - if (m_pSession) - m_pSession->close(); - clearTreeManager(); } catch (uno::Exception& e) @@ -438,20 +427,21 @@ namespace configmgr // ITreeProvider /ITreeManager //----------------------------------------------------------------------------- - data::NodeAccess OProviderImpl::requestSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) + data::NodeAccess OProviderImpl::requestSubtree( AbsolutePath const& aSubtreePath, + RequestOptions const & _aOptions + ) CFG_UNO_THROW_ALL( ) { rtl::Reference< TreeManager > xTreeManager = getTreeManager(); data::NodeAccess aTree = data::NodeAccess::emptyNode(); try { - aTree = xTreeManager->requestSubtree(aSubtreePath, _xOptions, nMinLevels); + aTree = xTreeManager->requestSubtree(aSubtreePath, _aOptions); } catch(uno::Exception&e) { - ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _xOptions); + ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _aOptions); // append the error message given by the tree provider sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nThe backend returned the following error:\n")); sMessage += e.Message; @@ -461,7 +451,7 @@ namespace configmgr if (!aTree.isValid()) { - ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _xOptions); + ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _aOptions); sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nNo backend error message available\n")); @@ -478,19 +468,19 @@ namespace configmgr } //----------------------------------------------------------------------------- - void OProviderImpl::releaseSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) CFG_NOTHROW() + void OProviderImpl::releaseSubtree( AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions ) CFG_NOTHROW() { rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); if (xTM.is()) - xTM->releaseSubtree(aSubtreePath, _xOptions); + xTM->releaseSubtree(aSubtreePath, _aOptions); } //----------------------------------------------------------------------------- - void OProviderImpl::disposeData(const vos::ORef < OOptions >& _xOptions) CFG_NOTHROW() + void OProviderImpl::disposeData(RequestOptions const& _aOptions) CFG_NOTHROW() { rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); if (xTM.is()) - xTM->disposeData(_xOptions); + xTM->disposeData(_aOptions); } //----------------------------------------------------------------------------- @@ -500,17 +490,17 @@ namespace configmgr } //----------------------------------------------------------------------------- - void OProviderImpl::fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels) CFG_NOTHROW() + void OProviderImpl::fetchSubtree(AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions) CFG_NOTHROW() { rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); if (xTM.is()) - xTM->fetchSubtree(aSubtreePath, _xOptions, nMinLevels); + xTM->fetchSubtree(aSubtreePath, _aOptions); } //----------------------------------------------------------------------------- - sal_Bool OProviderImpl::fetchDefaultData(memory::UpdateAccessor& _aAccessToken, AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) + sal_Bool OProviderImpl::fetchDefaultData(memory::UpdateAccessor& _aAccessToken, AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions) CFG_UNO_THROW_ALL( ) { - return getTreeManager()->fetchDefaultData(_aAccessToken, aSubtreePath, _xOptions, nMinLevels); + return getTreeManager()->fetchDefaultData(_aAccessToken, aSubtreePath, _aOptions); } // IInterface @@ -533,27 +523,27 @@ namespace configmgr } //----------------------------------------------------------------------------- - memory::Segment* OProviderImpl::getDataSegment(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions) + memory::Segment* OProviderImpl::getDataSegment(AbsolutePath const& _rAccessor, RequestOptions const& _aOptions) { - return getTreeManager()->getDataSegment(_rAccessor, _xOptions); + return getTreeManager()->getDataSegment(_rAccessor, _aOptions); } //----------------------------------------------------------------------------------- - OUString OProviderImpl::getErrorMessage(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions) + OUString OProviderImpl::getErrorMessage(AbsolutePath const& _rAccessor, RequestOptions const& _aOptions) { OUString const sAccessor = _rAccessor.toString(); CFG_TRACE_ERROR("config provider: the cache manager could not provide the tree (neither from the cache nor from the session)"); ::rtl::OUString sMessage; - ::rtl::OUString sUser(_xOptions->getUser()); - ::rtl::OUString sLocale(_xOptions->getLocale()); - CFG_TRACE_INFO_NI("config provider: the user we tried this for is \"%s\", the locale \"%s\", the path \"%s\"", OUSTRING2ASCII(sUser), OUSTRING2ASCII(sLocale), OUSTRING2ASCII(sAccessor)); + ::rtl::OUString sEntity(_aOptions.getEntity()); + ::rtl::OUString sLocale(_aOptions.getLocale()); + CFG_TRACE_INFO_NI("config provider: the entity we tried this for is \"%s\", the locale \"%s\", the path \"%s\"", OUSTRING2ASCII(sEntity), OUSTRING2ASCII(sLocale), OUSTRING2ASCII(sAccessor)); sMessage += sAccessor; - if (sUser.getLength()) + if (sEntity.getLength()) { - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (and for user ")); - sMessage += sUser; + sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (and for entity ")); + sMessage += sEntity; sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); } @@ -570,7 +560,7 @@ namespace configmgr // actual factory methods //----------------------------------------------------------------------------------- - NodeElement* OProviderImpl::buildReadAccess(OUString const& _rAccessor, const vos::ORef < OOptions >& _xOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ) + NodeElement* OProviderImpl::buildReadAccess(OUString const& _rAccessor, RequestOptions const& _aOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ) { CFG_TRACE_INFO("config provider: requesting the tree from the cache manager"); @@ -585,21 +575,21 @@ namespace configmgr AbsolutePath aAccessorPath = AbsolutePath::parse(_rAccessor); - data::NodeAccess aTree = this->requestSubtree(aAccessorPath,_xOptions, sal_Int16(nMinLevels)); + data::NodeAccess aTree = this->requestSubtree(aAccessorPath,_aOptions); RTL_LOGFILE_CONTEXT_TRACE(aLog, "data loaded" ); - TreeDepth nDepth = (nMinLevels == ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels); + TreeDepth nDepth = (nMinLevels == treeop::ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels); RTL_LOGFILE_CONTEXT_AUTHOR(aLog2, "configmgr::OProviderImpl", "jb99855", "configmgr: createReadOnlyTree()"); RootTree aRootTree( createReadOnlyTree( - aAccessorPath, this->getDataSegment(aAccessorPath,_xOptions), + aAccessorPath, this->getDataSegment(aAccessorPath,_aOptions), aTree, nDepth, - TemplateProvider( this->getTemplateProvider(), _xOptions ) + TemplateProvider( this->getTemplateProvider(), _aOptions ) )); - return m_pNewProviders->getReaderFactory().makeAccessRoot(aRootTree, _xOptions); + return m_pNewProviders->getReaderFactory().makeAccessRoot(aRootTree, _aOptions); } catch (configuration::Exception& e) { @@ -612,7 +602,7 @@ namespace configmgr //----------------------------------------------------------------------------------- - NodeElement* OProviderImpl::buildUpdateAccess(OUString const& _rAccessor, const vos::ORef < OOptions >& _xOptions, + NodeElement* OProviderImpl::buildUpdateAccess(OUString const& _rAccessor, RequestOptions const& _aOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ) { CFG_TRACE_INFO("config provider: requesting the tree from the cache manager"); @@ -627,22 +617,22 @@ namespace configmgr AbsolutePath aAccessorPath = AbsolutePath::parse(_rAccessor); - data::NodeAccess aTree = requestSubtree(aAccessorPath, _xOptions, sal_Int16(nMinLevels)); + data::NodeAccess aTree = requestSubtree(aAccessorPath, _aOptions); RTL_LOGFILE_CONTEXT_TRACE(aLog, "data loaded" ); - TreeDepth nDepth = (nMinLevels == ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels); + TreeDepth nDepth = (nMinLevels == treeop::ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels); RTL_LOGFILE_CONTEXT_AUTHOR(aLog2, "configmgr::OProviderImpl", "jb99855", "createUpdatableTree()"); RootTree aRootTree( createUpdatableTree( - aAccessorPath, this->getDataSegment(aAccessorPath,_xOptions), + aAccessorPath, this->getDataSegment(aAccessorPath,_aOptions), aTree, nDepth, - TemplateProvider( this->getTemplateProvider(), _xOptions ) + TemplateProvider( this->getTemplateProvider(), _aOptions ) )); - return m_pNewProviders->getWriterFactory().makeAccessRoot(aRootTree, _xOptions); + return m_pNewProviders->getWriterFactory().makeAccessRoot(aRootTree, _aOptions); } catch (configuration::Exception& e) { @@ -659,12 +649,15 @@ namespace configmgr sal_Char const * const OProviderImpl::FactoryArguments::asciiArgumentNames[] = { - "nodepath", // ARG_NODEPATH, // requested node path - "depth", // ARG_DEPTH, // depth of the tree - "user", // ARG_USER, // name of the user - only for admin - "locale", // ARG_LOCALE, // desired locale - "nocache", // ARG_NOCACHE, // cache disabling - "lazywrite" // ARG_ASYNC, // lasy write data + "nodepath", // ARG_NODEPATH, // requested node path + "depth", // ARG_DEPTH, // depth of the tree + "user", // ARG_USER_DEPRECATED, // name of the user - only for admin + "locale", // ARG_LOCALE, // desired locale + "nocache", // ARG_NOCACHE_OBSOLETE, // cache disabling + "lazywrite", // ARG_ASYNC_DEPRECATED, // lasy write data + "enableasync", // ARG_ASYNC, // lasy write data + "entity", // ARG_ENTITY, // name of the entity to be manipulated - only for admin + }; OUString OProviderImpl::FactoryArguments::getArgumentName(Argument _which) CFG_NOTHROW() @@ -719,7 +712,7 @@ namespace configmgr OUString const& aName, uno::Any const& aValue, OUString& /* [out] */ _rNodeAccessor, sal_Int32& /* [out] */ _nLevels, - vos::ORef<OOptions> /* [in/out] */ _xOptions ) + RequestOptions& /* [in/out] */ _rOptions ) CFG_NOTHROW() { switch ( lookupArgument(aName) ) @@ -744,11 +737,12 @@ namespace configmgr } break; - case ARG_USER: + case ARG_ENTITY: + case ARG_USER_DEPRECATED: { OUString sStringVal; if (aValue >>= sStringVal) - _xOptions->setUser(sStringVal); + _rOptions.setEntity(sStringVal); else return false; } @@ -759,14 +753,14 @@ namespace configmgr OUString sStringVal; if (aValue >>= sStringVal) { - _xOptions->setLocale(sStringVal); + _rOptions.setLocale(sStringVal); break; } lang::Locale aLocale; if (aValue >>= aLocale) { - _xOptions->setLocale(makeLocaleString(aLocale)); + _rOptions.setLocale(makeLocaleString(aLocale)); break; } @@ -774,21 +768,22 @@ namespace configmgr } break; - case ARG_NOCACHE: + case ARG_NOCACHE_OBSOLETE: { sal_Bool bBoolVal; if (aValue >>= bBoolVal) - _xOptions->setNoCache(!!bBoolVal); + OSL_ENSURE(false,"ConfigurationProvider: Parameter \"nocache\" is obsolete and has no effect"); else return false; } break; case ARG_ASYNC: + case ARG_ASYNC_DEPRECATED: { sal_Bool bBoolVal; if (aValue >>= bBoolVal) - _xOptions->setLazyWrite(!!bBoolVal); + _rOptions.enableAsync(!!bBoolVal); else return false; } @@ -909,10 +904,10 @@ namespace configmgr void OProviderImpl::FactoryArguments::extractArgs( const uno::Sequence<uno::Any>& _rArgs, OUString& /* [out] */ _rNodeAccessor, sal_Int32& /* [out] */ _nLevels, - vos::ORef<OOptions> /* [in/out] */ _xOptions ) + RequestOptions & /* [in/out] */ _aOptions ) CFG_THROW1 (lang::IllegalArgumentException) { - _nLevels = ITreeProvider::ALL_LEVELS; // setting a fallback + _nLevels = treeop::ALL_LEVELS; // setting a fallback // the args have to be a sequence of property values bool bLegacyFormat = false; @@ -923,12 +918,12 @@ namespace configmgr { if (_rArgs[i] >>= aPV) { - if ( !extractOneArgument(aPV.Name,aPV.Value,_rNodeAccessor,_nLevels,_xOptions) ) + if ( !extractOneArgument(aPV.Name,aPV.Value,_rNodeAccessor,_nLevels,_aOptions) ) failInvalidArgValue(aPV.Name,aPV.Value,i); } else if (_rArgs[i] >>= aNV) { - if ( !extractOneArgument(aNV.Name,aNV.Value,_rNodeAccessor,_nLevels,_xOptions) ) + if ( !extractOneArgument(aNV.Name,aNV.Value,_rNodeAccessor,_nLevels,_aOptions) ) failInvalidArgValue(aNV.Name,aNV.Value,i); } else diff --git a/configmgr/source/api2/providerimpl.hxx b/configmgr/source/api2/providerimpl.hxx index 5fda7e08af39..66fb3f6e6746 100644 --- a/configmgr/source/api2/providerimpl.hxx +++ b/configmgr/source/api2/providerimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: providerimpl.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2002-10-28 14:41:43 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,11 +68,17 @@ #ifndef CONFIGMGR_DEFAULTPROVIDER_HXX #include "defaultprovider.hxx" #endif +#ifndef _CONFIGMGR_COMMONTYPES_HXX_ +#include "commontypes.hxx" // IInterface +#endif -#ifndef CONFIGMGR_MISC_OPTIONS_HXX_ -#include "options.hxx" +#ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_ +#include "requestoptions.hxx" #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ #include <com/sun/star/script/XTypeConverter.hpp> #endif @@ -122,9 +128,8 @@ namespace configmgr class ISubtree; class ITemplateManager; class IConfigDefaultProvider; - class IConfigSession; class TreeManager; - class ConnectionSettings; + class ContextReader; struct IConfigBroadcaster; @@ -150,12 +155,14 @@ namespace configmgr /// possible arguments, given only in small letters. enum Argument { - ARG_NODEPATH, // requested node path - ARG_DEPTH, // depth of the tree - ARG_USER, // name of the user - only for admin - ARG_LOCALE, // desired locale - ARG_NOCACHE, // cache disabling - ARG_ASYNC, // lasy write data + ARG_NODEPATH, // requested node path + ARG_DEPTH, // depth of the tree + ARG_USER_DEPRECATED, // name of the entity to be manipulated - deprecated version + ARG_LOCALE, // desired locale + ARG_NOCACHE_OBSOLETE, // cache disabling - obsolete and nonfunctional + ARG_ASYNC_DEPRECATED, // lasy write data - deprecated version + ARG_ASYNC, // lazy write data + ARG_ENTITY, // name of the entity to be manipulated - only for admin _arg_count, ARG_NOT_FOUND = _arg_count @@ -165,11 +172,12 @@ namespace configmgr static OUString getArgumentName(Argument _which) CFG_NOTHROW(); static Argument lookupArgument(OUString const& sArgumentName) CFG_NOTHROW(); - static OUString getUserArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_USER); } + static OUString getUserArgumentNameD() CFG_NOTHROW() { return getArgumentName(ARG_USER_DEPRECATED); } + static OUString getEntityArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_ENTITY); } static OUString getNodePathArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_NODEPATH); } static OUString getDepthArgumentNameArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_DEPTH); } static OUString getLocaleArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_LOCALE); } - static OUString getNoCacheArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_NOCACHE); } + static OUString getNoCacheArgumentNameD() CFG_NOTHROW() { return getArgumentName(ARG_NOCACHE_OBSOLETE); } static OUString getAsyncArgumentName() CFG_NOTHROW() { return getArgumentName(ARG_ASYNC); } public: /** extracts arguments from the argument sequence into to the parameter variables @@ -185,34 +193,31 @@ namespace configmgr static void extractArgs( const uno::Sequence<uno::Any>& _rArgs, OUString& /* [out] */ _rNodeAccessor, sal_Int32& /* [out] */ _nLevels, - vos::ORef<OOptions> /* [in/out] */ xOptions + RequestOptions& /* [in/out] */ xOptions ) CFG_THROW1(lang::IllegalArgumentException); static bool extractOneArgument( OUString const& aName, uno::Any const& aValue, OUString& /* [out] */ _rNodeAccessor, sal_Int32& /* [out] */ _nLevels, - vos::ORef<OOptions> /* [in/out] */ _xOptions + RequestOptions& /* [in/out] */ xOptions ) CFG_NOTHROW(); }; - private: - typedef uno::Reference< lang::XMultiServiceFactory > CreationContext; + public: + typedef uno::Reference< uno::XComponentContext > CreationContext; typedef uno::Reference< script::XTypeConverter > TypeConverterRef; - CreationContext m_xContext; + private: TypeConverterRef m_xTypeConverter; - vos::ORef<OOptions> m_xDefaultOptions; + RequestOptions m_aDefaultOptions; configapi::ApiProviderInstances* m_pNewProviders; /// order depedency - this must be after the TreeManager mutable osl::Mutex m_aTreeManagerMutex; TreeManager* m_pTreeManager; /// the tree cache. Will hold a reference to us as long as it life - IConfigSession* m_pSession; rtl::Reference< TreeManager > maybeGetTreeManager() const CFG_NOTHROW(); rtl::Reference< TreeManager > getTreeManager() const CFG_UNO_THROW_RTE(); void setTreeManager(TreeManager * pTreeManager) CFG_UNO_THROW_RTE(); void clearTreeManager() CFG_NOTHROW(); - protected: - IConfigSession* getSession() const; public: OProviderImpl(OProvider* _pProvider, CreationContext const & _xContext); @@ -220,19 +225,18 @@ namespace configmgr virtual ~OProviderImpl(); /// ITreeManager - virtual memory::Segment* getDataSegment(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions); - virtual data::NodeAccess requestSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels = ALL_LEVELS) CFG_UNO_THROW_ALL( ); + virtual memory::Segment* getDataSegment(AbsolutePath const& _rAccessor, const RequestOptions& _aOptions); + virtual data::NodeAccess requestSubtree(AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions) CFG_UNO_THROW_ALL( ); virtual void updateTree(memory::UpdateAccessor& _aAccessToken, TreeChangeList& aChanges) CFG_UNO_THROW_ALL( ); - virtual void releaseSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) CFG_NOTHROW(); + virtual void releaseSubtree( AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions ) CFG_NOTHROW(); virtual void saveAndNotifyUpdate(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& aChanges) CFG_UNO_THROW_ALL( ); - virtual void disposeData(const vos::ORef < OOptions >& _xOptions) CFG_NOTHROW(); - virtual void fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels = ALL_LEVELS) CFG_NOTHROW(); + virtual void disposeData(const RequestOptions& _aOptions) CFG_NOTHROW(); + virtual void fetchSubtree(AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions) CFG_NOTHROW(); /// IDefaultableTreeManager virtual sal_Bool fetchDefaultData( memory::UpdateAccessor& _aAccessToken, - AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ); + AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions + ) CFG_UNO_THROW_ALL( ); // IInterface virtual void SAL_CALL acquire( ) throw (); @@ -245,11 +249,11 @@ namespace configmgr rtl::Reference< IConfigTemplateManager > getTemplateProvider() const CFG_UNO_THROW_RTE( ); protected: - static OUString getErrorMessage(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions); + static OUString getErrorMessage(AbsolutePath const& _rAccessor, const RequestOptions& _aOptions); virtual void SAL_CALL dispose() throw(); public: - const OOptions& getDefaultOptions() const {return *m_xDefaultOptions;} + RequestOptions const& getDefaultOptions() const {return m_aDefaultOptions;} TypeConverterRef getTypeConverter() const {return m_xTypeConverter;} configapi::Factory& getWriterFactory(); IConfigBroadcaster* getNotifier() CFG_NOTHROW(); @@ -257,17 +261,17 @@ namespace configmgr // actual factory methods // the returned object (if any) has to be acquired once) - configapi::NodeElement* buildReadAccess( OUString const& _rAccessor, const vos::ORef < OOptions >& _xOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ); + configapi::NodeElement* buildReadAccess( OUString const& _rAccessor, const RequestOptions& _aOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ); // the returned object (if any) has to be acquired once) - configapi::NodeElement* buildUpdateAccess(OUString const& _rAccessor, const vos::ORef < OOptions >& _xOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ); + configapi::NodeElement* buildUpdateAccess(OUString const& _rAccessor, const RequestOptions& _aOptions, sal_Int32 nMinLevels) CFG_UNO_THROW_ALL( ); private: - bool initSession(const ConnectionSettings& _rSettings); + bool initSession(const ContextReader& _rSettings); private: - void implInitFromSettings(const ConnectionSettings& _rSettings, bool& rNeedProfile); + void implInitFromSettings(const ContextReader& _rSettings, bool& rNeedProfile); void implInitFromProfile(data::NodeAccess const& aProfile); - virtual void initFromSettings(const ConnectionSettings& _rSettings, bool& rNeedProfile); + virtual void initFromSettings(const ContextReader& _rSettings, bool& rNeedProfile); virtual void initFromProfile(data::NodeAccess const& aProfile); }; } // namespace configmgr diff --git a/configmgr/source/api2/setaccess.cxx b/configmgr/source/api2/setaccess.cxx index e166d0e01f55..5f60f7f557bb 100644 --- a/configmgr/source/api2/setaccess.cxx +++ b/configmgr/source/api2/setaccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: setaccess.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,7 +66,6 @@ namespace configmgr { - using namespace configapi; using uno::Reference; using uno::Sequence; @@ -77,14 +76,14 @@ namespace configmgr //------------------------------------------------------------------------------------------------------------------ OUString SAL_CALL BasicSetAccess::getHierarchicalName( ) throw(RuntimeException) { - return implGetHierarchicalName( getNode() ); + return configapi::implGetHierarchicalName( getNode() ); } //------------------------------------------------------------------------------------------------------------------ OUString SAL_CALL BasicSetAccess::composeHierarchicalName( const OUString& sRelativeName ) throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, RuntimeException) { - return implComposeHierarchicalName( getNode(), sRelativeName ); + return configapi::implComposeHierarchicalName( getNode(), sRelativeName ); } //------------------------------------------------------------------------------------------------------------------ @@ -94,13 +93,13 @@ OUString SAL_CALL BasicSetAccess::composeHierarchicalName( const OUString& sRela uno::Type SAL_CALL BasicSetAccess::getElementType( ) throw(RuntimeException) { - return implGetElementType( getNode() ); + return configapi::implGetElementType( getNode() ); } //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicSetAccess::hasElements( ) throw(RuntimeException) { - return implHasElements( getNode() ); + return configapi::implHasElements( getNode() ); } // XExactName @@ -108,50 +107,70 @@ sal_Bool SAL_CALL BasicSetAccess::hasElements( ) throw(RuntimeException) OUString SAL_CALL BasicSetAccess::getExactName( const OUString& rApproximateName ) throw(RuntimeException) { - return implGetExactName( getNode(), rApproximateName); + return configapi::implGetExactName( getNode(), rApproximateName); } // XProperty //----------------------------------------------------------------------------------- -css::beans::Property SAL_CALL BasicSetAccess::getAsProperty( ) throw(uno::RuntimeException) +css::beans::Property SAL_CALL BasicSetAccess::getAsProperty( ) throw(RuntimeException) { - return implGetAsProperty( getNode() ); + return configapi::implGetAsProperty( getNode() ); } +// XPropertySetInfo +//----------------------------------------------------------------------------------- + +Sequence< css::beans::Property > SAL_CALL BasicSetAccess::getProperties( ) throw (uno::RuntimeException) +{ + return configapi::implGetProperties( getNode() ); +} + +css::beans::Property SAL_CALL BasicSetAccess::getPropertyByName( const OUString& aName ) + throw (css::beans::UnknownPropertyException, RuntimeException) +{ + return configapi::implGetPropertyByName( getNode(), aName ); +} + +sal_Bool SAL_CALL BasicSetAccess::hasPropertyByName( const OUString& Name ) throw (RuntimeException) +{ + return configapi::implHasPropertyByName( getNode(), Name ); +} + + // XNameAccess //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicSetAccess::hasByName( const OUString& sName ) throw(RuntimeException) { - return implHasByName( getNode(), sName); + return configapi::implHasByName( getNode(), sName); } //----------------------------------------------------------------------------------- Any SAL_CALL BasicSetAccess::getByName( const OUString& sName ) throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, RuntimeException) { - return implGetByName( getNode(), sName ); + return configapi::implGetByName( getNode(), sName ); } //----------------------------------------------------------------------------------- Sequence< OUString > SAL_CALL BasicSetAccess::getElementNames( ) throw( RuntimeException) { - return implGetElementNames( getNode() ); + return configapi::implGetElementNames( getNode() ); } // XHierarchicalNameAccess //----------------------------------------------------------------------------------- sal_Bool SAL_CALL BasicSetAccess::hasByHierarchicalName( const OUString& sName ) throw(RuntimeException) { - return implHasByHierarchicalName( getNode(), sName); + return configapi::implHasByHierarchicalName( getNode(), sName); } //----------------------------------------------------------------------------------- Any SAL_CALL BasicSetAccess::getByHierarchicalName( const OUString& sName ) throw(css::container::NoSuchElementException, RuntimeException) { - return implGetByHierarchicalName( getNode(), sName ); + return configapi::implGetByHierarchicalName( getNode(), sName ); } @@ -161,13 +180,13 @@ Any SAL_CALL BasicSetAccess::getByHierarchicalName( const OUString& sName ) void SAL_CALL BasicSetAccess::addContainerListener( const Reference< css::container::XContainerListener >& xListener ) throw(RuntimeException) { - implAddListener( getNode(), xListener ); + configapi::implAddListener( getNode(), xListener ); } void SAL_CALL BasicSetAccess::removeContainerListener( const Reference< css::container::XContainerListener >& xListener ) throw(RuntimeException) { - implRemoveListener( getNode(), xListener ); + configapi::implRemoveListener( getNode(), xListener ); } //----------------------------------------------------------------------------------- @@ -179,7 +198,7 @@ void SAL_CALL BasicSetAccess::removeContainerListener( const Reference< css::con OUString SAL_CALL BasicSetAccess::getElementTemplateName( ) throw(uno::RuntimeException) { - return implGetElementTemplateName( getNode() ); + return configapi::implGetElementTemplateName( getNode() ); } // XStringEscape @@ -187,21 +206,13 @@ OUString SAL_CALL BasicSetAccess::getElementTemplateName( ) OUString SAL_CALL BasicSetAccess::escapeString( const OUString& aString ) throw(css::lang::IllegalArgumentException, RuntimeException) { -#ifndef CFG_ESCAPE_ENABLED return aString; -#else - return implEscapeString( getNode(), aString ); -#endif } OUString SAL_CALL BasicSetAccess::unescapeString( const OUString& aEscapedString ) throw(css::lang::IllegalArgumentException, RuntimeException) { -#ifndef CFG_ESCAPE_ENABLED return aEscapedString; -#else - return implUnescapeString( getNode(), aEscapedString ); -#endif } //----------------------------------------------------------------------------------- diff --git a/configmgr/source/api2/setaccess.hxx b/configmgr/source/api2/setaccess.hxx index 60bdedc1c8e5..5bb47b15d0b3 100644 --- a/configmgr/source/api2/setaccess.hxx +++ b/configmgr/source/api2/setaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: setaccess.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,22 +83,22 @@ #ifndef _COM_SUN_STAR_BEANS_XPROPERTY_HPP_ #include <com/sun/star/beans/XProperty.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif #ifndef _COM_SUN_STAR_UTIL_XSTRINGESCAPE_HPP_ #include <com/sun/star/util/XStringEscape.hpp> #endif -#ifndef _CPPUHELPER_IMPLBASE8_HXX_ -#include <cppuhelper/implbase8.hxx> -#endif - -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" +#ifndef _CPPUHELPER_IMPLBASE9_HXX_ +#include <cppuhelper/implbase9.hxx> #endif namespace configmgr { namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; namespace configapi { class NodeSetInfoAccess; } @@ -107,13 +107,14 @@ namespace configmgr <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p> */ class BasicSetAccess - : public ::cppu::ImplHelper8 + : public ::cppu::ImplHelper9 < css::container::XNameAccess , css::container::XHierarchicalName , css::container::XHierarchicalNameAccess , css::container::XContainer , css::beans::XExactName , css::beans::XProperty + , css::beans::XPropertySetInfo , css::configuration::XTemplateContainer , css::util::XStringEscape > @@ -185,6 +186,19 @@ namespace configmgr getAsProperty( ) throw(uno::RuntimeException); + // XPropertySetInfo + virtual uno::Sequence< css::beans::Property > SAL_CALL + getProperties( ) + throw (uno::RuntimeException); + + virtual css::beans::Property SAL_CALL + getPropertyByName( const OUString& aName ) + throw (css::beans::UnknownPropertyException, uno::RuntimeException); + + virtual sal_Bool SAL_CALL + hasPropertyByName( const OUString& Name ) + throw (uno::RuntimeException); + // XTemplateContainer OUString SAL_CALL getElementTemplateName( ) diff --git a/configmgr/source/api2/setupdate.cxx b/configmgr/source/api2/setupdate.cxx index 275ffff4c683..15e2e29e88f2 100644 --- a/configmgr/source/api2/setupdate.cxx +++ b/configmgr/source/api2/setupdate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: setupdate.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,9 @@ #ifndef CONFIGMGR_API_NODEUPDATE_HXX_ #include "apinodeupdate.hxx" #endif +#ifndef CONFIGMGR_API_APITYPES_HXX_ +#include "apitypes.hxx" +#endif #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ #include <cppuhelper/queryinterface.hxx> @@ -82,7 +85,6 @@ namespace configmgr { ////////////////////////////////////////////////////////////////////////////////// - using namespace configapi; using uno::Reference; using uno::Sequence; @@ -129,9 +131,9 @@ uno::Sequence< uno::Type > SAL_CALL BasicSet::getTypes( ) throw (uno::RuntimeExc { /*static ?*/ cppu::OTypeCollection aTypes( - getReferenceType(static_cast< css::container::XNameContainer *>(this)), - getReferenceType(static_cast< css::container::XNameReplace *>(this)), - getReferenceType(static_cast< css::lang::XSingleServiceFactory *>(this)), + configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)), + configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)), + configapi::getReferenceType(static_cast< css::lang::XSingleServiceFactory *>(this)), BasicSetAccess::getTypes()); return aTypes.getTypes(); @@ -142,8 +144,8 @@ uno::Sequence< uno::Type > SAL_CALL BasicValueSet::getTypes( ) throw (uno::Runti { /*static ?*/ cppu::OTypeCollection aTypes( - getReferenceType(static_cast< css::container::XNameContainer *>(this)), - getReferenceType(static_cast< css::container::XNameReplace *>(this)), + configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)), + configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)), BasicSetAccess::getTypes()); return aTypes.getTypes(); @@ -190,14 +192,14 @@ configapi::NodeValueSetAccess& BasicValueSet::getSetNode() void SAL_CALL BasicSet::replaceByName( const OUString& rName, const uno::Any& rElement ) throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) { - implReplaceByName( getSetNode(), rName, rElement ); + configapi::implReplaceByName( getSetNode(), rName, rElement ); } //.............................................................................. void SAL_CALL BasicValueSet::replaceByName( const OUString& rName, const uno::Any& rElement ) throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) { - implReplaceByName( getSetNode(), rName, rElement ); + configapi::implReplaceByName( getSetNode(), rName, rElement ); } // XNameContainer @@ -205,28 +207,28 @@ void SAL_CALL BasicValueSet::replaceByName( const OUString& rName, const uno::An void SAL_CALL BasicSet::insertByName( const OUString& rName, const uno::Any& rElement) throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException) { - implInsertByName( getSetNode(), rName, rElement ); + configapi::implInsertByName( getSetNode(), rName, rElement ); } //.............................................................................. void SAL_CALL BasicValueSet::insertByName( const OUString& rName, const uno::Any& rElement) throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException) { - implInsertByName( getSetNode(), rName, rElement ); + configapi::implInsertByName( getSetNode(), rName, rElement ); } //---------------------------------------------------------------------------------- void SAL_CALL BasicSet::removeByName( const OUString& rName ) throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) { - implRemoveByName( getSetNode(), rName ); + configapi::implRemoveByName( getSetNode(), rName ); } //.............................................................................. void SAL_CALL BasicValueSet::removeByName( const OUString& rName ) throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) { - implRemoveByName( getSetNode(), rName ); + configapi::implRemoveByName( getSetNode(), rName ); } // XPropertyWithState @@ -234,37 +236,37 @@ void SAL_CALL BasicValueSet::removeByName( const OUString& rName ) css::beans::PropertyState SAL_CALL BasicSet::getStateAsProperty() throw (uno::RuntimeException) { - return implGetStateAsProperty( getSetNode() ); + return configapi::implGetStateAsProperty( getSetNode() ); } //.............................................................................. css::beans::PropertyState SAL_CALL BasicValueSet::getStateAsProperty() throw (uno::RuntimeException) { - return implGetStateAsProperty( getSetNode() ); + return configapi::implGetStateAsProperty( getSetNode() ); } //----------------------------------------------------------------------------------- void SAL_CALL BasicSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) { - implSetToDefaultAsProperty( getSetNode() ); + configapi::implSetToDefaultAsProperty( getSetNode() ); } //.............................................................................. void SAL_CALL BasicValueSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) { - implSetToDefaultAsProperty( getSetNode() ); + configapi::implSetToDefaultAsProperty( getSetNode() ); } //----------------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL BasicSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) { - return implGetDefaultAsProperty( getSetNode() ); + return configapi::implGetDefaultAsProperty( getSetNode() ); } //.............................................................................. uno::Reference< uno::XInterface > SAL_CALL BasicValueSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) { - return implGetDefaultAsProperty( getSetNode() ); + return configapi::implGetDefaultAsProperty( getSetNode() ); } // XSingleServiceFactory (not for ValueSet) @@ -272,14 +274,14 @@ uno::Reference< uno::XInterface > SAL_CALL BasicValueSet::getDefaultAsProperty() uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstance( ) throw(uno::Exception, uno::RuntimeException) { - return implCreateElement( getSetNode() ); + return configapi::implCreateElement( getSetNode() ); } //---------------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments ) throw(uno::Exception, uno::RuntimeException) { - return implCreateElement( getSetNode(), aArguments ); + return configapi::implCreateElement( getSetNode(), aArguments ); } //----------------------------------------------------------------------------------- diff --git a/configmgr/source/api2/setupdate.hxx b/configmgr/source/api2/setupdate.hxx index 0fa183000dec..24958b5bf7d3 100644 --- a/configmgr/source/api2/setupdate.hxx +++ b/configmgr/source/api2/setupdate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: setupdate.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,10 +76,6 @@ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #endif -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - //........................................................................ namespace configmgr { diff --git a/configmgr/source/api2/translatechanges.hxx b/configmgr/source/api2/translatechanges.hxx index d318a9c19564..9979509262fd 100644 --- a/configmgr/source/api2/translatechanges.hxx +++ b/configmgr/source/api2/translatechanges.hxx @@ -2,9 +2,9 @@ * * $RCSfile: translatechanges.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,6 @@ #ifndef CONFIGMGR_API_TRANSLATECHANGES_HXX_ #define CONFIGMGR_API_TRANSLATECHANGES_HXX_ -#include "apitypes.hxx" - #include <com/sun/star/beans/XPropertyChangeListener.hpp> #include <com/sun/star/beans/XVetoableChangeListener.hpp> #include <com/sun/star/beans/XPropertiesChangeListener.hpp> diff --git a/configmgr/source/api2/treeiterators.cxx b/configmgr/source/api2/treeiterators.cxx new file mode 100644 index 000000000000..6929d549f240 --- /dev/null +++ b/configmgr/source/api2/treeiterators.cxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: treeiterators.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2003-03-19 16:18:37 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <stdio.h> + +#include "treeiterators.hxx" + +#include "apitypes.hxx" +#include "configpath.hxx" +#include "attributes.hxx" +#include "valueref.hxx" +#include "propertyinfohelper.hxx" + +// ....................................................................... +namespace configmgr +{ +// ....................................................................... + namespace configapi + { + using configuration::Name; + using node::Attributes; + + // =================================================================== + // = CollectNodeNames + // =================================================================== + // ------------------------------------------------------------------- + CollectPropertyInfo::Result CollectNodeNames::handle(configuration::Tree const& aTree, configuration::NodeRef const& aNode) + { + m_aList.push_back(aTree.getName(aNode).toString()); + return CONTINUE; + } + + // ------------------------------------------------------------------- + CollectPropertyInfo::Result CollectNodeNames::handle(configuration::Tree const& aTree, configuration::ValueRef const& aNode) + { + m_aList.push_back(aTree.getName(aNode).toString()); + return CONTINUE; + } + + // =================================================================== + // = CollectPropertyInfo + // =================================================================== + // ------------------------------------------------------------------- + CollectNodeNames::Result CollectPropertyInfo::handle(configuration::Tree const& aTree, configuration::NodeRef const& aNode) + { + Name aName = aTree.getName(aNode); + Attributes aAttributes = aTree.getAttributes(aNode); + uno::Type aApiType = getUnoInterfaceType(); + + m_aList.push_back( helperMakeProperty(aName,aAttributes,aApiType,aTree.hasNodeDefault(aNode)) ); + return CONTINUE; + } + + // ------------------------------------------------------------------- + CollectNodeNames::Result CollectPropertyInfo::handle(configuration::Tree const& aTree, configuration::ValueRef const& aNode) + { + Name aName = aTree.getName(aNode); + Attributes aAttributes = aTree.getAttributes(aNode); + uno::Type aApiType = aTree.getUnoType(aNode); + + m_aList.push_back( helperMakeProperty(aName,aAttributes,aApiType,aTree.hasNodeDefault(aNode)) ); + return CONTINUE; + } +// ....................................................................... + } // namespace configapi + +// ....................................................................... +} // namespace configmgr +// ....................................................................... + diff --git a/configmgr/source/api2/treeiterators.hxx b/configmgr/source/api2/treeiterators.hxx new file mode 100644 index 000000000000..dacfd61d7800 --- /dev/null +++ b/configmgr/source/api2/treeiterators.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * $RCSfile: treeiterators.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2003-03-19 16:18:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CONFIGMGR_TREEITERATORS_HXX_ +#define CONFIGMGR_TREEITERATORS_HXX_ + +#ifndef CONFIGMGR_CONFIGNODE_HXX_ +#include "noderef.hxx" +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_ +#include <com/sun/star/beans/Property.hpp> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef INCLUDED_VECTOR +#include <vector> +#define INCLUDED_VECTOR +#endif + +// ....................................................................... +namespace configmgr +{ +// ....................................................................... + using rtl::OUString; + + namespace configapi + { + // =================================================================== + // = CollectNodeNames + // =================================================================== + class CollectNodeNames : public configuration::NodeVisitor + { + public: + typedef std::vector<OUString> NameList; + + protected: + NameList m_aList; + + public: + CollectNodeNames() { } + + virtual Result handle(configuration::Tree const& aTree, configuration::NodeRef const& aNode); // NodeVisitor + virtual Result handle(configuration::Tree const& aTree, configuration::ValueRef const& aNode); // NodeVisitor + + NameList const& list() const { return m_aList; } + }; + + // =================================================================== + // = CollectPropertyInfo + // =================================================================== + class CollectPropertyInfo : public configuration::NodeVisitor + { + public: + typedef com::sun::star::beans::Property Property; + typedef std::vector<Property> PropertyList; + + protected: + PropertyList m_aList; + + public: + CollectPropertyInfo() { } + + virtual Result handle(configuration::Tree const& aTree, configuration::NodeRef const& aNode); // NodeVisitor + virtual Result handle(configuration::Tree const& aTree, configuration::ValueRef const& aNode); // NodeVisitor + + PropertyList const& list() const { return m_aList; } + }; + } +// ....................................................................... +} // namespace configmgr +// ....................................................................... + +#endif // _CONFIGMGR_TREEITERATORS_HXX_ + diff --git a/configmgr/source/api2/updateimpl.cxx b/configmgr/source/api2/updateimpl.cxx index e0dfcaf837a0..1ac85f2476bc 100644 --- a/configmgr/source/api2/updateimpl.cxx +++ b/configmgr/source/api2/updateimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: updateimpl.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,9 +93,6 @@ #ifndef CONFIGMGR_API_BROADCASTER_HXX_ #include "broadcaster.hxx" #endif -#ifndef CONFIGMGR_API_ENCODENAME_HXX_ -#include "encodename.hxx" -#endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> diff --git a/configmgr/source/api2/updateimpl.hxx b/configmgr/source/api2/updateimpl.hxx index 6baa5eb27b70..4a72fd928dc9 100644 --- a/configmgr/source/api2/updateimpl.hxx +++ b/configmgr/source/api2/updateimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: updateimpl.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,6 @@ #ifndef CONFIGMGR_API_BASEUPDATEIMPL_HXX_ #define CONFIGMGR_API_BASEUPDATEIMPL_HXX_ -#ifndef CONFIGMGR_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> #endif @@ -80,6 +76,7 @@ namespace configmgr { namespace css = ::com::sun::star; namespace uno = ::com::sun::star::uno; + using rtl::OUString; /* implementations of the interfaces supported by a (parent) node within the configuration tree. diff --git a/configmgr/source/backend/backendaccess.cxx b/configmgr/source/backend/backendaccess.cxx index b4b144577d6e..57f542cb838e 100644 --- a/configmgr/source/backend/backendaccess.cxx +++ b/configmgr/source/backend/backendaccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: backendaccess.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:14:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,9 +92,13 @@ namespace configmgr { namespace backend { BackendAccess::BackendAccess( const uno::Reference<backenduno::XBackend>& xBackend, - const uno::Reference<lang::XMultiServiceFactory>& xFactory) - : mFactory(xFactory), mBackend(xBackend) + const uno::Reference<uno::XComponentContext>& xContext) + : mFactory(xContext->getServiceManager(), uno::UNO_QUERY) + , mBackend(xBackend) { + OSL_ENSURE(mFactory.is(), "BackendAccess: Context has no ServiceManager (or it is missing an interface)"); + if (!mFactory.is()) + throw uno::RuntimeException(OUString::createFromAscii("BackendAccess: Context has no ServiceManager (or it is missing an interface)"), NULL); } //------------------------------------------------------------------------------ @@ -128,9 +132,10 @@ static void merge( MergedComponentData& aData, const uno::Sequence<uno::Reference<backenduno::XLayer> >& aLayers, sal_Int32 aNbLayers, - const rtl::OUString& aLocale) + const rtl::OUString& aLocale, + ITemplateDataProvider *aTemplateProvider=NULL) { - LayerMergeHandler * pMerger = new LayerMergeHandler(aFactory, aData, OUString()); + LayerMergeHandler * pMerger = new LayerMergeHandler(aFactory, aData, aTemplateProvider); uno::Reference<backenduno::XLayerHandler> xLayerMerger(pMerger); RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::backend::BackendAccess", "jb99855", "configmgr: BackendAccess::merge()"); @@ -138,18 +143,19 @@ static void merge( for (sal_Int32 i = 0 ; i < aNbLayers ; ++ i) { - promoteToDefault(aData) ; + pMerger->prepareLayer() ; aLayers [i]->readData(xLayerMerger) ; uno::Reference<backenduno::XCompositeLayer> compositeLayer( aLayers [i], uno::UNO_QUERY) ; - if (compositeLayer.is()) { + if (compositeLayer.is()) + { rtl::OUString bestLocale = findBestLocale( compositeLayer->listSubLayerIds(), aLocale) ; - if (bestLocale.getLength() > 0) { - promoteToDefault(aData) ; + if (pMerger->prepareSublayer(bestLocale) ) + { compositeLayer->readSubLayerData(xLayerMerger, bestLocale) ; } } @@ -158,11 +164,12 @@ static void merge( //------------------------------------------------------------------------------ ComponentResult BackendAccess::getNodeData(const ComponentRequest& aRequest, + ITemplateDataProvider *aTemplateProvider, INodeDataListener *aListener) CFG_UNO_THROW_ALL() { rtl::OUString component = aRequest.getComponentName().toString() ; - SchemaBuilder *schemaBuilder = new backend::SchemaBuilder( component ) ; + SchemaBuilder *schemaBuilder = new backend::SchemaBuilder( component, aTemplateProvider == NULL ? this:aTemplateProvider ) ; uno::Reference<backenduno::XSchemaHandler> schemaHandler = schemaBuilder ; uno::Sequence<uno::Reference<backenduno::XLayer> > layers ; uno::Reference<backenduno::XSchema> schema ; @@ -177,7 +184,7 @@ ComponentResult BackendAccess::getNodeData(const ComponentRequest& aRequest, schema->readSchema(schemaHandler) ; merge(mFactory, schemaBuilder->result(), layers, layers.getLength(), - aNodeRequest.getOptions().getLocale()); + aNodeRequest.getOptions().getLocale(),aTemplateProvider ); ComponentInstance retCode(schemaBuilder->result().extractSchemaTree(), schemaBuilder->result().extractTemplatesTree(), @@ -260,7 +267,7 @@ TemplateResult BackendAccess::getTemplateData(const TemplateRequest& aRequest) templateId.Name = aRequest.getTemplateName().toString() ; templateId.Component = aRequest.getComponentName().toString() ; - aResultData = schemaBuilder->result().extractTemplateNode(templateId); + aResultData = schemaBuilder->result().extractTemplateNode(templateId.Name); } TemplateInstance retCode(aResultData,aRequest.getTemplateName(), aRequest.getComponentName()) ; diff --git a/configmgr/source/backend/backendaccess.hxx b/configmgr/source/backend/backendaccess.hxx index 4f72f7492761..790842ee155e 100644 --- a/configmgr/source/backend/backendaccess.hxx +++ b/configmgr/source/backend/backendaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: backendaccess.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:14:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,9 +82,12 @@ #include <drafts/com/sun/star/configuration/backend/XBackend.hpp> #endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_XBACKEND_HPP_ +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif // _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#endif namespace configmgr { namespace backend { @@ -105,15 +108,16 @@ class BackendAccess : public IMergedDataProvider { service factory. @param xBackend backend used for access to data - @param xFactory factory for instantiation of services + @param xContext uno context for instantiation of services */ - BackendAccess(const uno::Reference<backenduno::XBackend>& xBackend, - const uno::Reference<lang::XMultiServiceFactory>& xFactory) ; + BackendAccess( const uno::Reference<backenduno::XBackend>& xBackend, + const uno::Reference<uno::XComponentContext>& xContext) ; /** Destructor */ ~BackendAccess(void) ; // IMergedDataProvider virtual ComponentResult getNodeData(const ComponentRequest& aRequest, + ITemplateDataProvider* aTemplateProvider, INodeDataListener *aListener = NULL) CFG_UNO_THROW_ALL() ; virtual void removeRequestListener(INodeDataListener *aListener) diff --git a/configmgr/source/backend/backendfactory.cxx b/configmgr/source/backend/backendfactory.cxx index 18bfc7eff32e..75fe1114bd98 100644 --- a/configmgr/source/backend/backendfactory.cxx +++ b/configmgr/source/backend/backendfactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: backendfactory.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:14:45 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,9 @@ #include "backendfactory.hxx" +#ifndef CONFIGMGR_API_FACTORY_HXX_ +#include "confapifactory.hxx" +#endif #ifndef CONFIGMGR_BOOTSTRAPCONTEXT_HXX_ #include "bootstrapcontext.hxx" #endif @@ -70,6 +73,12 @@ #ifndef CONFIGMGR_BACKEND_BACKENDACCESS_HXX_ #include "backendaccess.hxx" #endif +#ifndef CONFIGMGR_SERVICEINFOHELPER_HXX_ +#include "serviceinfohelper.hxx" +#endif +#ifndef CONFIGMGR_WRAPEXCEPTION_HXX +#include "wrapexception.hxx" +#endif #ifndef _COM_SUN_STAR_CONFIGURATION_CANNOTLOADCONFIGURATIONEXCEPTION_HPP_ @@ -91,27 +100,183 @@ namespace configmgr // ------------------------------------------------------------------------- const sal_Char k_DefaultBackendWrapper[] = "com.sun.star.comp.configuration.backend.SingleBackendAdapter"; const sal_Char k_DefaultBackendService[] = "com.sun.star.comp.configuration.backend.LocalSingleBackend"; + +// ------------------------------------------------------------------------- +const sal_Char k_DefaultBackendServiceAndImplName[] = K_DefaultBackendServiceAndImplName ; +const sal_Char k_DefaultSingleBackendServiceAndImplName[] = K_DefaultSingleBackendServiceAndImplName ; + +// ------------------------------------------------------------------------- +const sal_Char k_GenericBackendServiceAndImplName[] = "com.sun.star.configuration.backend.Backend" ; +const sal_Char k_GenericSingleBackendServiceAndImplName[] = "com.sun.star.configuration.backend.SingleBackend" ; + +// ------------------------------------------------------------------------- +static AsciiServiceName const k_BackendServiceNames [] = +{ + k_DefaultBackendServiceAndImplName, + k_GenericBackendServiceAndImplName, + 0 +}; +static AsciiServiceName const k_SingleBackendServiceNames [] = +{ + k_DefaultSingleBackendServiceAndImplName, + k_GenericSingleBackendServiceAndImplName, + 0 +}; +// ------------------------------------------------------------------------- +static const ServiceRegistrationInfo k_DefaultBackendServiceInfo = +{ + k_DefaultBackendServiceAndImplName, + k_BackendServiceNames +}; +static const ServiceRegistrationInfo k_DefaultSingleBackendServiceInfo = +{ + k_DefaultSingleBackendServiceAndImplName, + k_SingleBackendServiceNames +}; +// ------------------------------------------------------------------------- +static const ServiceRegistrationInfo k_GenericBackendServiceInfo = +{ + k_GenericBackendServiceAndImplName, + k_BackendServiceNames + 1 +}; +static const ServiceRegistrationInfo k_GenericSingleBackendServiceInfo = +{ + k_GenericSingleBackendServiceAndImplName, + k_SingleBackendServiceNames + 1 +}; +// ------------------------------------------------------------------------- +static const SingletonRegistrationInfo k_DefaultBackendSingletonInfo = +{ + K_DefaultBackendSingletonName, + k_DefaultBackendServiceAndImplName, + k_DefaultBackendServiceAndImplName, + & k_GenericBackendServiceInfo +}; +static const SingletonRegistrationInfo k_DefaultSingleBackendSingletonInfo = +{ + K_DefaultSingleBackendSingletonName, + k_DefaultSingleBackendServiceAndImplName, + k_DefaultSingleBackendServiceAndImplName, + & k_GenericSingleBackendServiceInfo +}; +// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +const SingletonRegistrationInfo * getDefaultBackendSingletonInfo() +{ + return & k_DefaultBackendSingletonInfo; +} +// ------------------------------------------------------------------------- +const SingletonRegistrationInfo * getDefaultSingleBackendSingletonInfo() +{ + return & k_DefaultSingleBackendSingletonInfo; +} +// ------------------------------------------------------------------------- + +const ServiceRegistrationInfo * getDefaultBackendServiceInfo() +{ + return & k_DefaultBackendServiceInfo; +} +// ------------------------------------------------------------------------- +const ServiceRegistrationInfo * getDefaultSingleBackendServiceInfo() +{ + return & k_DefaultSingleBackendServiceInfo; +} +// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- + +uno::Reference<uno::XInterface> SAL_CALL + getDefaultBackendSingleton( CreationContext const& xContext ) +{ + OSL_ENSURE( xContext.is(), "ERROR: NULL context has no singletons" ); + + UnoContextTunnel aTunnel; + aTunnel.passthru( xContext ); + + uno::Reference<uno::XInterface> xResult; + + if (xContext.is()) + try + { + xContext->getValueByName(SINGLETON(K_DefaultBackendSingletonName)) + >>= xResult; + } + catch (uno::Exception & ) + { + // to do: really use the tunneled failure when that is set properly + if ( aTunnel.recoverFailure(true).hasValue() ) + { + // have a failure, but can't recover it + // -> try to regenerate + instantiateDefaultBackend(xContext); + + OSL_ENSURE(false, "Cannot recreate configuration backend instantiation failure - using generic error"); + } + // cannot recover any failure + throw; + } + + return xResult; +} +// ------------------------------------------------------------------------- + +uno::Reference<uno::XInterface> SAL_CALL + getDefaultSingleBackendSingleton( CreationContext const& xContext ) +{ + OSL_ENSURE( xContext.is(), "ERROR: NULL context has no singletons" ); + + UnoContextTunnel aTunnel; + aTunnel.passthru( xContext ); + + uno::Reference<uno::XInterface> xResult; + + if (xContext.is()) + try + { + xContext->getValueByName(SINGLETON(K_DefaultSingleBackendSingletonName)) + >>= xResult; + } + catch (uno::Exception & ) + { + // to do: really use the tunneled failure when that is set properly + if ( aTunnel.recoverFailure(true).hasValue() ) + { + // have a failure, but can't recover it + // -> try to regenerate + instantiateDefaultSingleBackend(xContext); + + OSL_ENSURE(false, "Cannot recreate configuration backend instantiation failure - using generic error"); + } + // cannot recover any failure + throw; + } + + return xResult; +} +// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- + +typedef BackendFactory::CreationContext CreationContext; +typedef uno::Sequence< uno::Any > UnoInitArgs; // ------------------------------------------------------------------------- -typedef uno::Sequence< uno::Any > UnoInitArgs; static -UnoInitArgs createInitArgs(ConnectionSettings const & _aSettings) +UnoInitArgs createInitArgs(ContextReader const & _aContext) { - uno::Reference< uno::XCurrentContext > xBootstrapArgs = new BootstrapContext(_aSettings.getUnoSettings()); + OSL_ASSERT(_aContext.hasBootstrapContext()); uno::Sequence< uno::Any > aResult( 1 ); - aResult[0] <<= xBootstrapArgs; + aResult[0] <<= _aContext.getBootstrapContext(); return aResult; } // ------------------------------------------------------------------------- -typedef BackendFactory::CreationContext CreationContext; - static inline -uno::Reference< uno::XInterface > createService(CreationContext const & _xCtx, UnoInitArgs const & _aInitArgs, OUString const & _aSvc) +uno::Reference< uno::XInterface > createService(ContextReader const & _aCtx, UnoInitArgs const & _aInitArgs, OUString const & _aSvc) { - OSL_ASSERT(_xCtx.is()); - return _xCtx->createInstanceWithArguments( _aSvc, _aInitArgs); + uno::Reference< lang::XMultiComponentFactory > xFactory = _aCtx.getServiceManager(); + OSL_ENSURE(xFactory.is(),"ERROR: ComponentContext has no service manager\n"); + if (!xFactory.is()) throw uno::RuntimeException( OUString::createFromAscii("ERROR: ComponentContext has no service manager\n"), NULL ); + return xFactory->createInstanceWithArgumentsAndContext( _aSvc, _aInitArgs, _aCtx.getBaseContext()); } // ------------------------------------------------------------------------- @@ -119,8 +284,10 @@ typedef uno::Reference< backenduno::XSingleBackend > UnoSingleBackend; typedef uno::Reference< backenduno::XBackend > UnoBackend; static -UnoBackend wrapSingleBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx, UnoInitArgs const & _aInitArgs, UnoSingleBackend const & _xWrappedBackend) +UnoBackend wrapSingleBackend(ContextReader const & _aSettings, UnoInitArgs const & _aInitArgs, UnoSingleBackend const & _xWrappedBackend) { + OSL_ASSERT(_aSettings.hasUnoBackendWrapper() || _aSettings.hasBootstrapContext()); + OUString aWrapperSvc = _aSettings.hasUnoBackendWrapper() ? _aSettings.getUnoBackendWrapper() : OUString::createFromAscii(k_DefaultBackendWrapper); @@ -133,19 +300,21 @@ UnoBackend wrapSingleBackend(ConnectionSettings const & _aSettings, CreationCont aExtendedArgs.realloc( nBaseArgsCount + 1 ); aExtendedArgs[nBaseArgsCount] <<= _xWrappedBackend; - return UnoBackend::query( createService(_xCtx,aExtendedArgs,aWrapperSvc) ); + return UnoBackend::query( createService(_aSettings,aExtendedArgs,aWrapperSvc) ); } // ------------------------------------------------------------------------- static -UnoBackend createOfflineBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx, UnoInitArgs const & _aInitArgs) +UnoBackend createOfflineBackend(ContextReader const & _aSettings, UnoInitArgs const & _aInitArgs) { + OSL_ASSERT(_aSettings.hasUnoBackendWrapper() || _aSettings.hasBootstrapContext()); + UnoBackend xResult; if ( _aSettings.hasUnoBackendWrapper() ) { OUString const aWrapperSvc = _aSettings.getUnoBackendWrapper(); - xResult = UnoBackend::query( createService(_xCtx,_aInitArgs,aWrapperSvc) ); + xResult = UnoBackend::query( createService(_aSettings,_aInitArgs,aWrapperSvc) ); } return xResult; @@ -153,34 +322,36 @@ UnoBackend createOfflineBackend(ConnectionSettings const & _aSettings, CreationC // ------------------------------------------------------------------------- static -uno::Reference< uno::XInterface > createRealBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx, UnoInitArgs const & _aInitArgs) +uno::Reference< uno::XInterface > createRealBackend(ContextReader const & _aSettings, UnoInitArgs const & _aInitArgs) { + OSL_ASSERT(_aSettings.hasUnoBackendService() || _aSettings.hasBootstrapContext()); + OUString const aBackendServiceName = _aSettings.hasUnoBackendService() ? _aSettings.getUnoBackendService() : OUString::createFromAscii(k_DefaultBackendService); uno::Reference< uno::XInterface > xResult = - createService(_xCtx,_aInitArgs,aBackendServiceName); + createService(_aSettings,_aInitArgs,aBackendServiceName); return xResult; } // ------------------------------------------------------------------------- static -UnoBackend createOnlineBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx, UnoInitArgs const & _aInitArgs) +UnoBackend createOnlineBackend(ContextReader const & _aSettings, UnoInitArgs const & _aInitArgs) { OSL_ENSURE( _aSettings.isUnoBackend(), "ERROR - BackendFactory: For legacy backends use createSessionBackend()"); UnoBackend xResult; - uno::Reference< uno::XInterface > xRealBackend = createRealBackend(_aSettings,_xCtx,_aInitArgs); + uno::Reference< uno::XInterface > xRealBackend = createRealBackend(_aSettings,_aInitArgs); if (_aSettings.hasUnoBackendWrapper()) { // try wrapping a single backend UnoSingleBackend xSingleRealBackend( xRealBackend, uno::UNO_QUERY); if (xSingleRealBackend.is()) - xResult = wrapSingleBackend(_aSettings,_xCtx,_aInitArgs,xSingleRealBackend); + xResult = wrapSingleBackend(_aSettings,_aInitArgs,xSingleRealBackend); // if we don't have one, try using it as unwrapped backend else @@ -195,7 +366,7 @@ UnoBackend createOnlineBackend(ConnectionSettings const & _aSettings, CreationCo // try the default wrapper if we only have a single backend UnoSingleBackend xSingleRealBackend( xRealBackend, uno::UNO_QUERY); if (xSingleRealBackend.is()) - xResult = wrapSingleBackend(_aSettings,_xCtx,_aInitArgs,xSingleRealBackend); + xResult = wrapSingleBackend(_aSettings,_aInitArgs,xSingleRealBackend); else OSL_ENSURE( !xRealBackend.is(), "Configuration Backend implements no known backend interface" ); @@ -206,52 +377,82 @@ UnoBackend createOnlineBackend(ConnectionSettings const & _aSettings, CreationCo } // ------------------------------------------------------------------------- -UnoBackend BackendFactory::createDefaultUnoBackend(CreationContext const & _xCtx) +static UnoBackend createUnoBackend(CreationContext const& _xCtx) { - BootstrapSettings aBootstrapData( getBootstrapContext(_xCtx) ); + ContextReader aSettings(_xCtx); + OSL_ENSURE( aSettings.isUnoBackend(), "ERROR - BackendFactory: Legacy backends are not supported any more"); - return createUnoBackend(aBootstrapData.settings,_xCtx); -} -// ------------------------------------------------------------------------- - -UnoBackend BackendFactory::createUnoBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx) -{ - UnoInitArgs aArguments = createInitArgs(_aSettings); + UnoInitArgs aArguments = createInitArgs(aSettings); - sal_Bool bOffline = _aSettings.hasOfflineSetting() ? _aSettings.getOfflineSetting() : !_aSettings.hasUnoBackendService(); + sal_Bool bOffline = aSettings.hasOfflineSetting() ? aSettings.getOfflineSetting() : !aSettings.hasUnoBackendService(); UnoBackend xResult; if (!bOffline) - xResult = createOnlineBackend(_aSettings,_xCtx,aArguments); + xResult = createOnlineBackend (aSettings,aArguments); if (!xResult.is()) - xResult = createOfflineBackend(_aSettings,_xCtx,aArguments); + xResult = createOfflineBackend(aSettings,aArguments); return xResult; } // ------------------------------------------------------------------------- +// to do: tunnel and raise fully typed exception information (and use it in the get..Singleton wrappers) + #define TUNNEL_ALL_EXCEPTIONS() \ + WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS1( UnoContextTunnel::tunnelFailure, true ) -rtl::Reference<IMergedDataProvider> - BackendFactory::createBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx) +// ------------------------------------------------------------------------- + +uno::Reference<uno::XInterface> SAL_CALL instantiateDefaultBackend( CreationContext const& xTargetContext ) { - OSL_ENSURE( _aSettings.isUnoBackend(), "ERROR - BackendFactory: For legacy backends use createSessionBackend()"); + CreationContext xContext = UnoContextTunnel::recoverContext(xTargetContext); + + try + { + return createUnoBackend(xContext); + } + TUNNEL_ALL_EXCEPTIONS() +} +// ------------------------------------------------------------------------- +uno::Reference<uno::XInterface> SAL_CALL instantiateDefaultSingleBackend( CreationContext const& xTargetContext ) +{ + CreationContext xContext = UnoContextTunnel::recoverContext(xTargetContext); + + ContextReader aSettings( xContext ); + UnoInitArgs aArguments = createInitArgs(aSettings); + + try + { + return createRealBackend(aSettings,aArguments); + } + TUNNEL_ALL_EXCEPTIONS() +} + +// ------------------------------------------------------------------------- + +UnoBackend BackendFactory::getUnoBackend() +{ + return UnoBackend::query( getDefaultBackendSingleton(m_xCtx) ); +} +// ------------------------------------------------------------------------- + +rtl::Reference<IMergedDataProvider> BackendFactory::createBackend() +{ rtl::Reference< IMergedDataProvider > xBackend; - UnoBackend xBackendService = createUnoBackend(_aSettings, _xCtx); + UnoBackend xBackendService = this->getUnoBackend(); if (xBackendService.is()) - xBackend = new BackendAccess(xBackendService, _xCtx); + xBackend = new BackendAccess(xBackendService, m_xCtx); return xBackend; } // ------------------------------------------------------------------------- -BackendFactory & BackendFactory::instance() +BackendFactory BackendFactory::instance(CreationContext const & _xCtx) { - static BackendFactory aStaticFactory; - return aStaticFactory; + return BackendFactory(_xCtx); } //----------------------------------------------------------------------------- diff --git a/configmgr/source/backend/componentdatahelper.cxx b/configmgr/source/backend/componentdatahelper.cxx index 2b04a3942c96..71a884499b02 100644 --- a/configmgr/source/backend/componentdatahelper.cxx +++ b/configmgr/source/backend/componentdatahelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: componentdatahelper.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: ssmith $ $Date: 2002-10-24 12:59:33 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,21 +98,23 @@ DataBuilderContext::DataBuilderContext( ) } // ----------------------------------------------------------------------------- -DataBuilderContext::DataBuilderContext( uno::XInterface * _pContext ) +DataBuilderContext::DataBuilderContext( uno::XInterface * _pContext, ITemplateDataProvider* aTemplateProvider ) : m_aParentStack() , m_aActiveComponent() , m_pContext(_pContext) , m_aExpectedComponentName(OUString()) +, m_aTemplateProvider( aTemplateProvider ) { } // ----------------------------------------------------------------------------- -DataBuilderContext::DataBuilderContext( uno::XInterface * _pContext, const OUString& aExpectedComponentName ) +DataBuilderContext::DataBuilderContext( uno::XInterface * _pContext, const OUString& aExpectedComponentName, ITemplateDataProvider* aTemplateProvider ) : m_aParentStack() , m_aActiveComponent() , m_pContext(_pContext) , m_aExpectedComponentName( aExpectedComponentName ) +, m_aTemplateProvider( aTemplateProvider ) { } @@ -227,21 +229,19 @@ ISubtree & DataBuilderContext::implGetCurrentParent() const } // ----------------------------------------------------------------------------- -void DataBuilderContext::ensureWritable(INode const * pNode) const - CFG_UNO_THROW1( lang::IllegalAccessException ) +bool DataBuilderContext::isWritable(INode const * pNode) const + CFG_NOTHROW( ) { OSL_PRECOND(pNode,"Unexpected NULL node pointer"); - if (!pNode->getAttributes().bWritable) - raiseIllegalAccessException("Illegal Access: Cannot remove or replace. Item is mandatory."); + return pNode->getAttributes().bWritable; } // ----------------------------------------------------------------------------- -void DataBuilderContext::ensureRemovable(ISubtree const * pItem) const - CFG_UNO_THROW1( lang::IllegalAccessException ) +bool DataBuilderContext::isRemovable(ISubtree const * pItem) const + CFG_NOTHROW( ) { OSL_PRECOND(pItem,"Unexpected NULL item pointer"); - if (!pItem->getAttributes().bNullable && !pItem->getAttributes().isReplacedForUser()) - raiseIllegalAccessException("Illegal Access: Cannot remove or replace. Item is mandatory."); + return pItem->getAttributes().bNullable || pItem->getAttributes().isReplacedForUser(); } // ----------------------------------------------------------------------------- @@ -473,8 +473,12 @@ void DataBuilderContext::endActiveComponent() OSL_POSTCOND(!hasActiveComponent(), "Component Builder Context: Could not end Component/Template"); } // ----------------------------------------------------------------------------- +TemplateResult DataBuilderContext::getTemplateData (TemplateRequest const & _aRequest ) +{ + return(m_aTemplateProvider->getTemplateData (_aRequest)); +} +// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- - ComponentDataFactory::ComponentDataFactory() : m_rNodeFactory( getDefaultTreeNodeFactory() ) { diff --git a/configmgr/source/backend/componentdatahelper.hxx b/configmgr/source/backend/componentdatahelper.hxx index 33d876ff906e..b039ce448397 100644 --- a/configmgr/source/backend/componentdatahelper.hxx +++ b/configmgr/source/backend/componentdatahelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: componentdatahelper.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-10-24 12:59:33 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,6 +111,13 @@ #define INCLUDED_MEMORY #endif +#ifndef CONFIGMGR_BACKEND_MERGEDDATAPROVIDER_HXX +#include "mergeddataprovider.hxx" +#endif +#ifndef CONFIGMGR_BACKEND_REQUEST_HXX_ +#include "request.hxx" +#endif + namespace configmgr { // ----------------------------------------------------------------------------- @@ -138,10 +145,11 @@ namespace configmgr OUString m_aActiveComponent; uno::XInterface * m_pContext; OUString m_aExpectedComponentName; + ITemplateDataProvider * m_aTemplateProvider; public: DataBuilderContext(); - explicit DataBuilderContext(uno::XInterface * _pContext ); - explicit DataBuilderContext(uno::XInterface * _pContext, const OUString& aExpectedComponentName ); + explicit DataBuilderContext(uno::XInterface * _pContext , ITemplateDataProvider* aTemplateProvider = NULL); + explicit DataBuilderContext(uno::XInterface * _pContext, const OUString& aExpectedComponentName,ITemplateDataProvider* aTemplateProvider = NULL ); ~DataBuilderContext(); bool isDone() const; @@ -192,10 +200,10 @@ namespace configmgr ISubtree * findNode(OUString const & _aName) CFG_THROW2( MalformedDataException, uno::RuntimeException ); - void ensureWritable(INode const * pNode) const - CFG_UNO_THROW1( lang::IllegalAccessException ); - void ensureRemovable(ISubtree const * pItem) const - CFG_UNO_THROW1( lang::IllegalAccessException ); + bool isWritable(INode const * pNode) const + CFG_NOTHROW( ); + bool isRemovable(ISubtree const * pItem) const + CFG_NOTHROW( ); ISubtree * addNodeToCurrent(std::auto_ptr<ISubtree> _aNode) CFG_THROW3( MalformedDataException, container::ElementExistException, uno::RuntimeException ); @@ -222,6 +230,7 @@ namespace configmgr CFG_UNO_THROW1( beans::PropertyExistException ); void raiseIllegalTypeException (sal_Char const * _pText) const CFG_UNO_THROW1( beans::IllegalTypeException ); + TemplateResult getTemplateData (TemplateRequest const & _aRequest ); private: INode * findChild(OUString const & _aName) CFG_THROW2( MalformedDataException, uno::RuntimeException ); @@ -231,6 +240,7 @@ namespace configmgr ISubtree & implGetCurrentParent() const CFG_THROW2( MalformedDataException, uno::RuntimeException ); + }; // ----------------------------------------------------------------------------- diff --git a/configmgr/source/backend/emptylayerimpl.hxx b/configmgr/source/backend/emptylayerimpl.hxx index 0d2906bc22c1..30d532ebc459 100644 --- a/configmgr/source/backend/emptylayerimpl.hxx +++ b/configmgr/source/backend/emptylayerimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: emptylayerimpl.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-11-28 12:58:17 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -174,4 +174,4 @@ namespace configmgr // ----------------------------------------------------------------------------- } // namespace configmgr -#endif
\ No newline at end of file +#endif diff --git a/configmgr/source/backend/importsvc.cxx b/configmgr/source/backend/importsvc.cxx index ce459fca32c4..2f9df44eef50 100644 --- a/configmgr/source/backend/importsvc.cxx +++ b/configmgr/source/backend/importsvc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: importsvc.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -108,16 +108,16 @@ const ServiceRegistrationInfo* getMergeImportServiceInfo() { return getRegistrationInfo(& aMergeImporterSI); } // ----------------------------------------------------------------------------- -MergeImportService::MergeImportService(CreationArg _xServiceFactory) -: ImportService(_xServiceFactory, &aMergeImporterSI) +MergeImportService::MergeImportService(CreationArg _xContext) +: ImportService(_xContext, &aMergeImporterSI) { } // ----------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL instantiateMergeImporter -( CreationContext const& rServiceManager ) +( CreationContext const& xContext ) { - return * new MergeImportService( rServiceManager ); + return * new MergeImportService( xContext ); } // ----------------------------------------------------------------------------- @@ -154,16 +154,16 @@ const ServiceRegistrationInfo* getCopyImportServiceInfo() { return getRegistrationInfo(& aCopyImporterSI); } // ----------------------------------------------------------------------------- -CopyImportService::CopyImportService(CreationArg _xServiceFactory) -: ImportService(_xServiceFactory, &aCopyImporterSI) +CopyImportService::CopyImportService(CreationArg _xContext) +: ImportService(_xContext, &aCopyImporterSI) { } // ----------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL instantiateCopyImporter -( CreationContext const& rServiceManager ) +( CreationContext const& xContext ) { - return * new CopyImportService( rServiceManager ); + return * new CopyImportService( xContext ); } // ----------------------------------------------------------------------------- @@ -195,13 +195,13 @@ sal_Bool CopyImportService::setImplementationProperty(OUString const & aName, un // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- -ImportService::ImportService(CreationArg _xServiceFactory, ServiceInfoHelper const & aSvcInfo ) +ImportService::ImportService(CreationArg _xContext, ServiceInfoHelper const & aSvcInfo ) : m_aMutex() -, m_xServiceFactory(_xServiceFactory) +, m_xContext(_xContext) , m_xDestinationBackend() , m_aServiceInfo(aSvcInfo) { - if (!m_xServiceFactory.is()) + if (!m_xContext.is()) { OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration Importer: Unexpected NULL context")); throw lang::NullPointerException(sMessage,NULL); @@ -215,7 +215,7 @@ ImportService::~ImportService() ImportService::Backend ImportService::createDefaultBackend() const { - return BackendFactory::createDefaultUnoBackend( m_xServiceFactory ); + return BackendFactory::instance( m_xContext ).getUnoBackend(); } // ----------------------------------------------------------------------------- diff --git a/configmgr/source/backend/importsvc.hxx b/configmgr/source/backend/importsvc.hxx index f92589a1ceeb..380ab530bbd7 100644 --- a/configmgr/source/backend/importsvc.hxx +++ b/configmgr/source/backend/importsvc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: importsvc.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-11-28 09:05:12 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,9 @@ #include <osl/mutex.hxx> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -104,10 +107,10 @@ namespace configmgr > { public: - typedef uno::Reference< lang::XMultiServiceFactory > const & CreationArg; + typedef uno::Reference< uno::XComponentContext > const & CreationArg; explicit - ImportService(CreationArg _xServiceFactory, ServiceInfoHelper const & aSvcInfo); + ImportService(CreationArg _xContext, ServiceInfoHelper const & aSvcInfo); ~ImportService(); // XInitialization @@ -147,14 +150,14 @@ namespace configmgr throw ( lang::WrappedTargetException, lang::IllegalArgumentException, lang::NullPointerException, uno::RuntimeException); protected: + typedef uno::Reference< uno::XComponentContext > Context; typedef uno::Reference< lang::XMultiServiceFactory > ServiceFactory; typedef uno::Reference< backenduno::XBackend > Backend; typedef uno::Reference< backenduno::XLayerHandler > InputHandler; Backend createDefaultBackend() const; - ServiceFactory getServiceFactory() const - { return m_xServiceFactory; } + //ServiceFactory getServiceFactory() const virtual sal_Bool setImplementationProperty( OUString const & aName, uno::Any const & aValue); private: @@ -163,7 +166,7 @@ namespace configmgr private: osl::Mutex m_aMutex; - ServiceFactory m_xServiceFactory; + Context m_xContext; Backend m_xDestinationBackend; ServiceInfoHelper m_aServiceInfo; @@ -175,7 +178,7 @@ namespace configmgr class MergeImportService : public ImportService { public: - explicit MergeImportService(CreationArg _xServiceFactory); + explicit MergeImportService(CreationArg _xContext); private: InputHandler createImportHandler(Backend const & xBackend, OUString const & aEntity); }; @@ -184,7 +187,7 @@ namespace configmgr class CopyImportService : public ImportService { public: - explicit CopyImportService(CreationArg _xServiceFactory); + explicit CopyImportService(CreationArg _xContext); private: InputHandler createImportHandler(Backend const & xBackend, OUString const & aEntity); sal_Bool setImplementationProperty( OUString const & aName, uno::Any const & aValue); diff --git a/configmgr/source/backend/layermerge.cxx b/configmgr/source/backend/layermerge.cxx index dc38b97493a2..25a1997a00b5 100644 --- a/configmgr/source/backend/layermerge.cxx +++ b/configmgr/source/backend/layermerge.cxx @@ -2,9 +2,9 @@ * * $RCSfile: layermerge.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2002-08-20 10:21:31 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,7 +112,7 @@ namespace configmgr MergedComponentData aData; uno::Reference< backenduno::XLayerHandler > - test(new LayerMergeHandler(_xServiceFactory, aData, localehelper::getDefaultLocale())); + test(new LayerMergeHandler(_xServiceFactory, aData)); } // ----------------------------------------------------------------------------- @@ -132,15 +132,15 @@ struct LayerMergeHandler::Converter bool m_bConvertData; }; // ----------------------------------------------------------------------------- -LayerMergeHandler::LayerMergeHandler(ServiceFactory const & _xServiceFactory, MergedComponentData & _rData, OUString const & _aLocale ) +LayerMergeHandler::LayerMergeHandler(ServiceFactory const & _xServiceFactory, MergedComponentData & _rData, ITemplateDataProvider* aTemplateProvider ) : m_rData(_rData) -, m_aContext(static_cast<backenduno::XLayerHandler*>(this)) +, m_aContext(static_cast<backenduno::XLayerHandler*>(this),aTemplateProvider ) , m_aFactory() -, m_aLocale(_aLocale) +, m_aLocale() , m_pProperty(NULL) , m_pConverter( new Converter(_xServiceFactory) ) , m_nSkipping(0) -, m_bSublayer(_aLocale.getLength() != 0) +, m_bSublayer(false) { OSL_ENSURE( m_rData.hasSchema(), "Creating layer merger without default data" ); } @@ -152,9 +152,30 @@ LayerMergeHandler::~LayerMergeHandler( ) } // ----------------------------------------------------------------------------- +void LayerMergeHandler::prepareLayer() +{ + OSL_ENSURE(isDone(), "LayerMergeHandler: Warning: Previous layer or schema not terminated properly"); + m_aLocale = OUString(); + m_bSublayer = false; + + promoteToDefault(m_rData); +} +// ----------------------------------------------------------------------------- + +bool LayerMergeHandler::prepareSublayer(OUString const & aLocale) +{ + OSL_ENSURE(isDone(), "LayerMergeHandler: Warning: Previous layer not terminated properly"); + + m_aLocale = aLocale; + m_bSublayer = (aLocale.getLength() != 0); + + return m_bSublayer; +} +// ----------------------------------------------------------------------------- + MergedComponentData & LayerMergeHandler::result() { - OSL_ENSURE(isDone(), "LayerMergeHandler: Warning: Schema not terminated properly"); + OSL_ENSURE(isDone(), "LayerMergeHandler: Warning: Layer not terminated properly"); return m_rData; } @@ -162,7 +183,7 @@ MergedComponentData & LayerMergeHandler::result() MergedComponentData const & LayerMergeHandler::result() const { - OSL_ENSURE(isDone(), "LayerMergeHandler: Warning: Schema not terminated properly"); + OSL_ENSURE(isDone(), "LayerMergeHandler: Warning: Layer not terminated properly"); return m_rData; } @@ -477,12 +498,14 @@ void LayerMergeHandler::applyAttributes(INode * pNode, sal_Int16 aNodeAttributes } // ----------------------------------------------------------------------------- -void LayerMergeHandler::startOverride(INode * pNode) /* ensure writable, mark merged */ - CFG_UNO_THROW1( lang::IllegalAccessException ) +bool LayerMergeHandler::startOverride(INode * pNode) /* ensure writable, mark merged */ + CFG_NOTHROW( ) { - m_aContext.ensureWritable(pNode); + if (!m_aContext.isWritable(pNode)) return false; if (pNode->isDefault()) pNode->modifyState( node::isMerged ); + + return true; } // ----------------------------------------------------------------------------- @@ -492,8 +515,9 @@ void LayerMergeHandler::ensureUnchanged(INode const * pNode) const // to do: change state handling to detect this within sets OSL_PRECOND(pNode,"INTERNAL ERROR: Unexpected NULL node pointer"); - if (pNode->getAttributes().state() == node::isMerged) - m_aContext.raiseMalformedDataException("Layer merging: Duplicate node or property in this layer"); + if (!this->isInSublayer()) + if (pNode->getAttributes().state() == node::isMerged) + m_aContext.raiseMalformedDataException("Layer merging: Duplicate node or property in this layer"); } // ----------------------------------------------------------------------------- @@ -529,6 +553,8 @@ void SAL_CALL LayerMergeHandler::endLayer( ) m_aContext.endActiveComponent(); + m_bSublayer = false; + OSL_POSTCOND( !m_aContext.hasActiveComponent(), "Layer merging: could not clear active component"); OSL_POSTCOND( m_aContext.isDone(), "Layer merging: could not finish processing"); } @@ -550,14 +576,17 @@ void LayerMergeHandler::overrideLayerRoot( const OUString& aName, sal_Int16 aAtt ensureUnchanged(pSchema); - startOverride(pSchema); - - applyAttributes(pSchema,aAttributes); + if (startOverride(pSchema)) + { + applyAttributes(pSchema,aAttributes); - m_aContext.pushNode(pSchema); + m_aContext.pushNode(pSchema); - OSL_POSTCOND( m_aContext.hasActiveComponent(), "Layer merging: could not set active component"); - OSL_POSTCOND( !m_aContext.isDone(), "Layer merging: could not start component"); + OSL_POSTCOND( m_aContext.hasActiveComponent(), "Layer merging: could not set active component"); + OSL_POSTCOND( !m_aContext.isDone(), "Layer merging: could not start component"); + } + else + this->skipNode(); } else { @@ -582,11 +611,14 @@ void SAL_CALL LayerMergeHandler::overrideNode( const OUString& aName, sal_Int16 { ensureUnchanged(pNode); - startOverride(pNode); - - applyAttributes(pNode, aAttributes); + if (startOverride(pNode)) + { + applyAttributes(pNode, aAttributes); - m_aContext.pushNode(pNode); + m_aContext.pushNode(pNode); + } + else + this->skipNode(); } else // ignore non-matched data { @@ -598,20 +630,38 @@ void SAL_CALL LayerMergeHandler::overrideNode( const OUString& aName, sal_Int16 // ----------------------------------------------------------------------------- void LayerMergeHandler::implAddOrReplaceNode( const OUString& aName, const TemplateIdentifier& aTemplate, sal_Int16 aAttributes ) - CFG_THROW5 (MalformedDataException, container::NoSuchElementException, lang::IllegalAccessException, lang::IllegalArgumentException, uno::RuntimeException) + CFG_THROW4 (MalformedDataException, container::NoSuchElementException, lang::IllegalArgumentException, uno::RuntimeException) { - std::auto_ptr<INode> apNewInstance = m_rData.instantiateTemplate(aName, aTemplate); + ISubtree * pReplacedNode = m_aContext.findNode(aName); + if (pReplacedNode) + { + this->ensureUnchanged(pReplacedNode); + + if (!m_aContext.isRemovable(pReplacedNode)) + { + this->skipNode(); + return; + } + } + + std::auto_ptr<INode> apNewInstance; + if (aTemplate.Component == m_aContext.getActiveComponent()) + { + apNewInstance = m_rData.instantiateTemplate(aName, aTemplate.Name); + } + else + { + TemplateRequest aTemplateRequest(configuration::makeName(aTemplate.Name, configuration::Name::NoValidate()), + configuration::makeName(aTemplate.Component, configuration::Name::NoValidate()) ); + apNewInstance = m_aContext.getTemplateData( aTemplateRequest ).extractDataAndClear(); + } + if (NULL == apNewInstance.get()) m_aContext.raiseNoSuchElementException("Layer merging: Cannot instantiate template.", aTemplate.Name); applyAttributes(apNewInstance.get(), aAttributes); - if (ISubtree * pReplaced = m_aContext.findNode(aName)) - { - this->ensureUnchanged(pReplaced); - m_aContext.ensureRemovable(pReplaced); - m_aContext.getCurrentParent().removeChild( aName ); - } + if (pReplacedNode) m_aContext.getCurrentParent().removeChild( aName ); INode * pAddedInstance = m_aContext.getCurrentParent().addChild( apNewInstance ); @@ -670,7 +720,8 @@ void SAL_CALL LayerMergeHandler::dropNode( const OUString& aName ) if (ISubtree * pDropped = m_aContext.findNode(aName)) { this->ensureUnchanged(pDropped); - m_aContext.ensureRemovable(pDropped); + if (!m_aContext.isRemovable(pDropped)) + return; } else { @@ -692,13 +743,16 @@ void SAL_CALL LayerMergeHandler::overrideProperty( const OUString& aName, sal_In { ensureUnchanged(pProp); - startOverride(pProp); - - applyAttributes(pProp,aAttributes); + if (startOverride(pProp)) + { + applyAttributes(pProp,aAttributes); - m_pProperty = pProp; + m_pProperty = pProp; - checkPropertyType(aType); + checkPropertyType(aType); + } + else + this->skipNode(); } else // ignore non-matched data { diff --git a/configmgr/source/backend/layermerge.hxx b/configmgr/source/backend/layermerge.hxx index 70fb0a7d77b1..084e75dc2b8f 100644 --- a/configmgr/source/backend/layermerge.hxx +++ b/configmgr/source/backend/layermerge.hxx @@ -2,9 +2,9 @@ * * $RCSfile: layermerge.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-07-11 16:58:27 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -105,11 +105,16 @@ namespace configmgr typedef uno::Reference< lang::XMultiServiceFactory > ServiceFactory; explicit - LayerMergeHandler(ServiceFactory const & _xServiceFactory , MergedComponentData & _rData, OUString const & _aLocale); + LayerMergeHandler(ServiceFactory const & _xServiceFactory , MergedComponentData & _rData, ITemplateDataProvider* aTemplateProvider = NULL); virtual ~LayerMergeHandler(); + // prepare merging + void prepareLayer(); + bool prepareSublayer(OUString const & aLocale); + // checking the result bool isDone() const { return m_aContext.isDone(); } + bool isInSublayer() const { return m_bSublayer; } MergedComponentData & result(); MergedComponentData const & result() const; @@ -189,11 +194,11 @@ namespace configmgr void overrideLayerRoot( const OUString& aName, sal_Int16 aAttributes ) CFG_THROW4 (MalformedDataException, lang::IllegalAccessException, lang::IllegalArgumentException, uno::RuntimeException); - void startOverride(INode * pNode) /* ensure writable, mark merged */ - CFG_THROW3( MalformedDataException, lang::IllegalAccessException, uno::RuntimeException ); + bool startOverride(INode * pNode) /* check if writable, mark merged */ + CFG_NOTHROW( ); void implAddOrReplaceNode(const OUString& aName, const TemplateIdentifier& aTemplate, sal_Int16 aAttributes) - CFG_THROW5 (MalformedDataException, container::NoSuchElementException, lang::IllegalAccessException, lang::IllegalArgumentException, uno::RuntimeException); + CFG_THROW4 (MalformedDataException, container::NoSuchElementException, lang::IllegalArgumentException, uno::RuntimeException); void ensureUnchanged(INode const * pNode) const CFG_THROW2( MalformedDataException, uno::RuntimeException ); diff --git a/configmgr/source/backend/layerupdatehandler.cxx b/configmgr/source/backend/layerupdatehandler.cxx index bb87a0470fd1..27a012ce9dcf 100644 --- a/configmgr/source/backend/layerupdatehandler.cxx +++ b/configmgr/source/backend/layerupdatehandler.cxx @@ -2,9 +2,9 @@ * * $RCSfile: layerupdatehandler.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-11-28 12:49:12 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,15 +87,15 @@ namespace configmgr // ----------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL instantiateUpdateMerger -( CreationContext const& rServiceManager ) +( CreationContext const& xContext ) { - return * new LayerUpdateHandler( rServiceManager ); + return * new LayerUpdateHandler( xContext ); } // ----------------------------------------------------------------------------- -LayerUpdateHandler::LayerUpdateHandler(CreationArg _xServiceFactory) -: UpdateService(_xServiceFactory) +LayerUpdateHandler::LayerUpdateHandler(CreationArg _xContext) +: UpdateService(_xContext) , m_aBuilder() { } diff --git a/configmgr/source/backend/layerupdatehandler.hxx b/configmgr/source/backend/layerupdatehandler.hxx index 011f2af36422..3a9bb818a540 100644 --- a/configmgr/source/backend/layerupdatehandler.hxx +++ b/configmgr/source/backend/layerupdatehandler.hxx @@ -2,9 +2,9 @@ * * $RCSfile: layerupdatehandler.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-06-07 12:01:22 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,7 +98,7 @@ namespace configmgr { public: explicit - LayerUpdateHandler(CreationArg _xServiceFactory); + LayerUpdateHandler(CreationArg _xContext); ~LayerUpdateHandler(); diff --git a/configmgr/source/backend/makefile.mk b/configmgr/source/backend/makefile.mk index c34c7255da8e..5d63e8ed0a4f 100644 --- a/configmgr/source/backend/makefile.mk +++ b/configmgr/source/backend/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.10 $ +# $Revision: 1.11 $ # -# last change: $Author: ssmith $ $Date: 2002-12-13 10:14:47 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:18:48 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses diff --git a/configmgr/source/backend/mergedcomponentdata.cxx b/configmgr/source/backend/mergedcomponentdata.cxx index 5f40ac1ac4fd..6b43d9c31f76 100644 --- a/configmgr/source/backend/mergedcomponentdata.cxx +++ b/configmgr/source/backend/mergedcomponentdata.cxx @@ -2,9 +2,9 @@ * * $RCSfile: mergedcomponentdata.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-05-27 10:34:15 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,10 +112,10 @@ OUString MergedComponentData::getTemplateAccessor (TemplateIdentifier const & _a } // ----------------------------------------------------------------------------- -bool MergedComponentData::hasTemplate(TemplateIdentifier const & _aTemplateName) const +bool MergedComponentData::hasTemplate(OUString const & _aTemplateName) const { return m_pTemplatesTree.get() != NULL && - m_pTemplatesTree->getChild( getTemplateAccessor(_aTemplateName) ) != NULL; + m_pTemplatesTree->getChild( _aTemplateName ) != NULL; } // ----------------------------------------------------------------------------- @@ -131,12 +131,12 @@ std::auto_ptr<ISubtree> MergedComponentData::extractTemplatesTree() } // ----------------------------------------------------------------------------- -std::auto_ptr<INode> MergedComponentData::extractTemplateNode(TemplateIdentifier const & _aTemplateName) +std::auto_ptr<INode> MergedComponentData::extractTemplateNode(OUString const & _aTemplateName) { if (m_pTemplatesTree.get() == NULL) return std::auto_ptr<INode>(); - return m_pTemplatesTree->removeChild(getTemplateAccessor(_aTemplateName)); + return m_pTemplatesTree->removeChild(_aTemplateName); } // ----------------------------------------------------------------------------- @@ -146,9 +146,9 @@ ISubtree const * MergedComponentData::getSchemaTree() const } // ----------------------------------------------------------------------------- -ISubtree const * MergedComponentData::findTemplate(TemplateIdentifier const & _aTemplateName) const +ISubtree const * MergedComponentData::findTemplate(OUString const & _aTemplateName) const { - INode const * pTemplateNode = m_pTemplatesTree->getChild(getTemplateAccessor(_aTemplateName)); + INode const * pTemplateNode = m_pTemplatesTree->getChild(_aTemplateName); ISubtree const * pTemplateTree = pTemplateNode ? pTemplateNode->asISubtree() : NULL; @@ -158,9 +158,9 @@ ISubtree const * MergedComponentData::findTemplate(TemplateIdentifier const & _a } // ----------------------------------------------------------------------------- -std::auto_ptr<INode> MergedComponentData::instantiateTemplate(OUString const & _aName, TemplateIdentifier const & _aTemplateName) const +std::auto_ptr<INode> MergedComponentData::instantiateTemplate(OUString const & _aName, OUString const & _aTemplateName) const { - if (INode const * pTemplateNode = m_pTemplatesTree->getChild(getTemplateAccessor(_aTemplateName))) + if (INode const * pTemplateNode = m_pTemplatesTree->getChild(_aTemplateName)) { std::auto_ptr<INode> aResult = pTemplateNode->clone(); aResult->setName(_aName); diff --git a/configmgr/source/backend/mergedcomponentdata.hxx b/configmgr/source/backend/mergedcomponentdata.hxx index e9294a173f1b..13f128000e70 100644 --- a/configmgr/source/backend/mergedcomponentdata.hxx +++ b/configmgr/source/backend/mergedcomponentdata.hxx @@ -2,9 +2,9 @@ * * $RCSfile: mergedcomponentdata.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-05-16 10:56:07 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,17 +99,17 @@ namespace configmgr bool hasSchema() const; bool hasTemplates() const; - bool hasTemplate(TemplateIdentifier const & _aTemplateName) const; + bool hasTemplate(OUString const & _aTemplateName) const; OUString getTemplateAccessor (TemplateIdentifier const & _aTemplateName) const; ISubtree const * getSchemaTree() const; - ISubtree const * findTemplate(TemplateIdentifier const & _aTemplateName) const; + ISubtree const * findTemplate(OUString const & _aTemplateName) const; ISubtree * getSchemaTree() { return m_pSchemaTree.get(); } ISubtree * getTemplatesTree() { return m_pTemplatesTree.get(); } - std::auto_ptr<INode> instantiateTemplate(OUString const & _aName, TemplateIdentifier const & _aTemplateName) const; + std::auto_ptr<INode> instantiateTemplate(OUString const & _aName, OUString const & _aTemplateName) const; void clear(); @@ -118,7 +118,7 @@ namespace configmgr std::auto_ptr<ISubtree> extractSchemaTree(); std::auto_ptr<ISubtree> extractTemplatesTree(); - std::auto_ptr<INode> extractTemplateNode(TemplateIdentifier const & _aTemplateName); + std::auto_ptr<INode> extractTemplateNode(OUString const & _aTemplateName); private: std::auto_ptr<ISubtree> m_pSchemaTree; std::auto_ptr<ISubtree> m_pTemplatesTree; diff --git a/configmgr/source/backend/schemabuilder.cxx b/configmgr/source/backend/schemabuilder.cxx index 859e1e7d5c17..24ad017ee2c6 100644 --- a/configmgr/source/backend/schemabuilder.cxx +++ b/configmgr/source/backend/schemabuilder.cxx @@ -2,9 +2,9 @@ * * $RCSfile: schemabuilder.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: ssmith $ $Date: 2002-10-24 12:59:34 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,10 +100,11 @@ namespace configmgr } // ----------------------------------------------------------------------------- -SchemaBuilder::SchemaBuilder( const OUString& aExpectedComponentName ) +SchemaBuilder::SchemaBuilder( const OUString& aExpectedComponentName, ITemplateDataProvider* aTemplateProvider ) : m_aData() -, m_aContext(static_cast<backenduno::XSchemaHandler*>(this), aExpectedComponentName ) +, m_aContext(static_cast<backenduno::XSchemaHandler*>(this), aExpectedComponentName, aTemplateProvider ) , m_aFactory() +, m_aTemplateProvider(aTemplateProvider) { } @@ -160,7 +161,7 @@ void SAL_CALL SchemaBuilder::endSchema( ) void SAL_CALL SchemaBuilder::importComponent( const OUString& aName ) throw (MalformedDataException, container::NoSuchElementException, lang::IllegalArgumentException, uno::RuntimeException) { - OSL_TRACE("WARNING: Configuration schema parser: Cross-component references are not yet supported\n"); + //OSL_TRACE("WARNING: Configuration schema parser: Cross-component references are not yet supported\n"); // OSL_ENSURE(false, "Cross-component references are not yet supported"); } // ----------------------------------------------------------------------------- @@ -211,7 +212,7 @@ void SAL_CALL SchemaBuilder::startGroupTemplate( const TemplateIdentifier& aTemp m_aContext.startActiveComponent(aTemplate.Component); - if (m_aData.hasTemplate(aTemplate)) + if (m_aData.hasTemplate(aTemplate.Name)) m_aContext.raiseElementExistException("Schema builder: Template already exists",aTemplate.Name); OUString aName = m_aData.getTemplateAccessor(aTemplate); @@ -234,7 +235,7 @@ void SAL_CALL SchemaBuilder::startSetTemplate( const TemplateIdentifier& aTempla m_aContext.startActiveComponent(aTemplate.Component); - if (m_aData.hasTemplate(aTemplate)) + if (m_aData.hasTemplate(aTemplate.Name)) m_aContext.raiseElementExistException("Schema builder: Template already exists",aTemplate.Name); OUString aName = m_aData.getTemplateAccessor(aTemplate); @@ -422,9 +423,9 @@ namespace InstanceList m_aReplacementList; TemplateStack m_aTemplateStack; public: - SubstitutionHelper(MergedComponentData & _rData, uno::XInterface * _pContext) + SubstitutionHelper(MergedComponentData & _rData, uno::XInterface * _pContext, ITemplateDataProvider* aTemplateProvider=NULL ) : m_rData(_rData) - , m_aContext(_pContext) + , m_aContext(_pContext,aTemplateProvider) , m_aReplacementList() , m_aTemplateStack() {} @@ -445,7 +446,7 @@ namespace void SchemaBuilder::substituteInstances() { - SubstitutionHelper helper(m_aData, static_cast<backenduno::XSchemaHandler*>(this)); + SubstitutionHelper helper(m_aData, static_cast<backenduno::XSchemaHandler*>(this),m_aTemplateProvider); helper.substituteInData(); } @@ -507,6 +508,7 @@ namespace void SubstitutionHelper::substitute(OUString const & _aName) { + ISubtree & rParent = m_aContext.getCurrentParent(); std::auto_ptr<INode> pReplacedNode = rParent.removeChild(_aName); @@ -516,33 +518,46 @@ namespace OSL_ASSERT( pReplacedInstance != NULL ); TemplateIdentifier aTemplateName = m_aFactory.getInstanceType(*pReplacedInstance); - - if (ISubtree const * pTemplate = m_rData.findTemplate(aTemplateName)) + if (aTemplateName.Component == m_aContext.getActiveComponent()) { - TemplateStack::iterator beg = m_aTemplateStack.begin(), end = m_aTemplateStack.end(); - if (std::find(beg,end,pTemplate) != end) - m_aContext.raiseMalformedDataException("SchemaBuilder: Could not expand instances: Template is recursive"); + if (ISubtree const * pTemplate = m_rData.findTemplate(aTemplateName.Name)) + { + TemplateStack::iterator beg = m_aTemplateStack.begin(), end = m_aTemplateStack.end(); + if (std::find(beg,end,pTemplate) != end) + m_aContext.raiseMalformedDataException("SchemaBuilder: Could not expand instances: Template is recursive"); - m_aTemplateStack.push_back(pTemplate); + m_aTemplateStack.push_back(pTemplate); - std::auto_ptr< INode > pTemplateInstance = pTemplate->clone(); + std::auto_ptr< INode > pTemplateInstance = pTemplate->clone(); - pTemplateInstance->setName(_aName); - // TODO: adjust state/attributes here (?) + pTemplateInstance->setName(_aName); + // TODO: adjust state/attributes here (?) - ISubtree * pAddedTree = rParent.addChild(pTemplateInstance)->asISubtree(); + ISubtree * pAddedTree = rParent.addChild(pTemplateInstance)->asISubtree(); - OSL_ENSURE(pAddedTree, "Could not obtain added template instance"); + OSL_ENSURE(pAddedTree, "Could not obtain added template instance"); - this->substituteInNode(*pAddedTree); + this->substituteInNode(*pAddedTree); - m_aTemplateStack.pop_back(); + m_aTemplateStack.pop_back(); + } + else + { + m_aContext.raiseMalformedDataException("SchemaBuilder: Could not expand instances: Template not found"); + } } + //Import Template from different component else { - m_aContext.raiseMalformedDataException("SchemaBuilder: Could not expand instances: Template not found"); + TemplateRequest aTemplateRequest(configuration::makeName(aTemplateName.Name, configuration::Name::NoValidate()), + configuration::makeName(aTemplateName.Component, configuration::Name::NoValidate()) ); + TemplateResult aResult = m_aContext.getTemplateData( aTemplateRequest ); + + std::auto_ptr<INode> pTemplateInstance = aResult.extractDataAndClear(); + pTemplateInstance->setName(_aName); + ISubtree * pAddedTree = rParent.addChild(pTemplateInstance)->asISubtree(); + OSL_ENSURE(pAddedTree, "Could not obtain added template instance"); } - } // ----------------------------------------------------------------------------- diff --git a/configmgr/source/backend/schemabuilder.hxx b/configmgr/source/backend/schemabuilder.hxx index bf2033cc9199..2b3406aafd46 100644 --- a/configmgr/source/backend/schemabuilder.hxx +++ b/configmgr/source/backend/schemabuilder.hxx @@ -2,9 +2,9 @@ * * $RCSfile: schemabuilder.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: ssmith $ $Date: 2002-10-24 12:59:35 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,9 @@ #ifndef CONFIGMGR_BACKEND_COMPONENTDATAHELPER_HXX #include "componentdatahelper.hxx" #endif +#ifndef CONFIGMGR_BACKEND_MERGEDDATAPROVIDER_HXX +#include "mergeddataprovider.hxx" +#endif #include <drafts/com/sun/star/configuration/backend/XSchemaHandler.hpp> @@ -98,7 +101,7 @@ namespace configmgr : public SchemaBuilder_Base { public: - SchemaBuilder( const OUString& aExpectedComponentName ); + SchemaBuilder( const OUString& aExpectedComponentName, ITemplateDataProvider* aTemplateProvider = NULL ); virtual ~SchemaBuilder(); // checking the result @@ -181,6 +184,7 @@ namespace configmgr MergedComponentData m_aData; DataBuilderContext m_aContext; ComponentDataFactory m_aFactory; + ITemplateDataProvider * m_aTemplateProvider; }; // ----------------------------------------------------------------------------- diff --git a/configmgr/source/backend/singlebackendadapter.cxx b/configmgr/source/backend/singlebackendadapter.cxx index ffc61ba07783..3ed89f92f964 100644 --- a/configmgr/source/backend/singlebackendadapter.cxx +++ b/configmgr/source/backend/singlebackendadapter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: singlebackendadapter.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,8 +80,8 @@ namespace configmgr { namespace backend { //============================================================================== SingleBackendAdapter::SingleBackendAdapter( - const uno::Reference<lang::XMultiServiceFactory>& aFactory) -: BackendBase(mMutex), mFactory(aFactory) { + const uno::Reference<uno::XComponentContext>& xContext) + : BackendBase(mMutex), mFactory(xContext->getServiceManager(),uno::UNO_QUERY) { } //------------------------------------------------------------------------------ @@ -148,8 +148,25 @@ SAL_CALL SingleBackendAdapter::listLayers(const rtl::OUString& aComponent, lang::IllegalArgumentException, uno::RuntimeException) { - return mBackend->getLayers(mBackend->listLayerIds(aComponent, aEntity), - rtl::OUString()) ; + uno::Sequence<uno::Reference<backenduno::XLayer> > retCode = + mBackend->getLayers(mBackend->listLayerIds(aComponent, aEntity), + rtl::OUString()) ; + + // There might be non-existent layers in the list if there's no + // actual data associated to a given layer id. Hence we have to + // compress the list. + sal_Int32 maxLayer = 0 ; + + for (sal_Int32 i = 0 ; i < retCode.getLength() ; ++ i) + { + if (retCode [i].is()) + { + if (i != maxLayer) { retCode [maxLayer] = retCode [i] ; } + ++ maxLayer ; + } + } + retCode.realloc(maxLayer) ; + return retCode ; } //------------------------------------------------------------------------------ @@ -200,9 +217,9 @@ const ServiceRegistrationInfo *getSingleBackendAdapterServiceInfo() } uno::Reference<uno::XInterface> SAL_CALL -instantiateSingleBackendAdapter(const CreationContext& aContext) +instantiateSingleBackendAdapter(const CreationContext& xContext) { - return *new SingleBackendAdapter(aContext) ; + return *new SingleBackendAdapter(xContext) ; } //------------------------------------------------------------------------------ diff --git a/configmgr/source/backend/singlebackendadapter.hxx b/configmgr/source/backend/singlebackendadapter.hxx index 39b1cc5a3fd2..8e4ef0707ba2 100644 --- a/configmgr/source/backend/singlebackendadapter.hxx +++ b/configmgr/source/backend/singlebackendadapter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: singlebackendadapter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: cyrillem $ $Date: 2002-06-17 14:28:57 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,10 @@ #include <drafts/com/sun/star/configuration/backend/XSingleBackend.hpp> #endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_XSINGLEBACKEND_HPP_ +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif + #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ #include <com/sun/star/lang/XInitialization.hpp> #endif // _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ @@ -78,10 +82,6 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #endif // _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif // _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ - #ifndef _CPPUHELPER_COMPBASE3_HXX_ #include <cppuhelper/compbase3.hxx> #endif // _CPPUHELPER_COMPBASE3_HXX_ @@ -109,7 +109,7 @@ class SingleBackendAdapter : public BackendBase { @param aFactory service factory */ SingleBackendAdapter( - const uno::Reference<lang::XMultiServiceFactory>& aFactory) ; + const uno::Reference<uno::XComponentContext>& xContext) ; /** Destructor */ ~SingleBackendAdapter(void) ; @@ -169,7 +169,7 @@ class SingleBackendAdapter : public BackendBase { protected : private : /** Service factory */ - const uno::Reference<lang::XMultiServiceFactory>& mFactory ; + uno::Reference<lang::XMultiServiceFactory> mFactory ; /** Mutex for resource protection */ osl::Mutex mMutex ; /** Remote backend that the offline cache is handling */ diff --git a/configmgr/source/backend/updatesvc.cxx b/configmgr/source/backend/updatesvc.cxx index 8ea0cada98be..ddc491f3f385 100644 --- a/configmgr/source/backend/updatesvc.cxx +++ b/configmgr/source/backend/updatesvc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: updatesvc.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,13 +112,13 @@ ServiceInfoHelper UpdateService::getServiceInfo() // ----------------------------------------------------------------------------- -UpdateService::UpdateService(CreationArg _xServiceFactory) -: m_xServiceFactory(_xServiceFactory) +UpdateService::UpdateService(CreationArg _xContext) +: m_xServiceFactory(_xContext->getServiceManager(),uno::UNO_QUERY) , m_aSourceMode(merge) { if (!m_xServiceFactory.is()) { - OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration Update Merger: Unexpected NULL context")); + OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration Update Merger: Context has no service manager (or missing interface)")); throw uno::RuntimeException(sMessage,NULL); } } diff --git a/configmgr/source/backend/updatesvc.hxx b/configmgr/source/backend/updatesvc.hxx index 5105c025bd68..a254725bff07 100644 --- a/configmgr/source/backend/updatesvc.hxx +++ b/configmgr/source/backend/updatesvc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: updatesvc.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-11-28 12:49:13 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,9 @@ #include <cppuhelper/implbase3.hxx> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -107,10 +110,10 @@ namespace configmgr > { public: - typedef uno::Reference< lang::XMultiServiceFactory > const & CreationArg; + typedef uno::Reference< uno::XComponentContext > const & CreationArg; explicit - UpdateService(CreationArg _xServiceFactory); + UpdateService(CreationArg _xContext); // XInitialization virtual void SAL_CALL diff --git a/configmgr/source/cmdtools/makefile.mk b/configmgr/source/cmdtools/makefile.mk index eedbd37bc75c..89e8d9a46eea 100644 --- a/configmgr/source/cmdtools/makefile.mk +++ b/configmgr/source/cmdtools/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: jb $ $Date: 2002-11-26 08:54:02 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:18:52 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -124,31 +124,3 @@ APP2OBJS= \ .INCLUDE : target.mk -#************************************************************************** -# history: -# $Log: not supported by cvs2svn $ -# Revision 1.2 2002/10/24 15:29:25 jb -# #102602# New application for importing configuration data into a backend -# -# Revision 1.1.1.1 2000/09/18 16:13:40 hr -# initial import -# -# Revision 1.4 2000/09/15 09:51:48 willem.vandorp -# OpenOffice header added -# -# Revision 1.3 2000/08/27 15:44:53 fs -# #78183# replaced cout/cerr with fprintf -# -# Revision 1.2 2000/08/25 13:22:39 fs -# #78116# on unx, build *.bin -# -# Revision 1.1 2000/08/25 13:02:07 fs -# common reg server related command line tools -# -# Revision 1.1 2000/06/23 08:47:33 fs -# socket related helpers/samples -# -# -# Revision 1.0 26.05.00 17:11:32 fs -#************************************************************************** - diff --git a/configmgr/source/inc/anynoderef.hxx b/configmgr/source/inc/anynoderef.hxx index 6404b2d469c8..2f810f88bda1 100644 --- a/configmgr/source/inc/anynoderef.hxx +++ b/configmgr/source/inc/anynoderef.hxx @@ -2,9 +2,9 @@ * * $RCSfile: anynoderef.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,12 +69,12 @@ namespace configmgr { namespace configapi { class Factory; } + namespace node { struct Attributes; } namespace configuration { //------------------------------------------------------------------------- class Name; - struct Attributes; //------------------------------------------------------------------------- namespace argument { struct NoValidate; } diff --git a/configmgr/source/inc/apitypes.hxx b/configmgr/source/inc/apitypes.hxx index 34a4c55964c8..d3fecbb1ef15 100644 --- a/configmgr/source/inc/apitypes.hxx +++ b/configmgr/source/inc/apitypes.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apitypes.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kr $ $Date: 2001-09-12 12:07:26 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,14 +89,10 @@ namespace configmgr { - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - using ::std::vector; - using ::rtl::OUString; - namespace configapi { + namespace uno = ::com::sun::star::uno; + inline uno::Type getAnyType( ) { @@ -125,7 +121,7 @@ namespace configmgr template <typename T> inline - uno::Sequence<T> makeSequence(vector<T> const& aVector) + uno::Sequence<T> makeSequence(::std::vector<T> const& aVector) { if (aVector.empty()) return uno::Sequence<T>(); @@ -133,17 +129,6 @@ namespace configmgr } } - // and one on the side - class NotCopyable - { - protected: - NotCopyable() {} - ~NotCopyable() {} - private: - NotCopyable (NotCopyable& notImplemented); - void operator= (NotCopyable& notImplemented); - }; - } #endif // CONFIGMGR_API_APITYPES_HXX_ diff --git a/configmgr/source/inc/attributes.hxx b/configmgr/source/inc/attributes.hxx index c76a644b6de8..a71002b2bd91 100644 --- a/configmgr/source/inc/attributes.hxx +++ b/configmgr/source/inc/attributes.hxx @@ -2,9 +2,9 @@ * * $RCSfile: attributes.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,11 +118,6 @@ namespace configmgr }; } - // for backward compatibility - this used to be in namespace configuration - namespace configuration - { - using node::Attributes; - } } #endif diff --git a/configmgr/source/inc/backendfactory.hxx b/configmgr/source/inc/backendfactory.hxx index c9c24c7f7bf5..35d171a17a21 100644 --- a/configmgr/source/inc/backendfactory.hxx +++ b/configmgr/source/inc/backendfactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: backendfactory.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:26:50 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,47 +66,42 @@ #include <rtl/ref.hxx> #endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ -#include <com/sun/star/script/XTypeConverter.hpp> +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> #endif #include <drafts/com/sun/star/configuration/backend/XBackend.hpp> namespace configmgr { //----------------------------------------------------------------------------- - class ConnectionSettings; - class IConfigSession; -//----------------------------------------------------------------------------- namespace backend { //----------------------------------------------------------------------------- struct IMergedDataProvider; //----------------------------------------------------------------------------- - struct BackendFactory + class BackendFactory { - typedef com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + public: + typedef com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > CreationContext; - typedef com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > - TypeConverterRef; - typedef com::sun::star::uno::Reference< drafts::com::sun::star::configuration::backend::XBackend > UnoBackend; - rtl::Reference<IMergedDataProvider> - createBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx); + rtl::Reference<IMergedDataProvider> createBackend(); + + UnoBackend getUnoBackend(); - static UnoBackend - createDefaultUnoBackend(CreationContext const & _xCtx); + static BackendFactory instance(CreationContext const & _xCtx); - static UnoBackend - createUnoBackend(ConnectionSettings const & _aSettings, CreationContext const & _xCtx); + private: + explicit + BackendFactory(CreationContext const & _xCtx) + : m_xCtx(_xCtx) + {} - static BackendFactory & instance(); + CreationContext m_xCtx; }; //----------------------------------------------------------------------------- } diff --git a/configmgr/source/inc/bootstrap.hxx b/configmgr/source/inc/bootstrap.hxx index 744c8de7bbbc..bb3a68595325 100644 --- a/configmgr/source/inc/bootstrap.hxx +++ b/configmgr/source/inc/bootstrap.hxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.hxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: jb $ $Date: 2002-10-24 15:44:01 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,322 +62,214 @@ #ifndef CONFIGMGR_BOOTSTRAP_HXX_ #define CONFIGMGR_BOOTSTRAP_HXX_ -#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ -#include <com/sun/star/uno/Reference.hxx> -#endif -#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ -#include <com/sun/star/uno/Sequence.hxx> -#endif -#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ -#include <com/sun/star/uno/Any.hxx> -#endif -#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ -#include <com/sun/star/beans/NamedValue.hpp> -#endif -#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ -#include <com/sun/star/uno/XComponentContext.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ -#include <com/sun/star/lang/IllegalArgumentException.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _RTL_USTRING_HXX_ -#include <rtl/ustring.hxx> -#endif - -#ifndef INCLUDED_MAP -#include <map> -#define INCLUDED_MAP +#ifndef CONFIGMGR_BOOTSTRAPCONTEXT_HXX_ +#include "bootstrapcontext.hxx" #endif -namespace osl { - class Profile; -} - +// --------------------------------------------------------------------------------------- +#define CONFIGMGR_INIFILE SAL_CONFIGFILE("configmgr") +#define BOOTSTRAP_ITEM_INIFILE "CFG_INIFILE" +// --------------------------------------------------------------------------------------- +// standard settings +#define SETTING_UNOSERVICE "BackendService" +#define SETTING_UNOWRAPPER "BackendWrapper" +#define SETTING_OFFLINE "Offline" +#define SETTING_LOCALE_NEW "Locale" +#define SETTING_ASYNC_NEW "EnableAsync" +#define SETTING_INIFILE "Inifile" + +// Prefixes +#define CONTEXT_MODULE_PREFIX_ "/modules/com.sun.star.configuration/" +#define CONTEXT_SECTION_BOOTSTRAP_ "bootstrap/" +#define CONTEXT_ITEM_PREFIX_ CONTEXT_MODULE_PREFIX_ CONTEXT_SECTION_BOOTSTRAP_ +#define BOOTSTRAP_ITEM_PREFIX_ "CFG_" + +// special internal context values +#define CONTEXT_SECTION_INTERNAL_ "factory/" +#define CONTEXT_INTERNAL_PREFIX_ CONTEXT_MODULE_PREFIX_ CONTEXT_SECTION_INTERNAL_ +#define CONTEXT_ITEM_ADMINFLAG CONTEXT_INTERNAL_PREFIX_"isAdminConfiguration" +#define CONTEXT_ITEM_BOOTSTRAP_ERROR CONTEXT_INTERNAL_PREFIX_"theBootstrapError" + +#define CONTEXT_ITEM_IS_WRAPPER_CONTEXT CONTEXT_INTERNAL_PREFIX_"isWrapperContext" +#define CONTEXT_ITEM_IS_BOOTSTRAP_CONTEXT CONTEXT_INTERNAL_PREFIX_"isBootstrapContext" + +// --------------------------------------------------------------------------------------- +#define A_DefaultProviderSingletonName "com.sun.star.configuration.theDefaultProvider" +#define K_DefaultBackendSingletonName "com.sun.star.configuration.backend.theDefaultBackend" +#define K_DefaultSingleBackendSingletonName "com.sun.star.configuration.backend.theDefaultSingleBackend" +#define A_BootstrapContextSingletonName "com.sun.star.configuration.bootstrap.theBootstrapContext" +// ------------------------------------------------------------------------- +#define A_DefaultProviderServiceAndImplName "com.sun.star.configuration.DefaultProvider" +#define K_DefaultBackendServiceAndImplName "com.sun.star.configuration.backend.DefaultBackend" +#define K_DefaultSingleBackendServiceAndImplName "com.sun.star.configuration.backend.DefaultSingleBackend" +// --------------------------------------------------------------------------------------- namespace configmgr { - class IConfigSession; - - // =================================================================================== + // ----------------------------------------------------------------------------------- namespace uno = ::com::sun::star::uno; namespace lang = ::com::sun::star::lang; namespace beans = ::com::sun::star::beans; using ::rtl::OUString; + // ----------------------------------------------------------------------------------- - // =================================================================================== - #define UNO_SESSION_IDENTIFIER "uno" - #define PORTAL_SESSION_IDENTIFIER "portal" - #define REMOTE_SESSION_IDENTIFIER "remote" - #define LOCAL_SESSION_IDENTIFIER "local" - #define SETUP_SESSION_IDENTIFIER "setup" - #define PLUGIN_SESSION_IDENTIFIER "plugin" + /** Customized ComponentContext for configuration bootstrap data and runtime arguments + */ + class BootstrapContext : public ComponentContext + { + // creation and destruction + private: + friend uno::Reference<uno::XInterface> SAL_CALL + instantiateBootstrapContext( Context const& xContext ); + // constructor + BootstrapContext(Context const & _xContext); - // =================================================================================== - // =================================================================================== - // = Settings - // =================================================================================== - class Settings - { - public: - enum Origin - { - SO_NOT_SET, - SO_UNKNOWN, - SO_FALLBACK, - SO_INIFILE, - SO_BOOTSTRAP, - SO_DEFAULT, - SO_OVERRIDE, - SO_ADJUSTMENT, - SO_MANUAL - }; - typedef OUString Name; - - // a single setting - class Setting - { - uno::Any m_aValue; - Origin m_eOrigin; - public: - Setting() : m_aValue(), m_eOrigin(SO_NOT_SET) { } - Setting(const OUString& _rValue, Origin _eOrigin) : m_aValue(uno::makeAny(_rValue)), m_eOrigin(_eOrigin) { } - Setting(const sal_Int32 _nValue, Origin _eOrigin) : m_aValue(uno::makeAny(_nValue)), m_eOrigin(_eOrigin) { } - Setting(const uno::Any& _rValue, Origin _eOrigin) : m_aValue(_rValue), m_eOrigin(_eOrigin) { } - - - uno::Any value() const { return m_aValue; } - Origin origin() const { return m_eOrigin; }; - - OUString toString() const; - sal_Int32 toInt32() const; - sal_Bool toBool() const; - }; - protected: - typedef std::map< Name, Setting > SettingsImpl; - SettingsImpl m_aImpl; + // two-phase construct + void initialize(); public: - typedef SettingsImpl::const_iterator Iterator; - public: - /// default ctor - Settings(); - - /** construct a settings object - containing the given overrides + typedef uno::Sequence < beans::NamedValue > Overrides; + /** Constructs a Context based on the given arguments and context. + @param _xContext + The base context of this component context. + @param _aArguments + The arguments used to create this component context. */ - Settings(const uno::Sequence< uno::Any >& _rOverrides, Origin _eOrigin = SO_OVERRIDE); + static Context createWrapper(Context const & _xContext, Overrides const & _aOverrides); - /// merge the given overrides into the object itself - void mergeOverrides(const Settings& _rOverrides); + /** Checks, if the given context is a wrapper. + @param _xContext + The context that is checked. + */ + static sal_Bool isWrapper(Context const & _xContext); - // check setting existence - sal_Bool haveSetting(Name const& _pName) const; - Origin getOrigin(Name const& _pName) const; + /** Retrieves the BootstrapContext for the given non-bootstrap context. + @param _xContext + The context from which the bootstrap context should be retrieved. - void putSetting(Name const& _pName, const Setting& _rSetting); - void clearSetting(Name const& _pName); + */ + static Context get(Context const & _xContext); - OUString getStringSetting(Name const& _pName) const; - sal_Int32 getIntSetting(Name const& _pName) const; - sal_Bool getBoolSetting(Name const& _pName) const; - Setting getSetting(Name const& _pName) const; - Setting getMaybeSetting(Name const& _pName) const; + /// Destroys this BootstrapContext + ~BootstrapContext(); - SettingsImpl::size_type size() const { return m_aImpl.size(); } - Iterator begin() const { return m_aImpl.begin(); } - Iterator end() const { return m_aImpl.end(); } + // gets the INI that should be used for bootstrap data by default + static OUString getDefaultConfigurationBootstrapURL(); - void swap(Settings& _rOther) { m_aImpl.swap(_rOther.m_aImpl); } - private: - void implAddOverrides(const uno::Sequence< uno::Any >& _rOverrides, Origin _eOrigin); - bool implExtractOverride(const uno::Any & _rOverride, Name& _rName, uno::Any& _rValue); - }; + // interface implementations + public: + // XComponentContext + /** Retrieves a value from this context. + @param Name + The name of the value to retrieve. + A prefix of "com.sun.star.configuration.bootstrap." is stripped/ignored - class ConnectionSettings - { - friend class BootstrapSettings; + @returns + The requested value, or <VOID/> if the value is not found. + */ + virtual uno::Any SAL_CALL + getValueByName( const OUString& Name ) + throw (uno::RuntimeException); - Settings m_aSettings; + public: // used by ArgumentHelper + static OUString makeContextName (OUString const & _aShortName); - ConnectionSettings() : m_aSettings() {}; + private: + static OUString makeBootstrapName(OUString const & _aLongName); + uno::Any makeBootstrapException(); + }; +// ----------------------------------------------------------------------------- + class ContextReader + { public: - ConnectionSettings(const uno::Sequence< uno::Any >& _rOverrides, - Settings::Origin _eOrigin = Settings::SO_OVERRIDE); + typedef uno::Reference< uno::XComponentContext > Context; + explicit + ContextReader(Context const & context); - /// merge the given overrides into the object itself - void mergeOverrides(const Settings& _rOverrides) - { - implMergeOverrides(_rOverrides); - implNormalizeSettings(); - } + // the underlying contexts + sal_Bool hasBootstrapContext() const { return m_fullcontext.is(); } + Context const & getBootstrapContext() const { return m_fullcontext; } + Context const & getBaseContext() const { return m_basecontext; } + Context const & getBestContext() const { return m_fullcontext.is() ? m_fullcontext : m_basecontext; } - /// merge the given overrides into the object itself - void mergeOverrides(const ConnectionSettings& _rOverrides) - { - implMergeOverrides(_rOverrides.m_aSettings); - } + uno::Reference< lang::XMultiComponentFactory > getServiceManager() const; - bool validate(); + /** Checks, if the given context is a BootstrapContext. + @param _xContext + The context that is checked. + */ + static bool isBootstrapContext(Context const & context); - bool isComplete() const; - bool isComplete(OUString const& aSessionType) const; + /** Checks, if the given context has the given 'admin' flag setting.. + @param _xContext + The context that is checked. + */ + static bool testAdminService(Context const & context, bool bAdmin); - sal_Bool isSessionTypeKnown() const; + // general settings + sal_Bool isUnoBackend() const; - sal_Bool hasUser() const; - sal_Bool hasPassword() const; + sal_Bool hasUnoBackendService() const; + sal_Bool hasUnoBackendWrapper() const; sal_Bool hasLocale() const; sal_Bool hasAsyncSetting() const; sal_Bool hasOfflineSetting() const; - sal_Bool hasServer() const; - sal_Bool hasPort() const; - sal_Bool hasTimeout() const; - sal_Bool hasService() const; - - sal_Bool isPlugin() const; - sal_Bool isLocalSession() const; - sal_Bool isRemoteSession() const; - bool isUnoBackend() const; - - sal_Bool hasUnoBackendService() const; - sal_Bool hasUnoBackendWrapper() const; - - sal_Bool isSourcePathValid() const; - sal_Bool isUpdatePathValid() const; - sal_Bool hasReinitializeFlag() const; - - // get a special setting - OUString getSessionType() const; - sal_Bool isAdminSession() const; - OUString getUnoBackendService() const; OUString getUnoBackendWrapper() const; - OUString getUser() const; - OUString getPassword() const; - OUString getLocale() const; sal_Bool getAsyncSetting() const; sal_Bool getOfflineSetting() const; - OUString getSourcePath() const; - OUString getUpdatePath() const; - sal_Bool getReinitializeFlag() const; - - OUString getServer() const; - OUString getService() const; - sal_Int32 getPort() const; - sal_Int32 getTimeout() const; - - // make sure this behaves as a user session - void setUserSession(); - void setUserSession(const OUString& _rRemoteServiceName); - - // make sure this behaves as an administrative session - void setAdminSession(); - void setAdminSession(const OUString& _rRemoteServiceName); - - // set a new session type. Must be one of the *_SESSION_IDENTIFIER defines - void setSessionType(const OUString& _rSessionIdentifier, Settings::Origin _eOrigin /*= SO_MANUAL*/); - - // set a desired service, only necessary in remote environments - sal_Bool isServiceRequired() const; - void setService(const OUString& _rService, Settings::Origin _eOrigin /*= SO_MANUAL*/); - - // set this to a wildcard locale - void setAnyLocale(Settings::Origin _eOrigin /*= SO_MANUAL*/); - - IConfigSession* createConnection( - uno::Reference< lang::XMultiServiceFactory > const& _rxServiceMgr) const; - - void swap(ConnectionSettings& _rOther) { m_aSettings.swap(_rOther.m_aSettings); } - - uno::Sequence< beans::NamedValue > getUnoSettings() const; + // internal settings - should only ever be in configmgr::BootstrapContext instances + // get a special setting + sal_Bool isAdminService() const; + // access to error diagnostics + sal_Bool isBootstrapValid() const; + uno::Any getBootstrapError() const; private: - bool checkSettings() const; - - /** @return <TRUE/> if the setting exists and is a valid path - */ - // sal_Bool isValidPathSetting(Settings::Name const& _pSetting) const; - - // if we do not already have the given config path setting, ensure that it exists (calculated relative to a given path) - //sal_Bool ensureConfigPath(Settings::Name const& _pSetting, const OUString& _rBasePath); - - /// merge the given overrides into the object itself - void implMergeOverrides(const Settings& _rOverrides); - - // ensure that the named setting is a valid file URL - bool implNormalizePathSetting(Settings::Name const& _pSetting); - - // normalize the server and port settings - void implNormalizeRemoteServer(); - - // transform settings that are accepted for compatibility reasons to their normal form - void implNormalizeSettings(); - - // tries to ensure that a session type is set - bool implDetermineSessionType(); - - // convenience wrappers for Settings members - public: - sal_Bool haveSetting(Settings::Name const& _pName) const - { return m_aSettings.haveSetting(_pName); } - - Settings::Setting getSetting(Settings::Name const& _pName) const - { return m_aSettings.getSetting(_pName); } - - // private convenience wrappers for Settings members + sal_Bool hasSetting(OUString const & _aSetting) const; + sal_Bool getBoolSetting(OUString const & _aSetting, sal_Bool bValue) const; + OUString getStringSetting(OUString const & _aSetting, OUString aValue) const; + uno::Any getSetting(OUString const & _aSetting) const; private: - void putSetting(Settings::Name const& _pName, const Settings::Setting& _rSetting) - { m_aSettings.putSetting(_pName,_rSetting); } - - void clearSetting(Settings::Name const& _pName) - { m_aSettings.clearSetting(_pName); } + Context m_basecontext; + Context m_fullcontext; }; + //------------------------------------------------------------------------ -// =================================================================================== - -// =================================================================================== - class BootstrapSettings + class ArgumentHelper { + bool m_bHasBackendArguments; public: typedef uno::Reference< uno::XComponentContext > Context; - ConnectionSettings settings; /// the settings collected from bootstrapping (may work even if !valid) - bool valid; /// indicates whether the whole bootstrap process was executed successfully - explicit - BootstrapSettings(Context const & xContext) - : settings() - , valid(false) - { - bootstrap(xContext); - } + ArgumentHelper(Context const & context) + : m_context(context) + , m_bHasBackendArguments(false) + {} - void raiseBootstrapException( uno::Reference< uno::XInterface > const & xErrorContext ) const; + bool hasBackendArguments() const { return m_bHasBackendArguments; } + bool checkBackendArgument(beans::NamedValue const & aAdjustedValue); - static OUString getURL(); - private: - void bootstrap(Context const & xContext); + bool filterAndAdjustArgument(beans::NamedValue & rValue); - struct Impl; - friend struct Impl; - }; -// =================================================================================== + static + bool extractArgument(beans::NamedValue & rValue, uno::Any const & aArgument); - // a transition helper - BootstrapSettings::Context getBootstrapContext(const uno::Reference< lang::XMultiServiceFactory >& _xORB); + static beans::NamedValue makeAdminServiceOverride(sal_Bool bAdmin); + private: + Context m_context; // context used to strip identical arguments + }; +// ----------------------------------------------------------------------------------- -// =================================================================================== } #endif // CONFIGMGR_BOOTSTRAP_HXX_ diff --git a/configmgr/source/inc/bootstrapcontext.hxx b/configmgr/source/inc/bootstrapcontext.hxx index cca83f425e5b..b23e5f6b47d2 100644 --- a/configmgr/source/inc/bootstrapcontext.hxx +++ b/configmgr/source/inc/bootstrapcontext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrapcontext.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-06-12 16:37:43 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,9 @@ #ifndef CONFIGMGR_BOOTSTRAPCONTEXT_HXX_ #define CONFIGMGR_BOOTSTRAPCONTEXT_HXX_ +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif #ifndef _CPPUHELPER_IMPLBASE1_HXX_ #include <cppuhelper/implbase1.hxx> #endif @@ -70,9 +73,18 @@ #include <rtl/bootstrap.h> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_UNO_XCURRENTCONTEXT_HPP_ #include <com/sun/star/uno/XCurrentContext.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ +#include <com/sun/star/lang/XEventListener.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif #ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ #include <com/sun/star/beans/NamedValue.hpp> #endif @@ -84,6 +96,10 @@ namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } } +// ----------------------------------------------------------------------------- +#define SINGLETON_ "/singletons/" +#define SINGLETON( NAME ) OUString( RTL_CONSTASCII_USTRINGPARAM( SINGLETON_ NAME ) ) +// ----------------------------------------------------------------------------- namespace configmgr { // ----------------------------------------------------------------------------- @@ -92,66 +108,144 @@ namespace configmgr namespace beans = ::com::sun::star::beans; using ::rtl::OUString; // ----------------------------------------------------------------------------- - /** Base class for a customized ComponentContext + typedef ::cppu::WeakComponentImplHelper2 < + uno::XComponentContext, + uno::XCurrentContext + > ComponentContext_Base; + /** Base class for customized ComponentContext using bootstrap data and overrides */ - class BootstrapContext - : public ::cppu::WeakImplHelper1< uno::XCurrentContext > + class ComponentContext : public ComponentContext_Base { public: - typedef uno::Reference< uno::XComponentContext > ComponentContext; - typedef uno::Sequence < beans::NamedValue > Arguments; + typedef uno::Reference< uno::XComponentContext > Context; + typedef uno::Reference< lang::XMultiComponentFactory > ServiceManager; + // creation and destruction public: - /** Constructs a BoottrapContext based on the given arguments and context. - - @param _aArguments - The arguments used to create this component. - These values will override values from the context or bootstrap data. + /** Constructs a ComponentContext based on the given overrides and context. + Initially no bootstrap data will be used. @param _xContext - The context of this component. - Values from here will override values from bootstrap data. + The base context of this component context. + Values from here take precedence over values from bootstrap data. + + @param _aOverrides + The overrides used to create this component context. + These values take precedence over values from the base context or bootstrap data. */ explicit - BootstrapContext(Arguments const & _aArguments, ComponentContext const & _xContext = ComponentContext()); + ComponentContext(Context const & _xContext); /// Destroys this BootstrapContext - ~BootstrapContext(); + ~ComponentContext(); + + /// changes the INI file to use for bootstrap data + void changeBootstrapURL( const OUString& _aURL ); + + // gets the INI in use for getting bootstrap data + OUString getBootstrapURL() const; + + static sal_Bool isPassthrough(Context const & _xContext); - /// sets the INI file to use for bootstrap data - void setBootstrapURL( const OUString& _aURL ); + static Context getBaseContext(Context const & _xContext); + static beans::NamedValue makePassthroughMarker(sal_Bool bPassthrough = true); // interface implementations public: - // XCurrentContext + // XComponentContext & XCurrentContext /** Retrieves a value from this context. + Can be overridden in derived implementations @param Name The name of the value to retrieve. - A prefix of "com.sun.star.configuration.bootstrap." is stripped/ignored @returns The requested value, or <VOID/> if the value is not found. */ virtual uno::Any SAL_CALL getValueByName( const OUString& Name ) + throw (uno::RuntimeException) = 0; + + // XComponentContext only + virtual ServiceManager SAL_CALL + getServiceManager( ) throw (uno::RuntimeException); - private: - bool lookupInArguments( uno::Any & _rValue, const OUString& _aName ); - bool lookupInContext ( uno::Any & _rValue, const OUString& _aName ); - bool lookupInBootstrap( uno::Any & _rValue, const OUString& _aName ); + protected: + // ComponentHelper + virtual void SAL_CALL disposing(); + + protected: + // two phase construct - also initialized the bootstrap data + void initialize(const OUString& _aBootstrapURL); + + bool lookupInContext ( uno::Any & _rValue, const OUString& _aName ) const; + bool lookupInBootstrap( uno::Any & _rValue, const OUString& _aName ) const; - static OUString makeLongName (OUString const & _aName); - static OUString makeShortName(OUString const & _aName); + osl::Mutex & mutex() const { return m_aMutex; } + Context const & basecontext() const { osl::MutexGuard lock(mutex()); return m_xContext; } - /// The context that some requests are delegated to - Arguments m_aArguments; - ComponentContext m_xContext; + private: + /// The mutex protecting this component + mutable osl::Mutex m_aMutex; + /// The context that most requests are delegated to + Context m_xContext; + /// The bootstrap data consulted as fallback rtlBootstrapHandle m_hBootstrapData; }; // ----------------------------------------------------------------------------- + class UnoContextTunnel + { + public: + typedef uno::Reference< uno::XCurrentContext > CurrentContext; + typedef uno::Reference< lang::XUnoTunnel > FailureTunnel; + typedef uno::Reference< uno::XComponentContext > Context; + public: + UnoContextTunnel(); + ~UnoContextTunnel(); + void tunnel(Context const & xContext); + void passthru(Context const & xContext); + uno::Any recoverFailure(bool bRaise); // true, if there is a failure + + static Context recoverContext(Context const & xFallback = Context()); + static bool tunnelFailure(uno::Any const & aException, bool bRaise = false); + private: + CurrentContext m_xOldContext; + FailureTunnel m_xActiveTunnel; + class Tunnel; + }; +// ----------------------------------------------------------------------------- + + class DisposingForwarder : public cppu::WeakImplHelper1< lang::XEventListener > + { + uno::Reference< lang::XComponent > m_xTarget; + + DisposingForwarder( uno::Reference< lang::XComponent > const & xTarget ) SAL_THROW( () ) + : m_xTarget( xTarget ) + { OSL_ASSERT( m_xTarget.is() ); } + + virtual void SAL_CALL disposing( lang::EventObject const & rSource ) + throw (uno::RuntimeException); + public: + // listens at source for disposing, then disposes target + static inline void forward( + uno::Reference< lang::XComponent > const & xSource, + uno::Reference< lang::XComponent > const & xTarget ) + SAL_THROW( (uno::RuntimeException) ); + }; +//__________________________________________________________________________________________________ + inline void DisposingForwarder::forward( + uno::Reference< lang::XComponent > const & xSource, + uno::Reference< lang::XComponent > const & xTarget ) + SAL_THROW( (uno::RuntimeException) ) + { + if (xSource.is()) + { + xSource->addEventListener( new DisposingForwarder( xTarget ) ); + } + } +// ----------------------------------------------------------------------------- } // namespace configmgr #endif diff --git a/configmgr/source/inc/cachefactory.hxx b/configmgr/source/inc/cachefactory.hxx index 91f49a8f3120..62ba3f39920d 100644 --- a/configmgr/source/inc/cachefactory.hxx +++ b/configmgr/source/inc/cachefactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cachefactory.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:27:09 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,29 +66,22 @@ #include <rtl/ref.hxx> #endif -#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ -#include <com/sun/star/script/XTypeConverter.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> #endif namespace configmgr { //----------------------------------------------------------------------------- class TreeManager; - class ConnectionSettings; - class IConfigSession; //----------------------------------------------------------------------------- struct CacheFactory { - typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > CreationContext; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > - TypeConverterRef; rtl::Reference<TreeManager> - createCacheManager(ConnectionSettings const & _aSettings, CreationContext const & _xContext); + createCacheManager(CreationContext const & _xContext); static CacheFactory & instance(); }; diff --git a/configmgr/source/inc/change.hxx b/configmgr/source/inc/change.hxx index 0cf929268d4c..404f6b88d127 100644 --- a/configmgr/source/inc/change.hxx +++ b/configmgr/source/inc/change.hxx @@ -2,9 +2,9 @@ * * $RCSfile: change.hxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: jb $ $Date: 2002-10-16 07:58:26 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,8 +78,8 @@ #ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> #endif -#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ -#include <com/sun/star/uno/Sequence.h> +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> #endif #ifndef INCLUDED_MAP @@ -217,7 +217,7 @@ namespace configmgr Mode getMode() const { return m_eMode; } - const configuration::Attributes& getAttributes() const {return m_aAttributes;} + const node::Attributes& getAttributes() const {return m_aAttributes;} rtl::OUString getModeAsString() const; void setModeAsString(const rtl::OUString& _rMode); @@ -542,7 +542,7 @@ namespace configmgr class SubtreeChangeReferrer : public SubtreeChange { // no explicit construction - SubtreeChangeReferrer() : SubtreeChange(::rtl::OUString(), configuration::Attributes()) { } + SubtreeChangeReferrer() : SubtreeChange(::rtl::OUString(), node::Attributes()) { } public: SubtreeChangeReferrer(const SubtreeChange& _rSource); diff --git a/configmgr/source/inc/commontypes.hxx b/configmgr/source/inc/commontypes.hxx index d37458e6b48c..ef5be7f1b4b3 100644 --- a/configmgr/source/inc/commontypes.hxx +++ b/configmgr/source/inc/commontypes.hxx @@ -2,9 +2,9 @@ * * $RCSfile: commontypes.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,31 +97,6 @@ public: virtual void SAL_CALL release( ) throw () = 0; }; -typedef ::com::sun::star::uno::RuntimeException CantRenameException_Base; -class CantRenameException : CantRenameException_Base -{ -public: - ::rtl::OUString newName; - ::rtl::OUString oldName; - - static ::rtl::OUString message(::rtl::OUString const& sNewName, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed> xContext) - { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Object cannot be renamed") ); - } - - CantRenameException(::rtl::OUString const& sNewName, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > xContext) - : CantRenameException_Base(message(sNewName,xContext), xContext) - , newName(sNewName) - , oldName(xContext->getName()) - { - } -}; -//.......................................................................... -struct UStringLess : public std::binary_function< rtl::OUString, rtl::OUString, bool> -{ - bool operator() (const rtl::OUString& lhs, const rtl::OUString& rhs) const - { return lhs < rhs ? true : false;} // construct prevents a MSVC6 warning -}; //.......................................................................... } // namespace configmgr //.......................................................................... diff --git a/configmgr/source/inc/confapifactory.hxx b/configmgr/source/inc/confapifactory.hxx index 21f1fa15ec3e..0f6ea3359ef6 100644 --- a/configmgr/source/inc/confapifactory.hxx +++ b/configmgr/source/inc/confapifactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confapifactory.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:06:55 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,68 +69,67 @@ namespace com { namespace sun { namespace star { { class XInterface; template <class> class Reference; + class XComponentContext; } namespace lang { - class XMultiServiceFactory; + class XSingleComponentFactory; } } } } +namespace rtl { class OUString; } namespace configmgr { - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; - struct ServiceRegistrationInfo; - class ConnectionSettings; - - typedef uno::Reference< lang::XMultiServiceFactory > CreationContext; + namespace uno = ::com::sun::star::uno; + namespace lang = ::com::sun::star::lang; - typedef uno::Reference< uno::XInterface > (SAL_CALL * ProviderInstantiation) - ( - CreationContext const& rServiceManager, - ConnectionSettings const& _rConnectionSettings - ); + extern + uno::Reference< lang::XSingleComponentFactory > SAL_CALL + createProviderFactory( + ::rtl::OUString const & aImplementationName, + bool bAdmin + ) + SAL_THROW( () ); -// provider instantiation - uno::Reference< uno::XInterface > SAL_CALL instantiateConfigProvider - ( - CreationContext const& rServiceManager, - ConnectionSettings const& _rConnectionSettings - ); + struct ServiceRegistrationInfo; + struct SingletonRegistrationInfo; - uno::Reference< uno::XInterface > SAL_CALL instantiateAdminProvider - ( - CreationContext const& rServiceManager, - ConnectionSettings const& _rConnectionSettings - ); + typedef uno::Reference< uno::XComponentContext > CreationContext; - uno::Reference< uno::XInterface > SAL_CALL instantiateLocalAdminProvider - ( - CreationContext const& rServiceManager, - ConnectionSettings const& _rConnectionSettings - ); +// provider instantiation + uno::Reference<uno::XInterface> SAL_CALL + getDefaultConfigProviderSingleton( CreationContext const& xContext ); + uno::Reference<uno::XInterface> SAL_CALL + instantiateDefaultProvider( CreationContext const& xContext ); // provider service info - const ServiceRegistrationInfo* getConfigurationProviderServices(); - const ServiceRegistrationInfo* getAdminProviderServices(); - const ServiceRegistrationInfo* getLocalAdminProviderServices(); + const SingletonRegistrationInfo * getDefaultProviderSingletonInfo(); + const ServiceRegistrationInfo * getConfigurationProviderServiceInfo(); + const ServiceRegistrationInfo * getDefaultProviderServiceInfo(); + const ServiceRegistrationInfo * getAdminProviderServiceInfo(); // other services - instantiation and info - uno::Reference< uno::XInterface > SAL_CALL instantiateConfigRegistry - ( CreationContext const& rServiceManager ); + uno::Reference< uno::XInterface > SAL_CALL + instantiateConfigRegistry( CreationContext const& xContext ); const ServiceRegistrationInfo* getConfigurationRegistryServiceInfo(); +// bootstrap context support + uno::Reference<uno::XInterface> SAL_CALL + instantiateBootstrapContext( CreationContext const& xContext ); + + const SingletonRegistrationInfo * getBootstrapContextSingletonInfo(); + const ServiceRegistrationInfo * getBootstrapContextServiceInfo(); + namespace xml { uno::Reference< uno::XInterface > SAL_CALL instantiateSchemaParser - ( CreationContext const& rServiceManager ); + ( CreationContext const& xContext ); uno::Reference< uno::XInterface > SAL_CALL instantiateLayerParser - ( CreationContext const& rServiceManager ); + ( CreationContext const& xContext ); uno::Reference< uno::XInterface > SAL_CALL instantiateLayerWriter - ( CreationContext const& rServiceManager ); + ( CreationContext const& xContext ); const ServiceRegistrationInfo* getSchemaParserServiceInfo(); const ServiceRegistrationInfo* getLayerParserServiceInfo(); @@ -138,36 +137,55 @@ namespace configmgr } namespace backend { + uno::Reference<uno::XInterface> SAL_CALL + getDefaultBackendSingleton( CreationContext const& xContext ); + + uno::Reference<uno::XInterface> SAL_CALL + getDefaultSingleBackendSingleton( CreationContext const& xContext ); + + uno::Reference<uno::XInterface> SAL_CALL + instantiateDefaultBackend( CreationContext const& xContext ); + + uno::Reference<uno::XInterface> SAL_CALL + instantiateDefaultSingleBackend( CreationContext const& xContext ); + uno::Reference< uno::XInterface > SAL_CALL - instantiateUpdateMerger( CreationContext const& rServiceManager ); + instantiateUpdateMerger( CreationContext const& xContext ); uno::Reference<uno::XInterface> SAL_CALL - instantiateSingleBackendAdapter(const CreationContext& aServiceManager) ; + instantiateSingleBackendAdapter( CreationContext const& xContext ); uno::Reference< uno::XInterface > SAL_CALL - instantiateMergeImporter( CreationContext const& rServiceManager ); + instantiateMergeImporter( CreationContext const& xContext ); uno::Reference< uno::XInterface > SAL_CALL - instantiateCopyImporter( CreationContext const& rServiceManager ); + instantiateCopyImporter( CreationContext const& xContext ); + + const SingletonRegistrationInfo * getDefaultBackendSingletonInfo(); + const SingletonRegistrationInfo * getDefaultSingleBackendSingletonInfo(); + + const ServiceRegistrationInfo * getDefaultBackendServiceInfo(); + const ServiceRegistrationInfo * getDefaultSingleBackendServiceInfo(); const ServiceRegistrationInfo * getUpdateMergerServiceInfo(); - const ServiceRegistrationInfo * getSingleBackendAdapterServiceInfo() ; + const ServiceRegistrationInfo * getSingleBackendAdapterServiceInfo(); const ServiceRegistrationInfo * getMergeImportServiceInfo(); const ServiceRegistrationInfo * getCopyImportServiceInfo(); } - namespace localbe { + namespace localbe + { uno::Reference<uno::XInterface> SAL_CALL - instantiateLocalBackend(const CreationContext& aServiceManager) ; + instantiateLocalBackend( CreationContext const& xContext ); uno::Reference<uno::XInterface> SAL_CALL - instantiateLocalDataImporter(const CreationContext& aServiceManager) ; + instantiateLocalDataImporter( CreationContext const& xContext ); uno::Reference<uno::XInterface> SAL_CALL - instantiateLocalHierarchyBrowser(const CreationContext& aServiceManager) ; + instantiateLocalHierarchyBrowser( CreationContext const& xContext ); - const ServiceRegistrationInfo * getLocalBackendServiceInfo() ; - const ServiceRegistrationInfo * getLocalDataImportServiceInfo() ; - const ServiceRegistrationInfo * getLocalHierarchyBrowserServiceInfo() ; + const ServiceRegistrationInfo * getLocalBackendServiceInfo(); + const ServiceRegistrationInfo * getLocalDataImportServiceInfo(); + const ServiceRegistrationInfo * getLocalHierarchyBrowserServiceInfo(); } // localbe } // namespace configmgr diff --git a/configmgr/source/inc/confevents.hxx b/configmgr/source/inc/confevents.hxx index 3e4639c06ba6..089adcdfab32 100644 --- a/configmgr/source/inc/confevents.hxx +++ b/configmgr/source/inc/confevents.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confevents.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,11 @@ #ifndef CONFIGMGR_API_EVENTS_HXX_ #define CONFIGMGR_API_EVENTS_HXX_ -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_ +#include <salhelper/simplereferenceobject.hxx> +#endif +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> #endif namespace rtl { class OUString; } @@ -72,14 +75,14 @@ namespace configmgr { class Change; struct TreeChangeList; - class OOptions; + class RequestOptions; namespace memory { class Accessor; } namespace configuration { class AbsolutePath; } using configuration::AbsolutePath; struct IConfigBroadcaster; - struct IConfigListener : public virtual vos::OReference + struct IConfigListener : public virtual salhelper::SimpleReferenceObject { virtual void disposing(IConfigBroadcaster* pSource) = 0; }; @@ -88,7 +91,7 @@ namespace configmgr virtual void nodeChanged(memory::Accessor const& _aChangedDataAccessor, Change const& aChange, AbsolutePath const& aPath, IConfigBroadcaster* pSource) = 0; virtual void nodeDeleted(memory::Accessor const& _aChangedDataAccessor, AbsolutePath const& aPath, IConfigBroadcaster* pSource) = 0; }; - typedef vos::ORef<INodeListener> INodeListenerRef; + typedef rtl::Reference<INodeListener> INodeListenerRef; struct IConfigBroadcaster { @@ -96,8 +99,8 @@ namespace configmgr IConfigBroadcaster() {} ~IConfigBroadcaster() {} public: - virtual void addListener(AbsolutePath const& aPath, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener) = 0; - virtual void removeListener(const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener) = 0; + virtual void addListener(AbsolutePath const& aPath, const RequestOptions& _aOptions, INodeListenerRef const& pListener) = 0; + virtual void removeListener(const RequestOptions& _aOptions, INodeListenerRef const& pListener) = 0; }; @@ -108,13 +111,13 @@ namespace configmgr ConfigChangeBroadcaster(); virtual ~ConfigChangeBroadcaster(); - virtual void addListener(AbsolutePath const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener); - virtual void removeListener(const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener); + virtual void addListener(AbsolutePath const& aName, const RequestOptions& _aOptions, INodeListenerRef const& pListener); + virtual void removeListener(const RequestOptions& _aOptions, INodeListenerRef const& pListener); protected: virtual void fireChanges(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& _aChanges, sal_Bool _bError); protected: - virtual ConfigChangeBroadcastHelper* getBroadcastHelper(const vos::ORef < OOptions >& _xOptions, bool bCreate) = 0; + virtual ConfigChangeBroadcastHelper* getBroadcastHelper(const RequestOptions& _aOptions, bool bCreate) = 0; ConfigChangeBroadcastHelper* newBroadcastHelper(); // needed to implement the preceding void disposeBroadcastHelper(ConfigChangeBroadcastHelper* pHelper); // needed to discard the preceding }; diff --git a/configmgr/source/inc/configdefaultprovider.hxx b/configmgr/source/inc/configdefaultprovider.hxx index 469c4f4cd5c0..486229e2aecb 100644 --- a/configmgr/source/inc/configdefaultprovider.hxx +++ b/configmgr/source/inc/configdefaultprovider.hxx @@ -2,9 +2,9 @@ * * $RCSfile: configdefaultprovider.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:28:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,9 +73,6 @@ #ifndef _RTL_REF_HXX_ #include <rtl/ref.hxx> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif #ifndef INCLUDED_MEMORY #include <memory> @@ -88,7 +85,7 @@ namespace configmgr class ISubtree; class IConfigDefaultProvider; class IDefaultableTreeManager; - class OOptions; + class RequestOptions; namespace uno = com::sun::star::uno; //----------------------------------------------------------------------------- @@ -116,7 +113,7 @@ namespace configmgr // factory methods static DefaultProvider createEmpty(); static DefaultProvider create(Tree const& _aRootTree, - vos::ORef<OOptions> const& _xOptions, + RequestOptions const& _xOptions, rtl::Reference< IConfigDefaultProvider > const & _xDefaultProvider, IDefaultableTreeManager* _pDefaultableTree); diff --git a/configmgr/source/inc/configexcept.hxx b/configmgr/source/inc/configexcept.hxx index aef09b344769..8608fd8ac36d 100644 --- a/configmgr/source/inc/configexcept.hxx +++ b/configmgr/source/inc/configexcept.hxx @@ -2,9 +2,9 @@ * * $RCSfile: configexcept.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2000-11-07 14:40:31 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,14 +62,26 @@ #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #define CONFIGMGR_CONFIGEXCEPT_HXX_ -#include "apitypes.hxx" +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _RTL_STRING_HXX_ #include <rtl/string.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ #include <com/sun/star/uno/Exception.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ #include <com/sun/star/lang/IllegalArgumentException.hpp> +#endif namespace configmgr { +//------------------------------------------------------------------------- + namespace uno = ::com::sun::star::uno; + namespace lang = ::com::sun::star::lang; + using rtl::OUString; //----------------------------------------------------------------------------- namespace configuration { @@ -161,7 +173,7 @@ namespace configmgr OUString message() const; uno::Reference<uno::XInterface> context() const; - void illegalArgument(sal_Int16 nArgument = -1) throw(css::lang::IllegalArgumentException); + void illegalArgument(sal_Int16 nArgument = -1) throw(lang::IllegalArgumentException); void unhandled() throw(uno::RuntimeException); }; //------------------------------------------------------------------------- diff --git a/configmgr/source/inc/configgroup.hxx b/configmgr/source/inc/configgroup.hxx index 02bbf80b6a6b..7c028a35c84a 100644 --- a/configmgr/source/inc/configgroup.hxx +++ b/configmgr/source/inc/configgroup.hxx @@ -2,9 +2,9 @@ * * $RCSfile: configgroup.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jb $ $Date: 2002-08-13 13:33:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGGROUP_HXX_ #define CONFIGMGR_CONFIGGROUP_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif diff --git a/configmgr/source/inc/configpath.hxx b/configmgr/source/inc/configpath.hxx index 753aff7f7536..ff8c77cad5eb 100644 --- a/configmgr/source/inc/configpath.hxx +++ b/configmgr/source/inc/configpath.hxx @@ -2,9 +2,9 @@ * * $RCSfile: configpath.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2001-07-27 11:59:29 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,12 +62,8 @@ #ifndef CONFIGMGR_CONFIGPATH_HXX_ #define CONFIGMGR_CONFIGPATH_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif - -#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_ -#include "attributes.hxx" // used to be defined in this header +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> #endif #ifndef INCLUDED_VECTOR @@ -80,6 +76,8 @@ namespace configmgr namespace configuration { //------------------------------------------------------------------------ + using rtl::OUString; + //------------------------------------------------------------------------ /// A tag struct for disabling validity checking on arguments namespace argument { struct NoValidate {}; } diff --git a/configmgr/source/inc/configset.hxx b/configmgr/source/inc/configset.hxx index ed29e940ff3d..8f7319873228 100644 --- a/configmgr/source/inc/configset.hxx +++ b/configmgr/source/inc/configset.hxx @@ -2,9 +2,9 @@ * * $RCSfile: configset.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGSET_HXX_ #define CONFIGMGR_CONFIGSET_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif diff --git a/configmgr/source/inc/defaultprovider.hxx b/configmgr/source/inc/defaultprovider.hxx index 4d2df43f2790..e425ec044698 100644 --- a/configmgr/source/inc/defaultprovider.hxx +++ b/configmgr/source/inc/defaultprovider.hxx @@ -2,9 +2,9 @@ * * $RCSfile: defaultprovider.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:27:46 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,10 +69,6 @@ #include "utility.hxx" #endif -#ifndef CONFIGMGR_MISC_OPTIONS_HXX_ -#include <options.hxx> -#endif - #ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ #include <com/sun/star/uno/Exception.hpp> #endif @@ -80,10 +76,6 @@ #include <com/sun/star/uno/RuntimeException.hpp> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif - #ifndef INCLUDED_MEMORY #include <memory> #define INCLUDED_MEMORY @@ -108,7 +100,7 @@ namespace configmgr } //------------------------- class ISubtree; - + class RequestOptions; //========================================================================== //= IDefaultProvider //========================================================================== @@ -126,8 +118,8 @@ namespace configmgr <NULL/>if no default data is available for the tree */ virtual std::auto_ptr<ISubtree> requestDefaultData( configuration::AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) = 0; + const RequestOptions& _aOptions + ) CFG_UNO_THROW_ALL( ) = 0; }; //========================================================================== @@ -147,7 +139,7 @@ namespace configmgr public: /// get a data segment to host the given location - also available in ITreeManager virtual memory::Segment* getDataSegment(configuration::AbsolutePath const& _rAccessor, - const vos::ORef < OOptions >& _xOptions) = 0; + const RequestOptions& _aOptions) = 0; /** attempt to load default data into the tree named by a path using certain options and requiring a specific loading depth. @@ -158,8 +150,8 @@ namespace configmgr */ virtual sal_Bool fetchDefaultData( memory::UpdateAccessor& _aAccessToken, configuration::AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) = 0; + const RequestOptions& _xOptions + ) CFG_UNO_THROW_ALL( ) = 0; }; diff --git a/configmgr/source/inc/localizedtreeactions.hxx b/configmgr/source/inc/localizedtreeactions.hxx index 3e2c671f0229..b23978c6f413 100644 --- a/configmgr/source/inc/localizedtreeactions.hxx +++ b/configmgr/source/inc/localizedtreeactions.hxx @@ -2,9 +2,9 @@ * * $RCSfile: localizedtreeactions.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,7 +80,7 @@ class SubtreeChange; // convert to the given locale format, no matter what the original representation data::TreeSegment cloneForLocale(INode const* _pNode, OUString const& _sLocale); // convert to the given locale format, assuming the original representation was expanded -data::TreeSegment cloneExpandedForLocale(data::TreeAccessor const & _aTree, OUString const& _sLocale, bool bMakeWritable = false); +data::TreeSegment cloneExpandedForLocale(data::TreeAccessor const & _aTree, OUString const& _sLocale); // convert to the given locale format, assuming the original representation was expanded std::auto_ptr<INode> reduceExpandedForLocale(std::auto_ptr<ISubtree> _pNode, OUString const& _sLocale); diff --git a/configmgr/source/inc/mergeddataprovider.hxx b/configmgr/source/inc/mergeddataprovider.hxx index ba92e58dd256..ccafc13ed19d 100644 --- a/configmgr/source/inc/mergeddataprovider.hxx +++ b/configmgr/source/inc/mergeddataprovider.hxx @@ -2,9 +2,9 @@ * * $RCSfile: mergeddataprovider.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:29:37 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:18:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,6 +113,32 @@ namespace configmgr virtual ComponentResult getComponentData(ComponentRequest const & _aRequest) CFG_UNO_THROW_ALL() = 0; }; + +// --------------------------------------------------------------------------- + + /// Interface providing access to template (schema) data + struct SAL_NO_VTABLE ITemplateDataProvider + { + /** loads a given template and returns it as return value + + @param _aRequest + identifies the template to be loaded + + @returns + A valid instance of the given template. + + <p> Currently a request with empty template name + will retrieve a group node holding all templates + of a component. + </p> + + @throws com::sun::star::uno::Exception + if the template cannot be retrieved. + The exact exception being thrown may depend on the underlying backend. + */ + virtual TemplateResult getTemplateData(TemplateRequest const & _aRequest) + CFG_UNO_THROW_ALL() = 0; + }; // --------------------------------------------------------------------------- /** Interface providing access to (merged) data for individual nodes @@ -147,7 +173,9 @@ namespace configmgr if the node cannot be retrieved. The exact exception being thrown may depend on the underlying backend. */ - virtual ComponentResult getNodeData(ComponentRequest const & _aRequest, INodeDataListener * _pListener = NULL) + virtual ComponentResult getNodeData(ComponentRequest const & _aRequest, + ITemplateDataProvider* _aTemplateProvider, + INodeDataListener * _pListener = NULL) CFG_UNO_THROW_ALL() = 0; /** remove a listener registered for a previous request. @@ -198,31 +226,7 @@ namespace configmgr virtual NodeResult getDefaultData(NodeRequest const & _aRequest) CFG_UNO_THROW_ALL() = 0; }; -// --------------------------------------------------------------------------- - - /// Interface providing access to template (schema) data - struct SAL_NO_VTABLE ITemplateDataProvider - { - /** loads a given template and returns it as return value - - @param _aRequest - identifies the template to be loaded - - @returns - A valid instance of the given template. - <p> Currently a request with empty template name - will retrieve a group node holding all templates - of a component. - </p> - - @throws com::sun::star::uno::Exception - if the template cannot be retrieved. - The exact exception being thrown may depend on the underlying backend. - */ - virtual TemplateResult getTemplateData(TemplateRequest const & _aRequest) - CFG_UNO_THROW_ALL() = 0; - }; // --------------------------------------------------------------------------- /// Interface providing access to backend meta-data diff --git a/configmgr/source/inc/nodechange.hxx b/configmgr/source/inc/nodechange.hxx index 8235f03f406e..882b6509507c 100644 --- a/configmgr/source/inc/nodechange.hxx +++ b/configmgr/source/inc/nodechange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechange.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,7 +62,6 @@ #ifndef CONFIGMGR_CONFIGCHANGE_HXX_ #define CONFIGMGR_CONFIGCHANGE_HXX_ -#include "apitypes.hxx" #include "configexcept.hxx" #include <vector> @@ -159,7 +158,7 @@ namespace configmgr */ class NodeChanges { - typedef vector<NodeChange> ChangesList; + typedef std::vector<NodeChange> ChangesList; public: typedef ChangesList::const_iterator Iterator; typedef ChangesList::iterator MutatingIterator; diff --git a/configmgr/source/inc/nodechangeinfo.hxx b/configmgr/source/inc/nodechangeinfo.hxx index 974519061eba..ba72f71a4493 100644 --- a/configmgr/source/inc/nodechangeinfo.hxx +++ b/configmgr/source/inc/nodechangeinfo.hxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechangeinfo.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_ #define CONFIGMGR_CONFIGCHANGEINFO_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGPATH_HXX_ #include "configpath.hxx" #endif diff --git a/configmgr/source/inc/noderef.hxx b/configmgr/source/inc/noderef.hxx index 10b671124b99..211a7273d92b 100644 --- a/configmgr/source/inc/noderef.hxx +++ b/configmgr/source/inc/noderef.hxx @@ -2,9 +2,9 @@ * * $RCSfile: noderef.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGNODE_HXX_ #define CONFIGMGR_CONFIGNODE_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif @@ -87,6 +84,7 @@ namespace configmgr namespace data { using memory::Accessor; class TreeAccessor; } namespace view { class ViewTreeAccess; } namespace configapi { class Factory; } + namespace node { struct Attributes; } namespace configuration { //------------------------------------------------------------------------- @@ -95,8 +93,6 @@ namespace configmgr class RelativePath; namespace Path { class Component; } - struct Attributes; - class NodeChange; class NodeChanges; class NodeChangesTree; @@ -246,6 +242,7 @@ namespace configmgr */ class Tree { + typedef node::Attributes NodeAttributes; public: /// create a tree with a given implementation Tree(data::Accessor const& _accessor, TreeImpl* pImpl); @@ -359,13 +356,13 @@ namespace configmgr Name getName(ValueRef const& aValue) const; /// return the <type>Attributes</type> of node <var>aNode</var> in this tree - Attributes getAttributes(NodeRef const& aNode) const; + NodeAttributes getAttributes(NodeRef const& aNode) const; /// return the <type>Attributes</type> of node <var>aNode</var> in this tree - Attributes getAttributes(AnyNodeRef const& aNode) const; + NodeAttributes getAttributes(AnyNodeRef const& aNode) const; /// return the <type>Attributes</type> of value <var>aValue</var> in this tree - Attributes getAttributes(ValueRef const& aValue) const; + NodeAttributes getAttributes(ValueRef const& aValue) const; /// get the Uno <type scope='com::sun::star::uno'>Type</type> of value <var>aValue</var> in this tree UnoType getUnoType(ValueRef const& aValue) const; diff --git a/configmgr/source/inc/options.hxx b/configmgr/source/inc/options.hxx index a1c634f12075..4ab4abc3aa20 100644 --- a/configmgr/source/inc/options.hxx +++ b/configmgr/source/inc/options.hxx @@ -2,9 +2,9 @@ * * $RCSfile: options.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: jb $ $Date: 2002-03-28 09:00:39 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -95,87 +95,45 @@ namespace configmgr class OOptions : public salhelper::SimpleReferenceObject { RequestOptions m_aRequestOptions; // current options to use - RequestOptions m_aDefaultOptions; // default options used as base - bool m_bLazyWrite; // true, if tree use lazy writing - bool m_bForceWritable; // true, if write-protection should be ignored public: typedef RequestOptions::Locale Locale; typedef RequestOptions::Entity Entity; OOptions() : m_aRequestOptions() - , m_aDefaultOptions() - , m_bLazyWrite(true) - , m_bForceWritable(false) {} explicit OOptions(const RequestOptions& _aDefaultOptions) - : m_aRequestOptions(_aDefaultOptions, true) - , m_aDefaultOptions(_aDefaultOptions) - , m_bLazyWrite(true) - , m_bForceWritable(false) + : m_aRequestOptions(_aDefaultOptions) { } - OOptions(const OOptions& _rOptions) - : m_aRequestOptions(_rOptions.m_aRequestOptions, true) - , m_aDefaultOptions(_rOptions.m_aDefaultOptions) - , m_bLazyWrite(_rOptions.m_bLazyWrite) - , m_bForceWritable(_rOptions.m_bForceWritable) + OOptions(const OOptions& _aOtherOptions) + : m_aRequestOptions(_aOtherOptions.m_aRequestOptions) { } bool isForSessionUser() const { return ! m_aRequestOptions.hasEntity(); } - bool canUseCache() const { return ! m_aRequestOptions.isForcingReload(); } - bool getLazyWrite() const { return m_bLazyWrite; } - bool isForcingWritable() const { return m_bForceWritable; } Locale getLocale() const { return m_aRequestOptions.getLocale(); } Entity getUser() const { return m_aRequestOptions.getEntity(); } - Locale getDefaultLocale() const { return m_aDefaultOptions.getLocale(); } - Entity getDefaultUser() const { return m_aDefaultOptions.getEntity(); } - RequestOptions const & getRequestOptions() const { return m_aRequestOptions; } - void setNoCache(bool _bNoCache = true) - { m_aRequestOptions.forceReload(_bNoCache); } - void setUser(const Entity & _rUser) { m_aRequestOptions.setEntity(_rUser); } - void setDefaultUser(const Entity & _rUser) - { - m_aDefaultOptions.setEntity(_rUser); - if (!m_aRequestOptions.hasEntity()) - m_aRequestOptions.setEntity(_rUser); - } - void setLocale(const Locale & _rLocale) { m_aRequestOptions.setLocale(_rLocale); } - void setDefaultLocale(const Locale & _rLocale) - { - m_aDefaultOptions.setLocale(_rLocale); - if (!m_aRequestOptions.hasLocale()) - m_aRequestOptions.setLocale(_rLocale); - } - void setMultiLocaleMode() { m_aRequestOptions.setAllLocales(); } - void setMultiLocaleDefault() - { - m_aDefaultOptions.setAllLocales(); - if (!m_aRequestOptions.hasLocale()) - m_aRequestOptions.setAllLocales(); - } - - void setLazyWrite(bool _bLazyWrite) { m_bLazyWrite = _bLazyWrite; } - void setForceWritable(bool _bForce) { m_bForceWritable = _bForce; } + void enableAsync(bool _bEnable) + { m_aRequestOptions.enableAsync(_bEnable); } }; typedef vos::ORef<OOptions> OptionsRef; diff --git a/configmgr/source/inc/request.hxx b/configmgr/source/inc/request.hxx index 07aaa25683a2..bd70eb99eca0 100644 --- a/configmgr/source/inc/request.hxx +++ b/configmgr/source/inc/request.hxx @@ -2,9 +2,9 @@ * * $RCSfile: request.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:59:14 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,18 +102,20 @@ namespace configmgr { Name m_aComponentName; RequestOptions m_aOptions; - + bool m_bForcedReload; public: ComponentRequest(Name const& _aComponentName, RequestOptions const & _aOptions) : m_aComponentName(_aComponentName) , m_aOptions(_aOptions) + , m_bForcedReload(false) { } Name const & getComponentName() const { return m_aComponentName; } RequestOptions const & getOptions() const { return m_aOptions; } - void forceReload() { m_aOptions.forceReload(); } + bool isForcingReload() const { return m_bForcedReload; } + void forceReload(bool _bForce = true) { m_bForcedReload = _bForce; } }; // --------------------------------------------------------------------------- @@ -154,14 +156,12 @@ namespace configmgr ConstUpdateInstance m_aUpdate; RequestOptions m_aOptions; RequestId m_aRQID; - bool m_bForceFlush; public: explicit UpdateRequest( UpdateInstance const & _aUpdate, RequestOptions const & _aOptions) : m_aUpdate(_aUpdate) , m_aOptions(_aOptions) - , m_bForceFlush( _aOptions.isForcingReload() ) {} explicit @@ -169,7 +169,6 @@ namespace configmgr RequestOptions const & _aOptions) : m_aUpdate(_aUpdate) , m_aOptions(_aOptions) - , m_bForceFlush( _aOptions.isForcingReload() ) {} explicit @@ -178,12 +177,9 @@ namespace configmgr RequestOptions const & _aOptions) : m_aUpdate(_aUpdateData, _aRootpath) , m_aOptions(_aOptions) - , m_bForceFlush( _aOptions.isForcingReload() ) {} - void forceFlush() { m_bForceFlush = true; } - - bool isForcingFlush() const { return m_bForceFlush; } + bool isSyncRequired() const { return !m_aOptions.isAsyncEnabled(); } RequestOptions const & getOptions() const { return m_aOptions; } NodePath const & getUpdateRoot() const { return m_aUpdate.root(); } diff --git a/configmgr/source/inc/requestoptions.hxx b/configmgr/source/inc/requestoptions.hxx index f7a24eb0808d..0c56e113c474 100644 --- a/configmgr/source/inc/requestoptions.hxx +++ b/configmgr/source/inc/requestoptions.hxx @@ -2,9 +2,9 @@ * * $RCSfile: requestoptions.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:59:45 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,29 +86,11 @@ namespace configmgr RequestOptions() : m_sLocale() , m_sEntity() - , m_nCacheID(0) + , m_bEnableAsync(false) {} - /// Copy constructor. Copies all options (optionally copying or renewing the cache ID) - RequestOptions(const RequestOptions& _aOther, bool _bRenewCacheID = false) - : m_sLocale(_aOther.m_sLocale) - , m_sEntity(_aOther.m_sEntity) - { - if (_bRenewCacheID) - { - m_nCacheID = 0; - this->forceReload(_aOther.isForcingReload()); - } - else - { - m_nCacheID = _aOther.m_nCacheID; - } - } - - /// @returns <TRUE/>, if data must be loaded freshly into a private cache line - bool isForcingReload() const { return m_nCacheID != 0; } - /// @returns an ID number identifying the private cache line to use - sal_Int32 getCacheID() const { return m_nCacheID; } + /// @returns <TRUE/>, if data can be written asynchronously + bool isAsyncEnabled() const { return m_bEnableAsync; } /** @returns <TRUE/>, if a locale is specified, <BR/> @@ -140,8 +122,8 @@ namespace configmgr /// resets the locale to get data for to use the default void clearLocale() { m_sLocale = rtl::OUString(); } - /// forces data to be freshly loaded into a new private cache line - void forceReload(bool _bNoCache = true); + /// marks asyncronous access a enabled or disabled + void enableAsync(bool _bEnable = true) { m_bEnableAsync = _bEnable; } // comparison/container helpers /// return a hash code for this object @@ -151,7 +133,7 @@ namespace configmgr private: Locale m_sLocale; /// locale to fetch data for Entity m_sEntity; /// user/group/role to fetch data for - sal_Int32 m_nCacheID; /// nonzero, if data should not be fetched from the cache, but reloaded + bool m_bEnableAsync; /// true, if data may be }; // --------------------------------------------------------------------------- diff --git a/configmgr/source/inc/requesttypes.hxx b/configmgr/source/inc/requesttypes.hxx index 8e6e39bcbb36..f9cb5699f241 100644 --- a/configmgr/source/inc/requesttypes.hxx +++ b/configmgr/source/inc/requesttypes.hxx @@ -2,9 +2,9 @@ * * $RCSfile: requesttypes.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: ssmith $ $Date: 2002-12-16 12:46:37 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,10 @@ #include "configpath.hxx" #endif +#ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_ +#include <salhelper/simplereferenceobject.hxx> +#endif + #ifndef INCLUDED_MEMORY #include <memory> #define INCLUDED_MEMORY diff --git a/configmgr/source/inc/roottree.hxx b/configmgr/source/inc/roottree.hxx index f9bb7478d57a..17af944dd51c 100644 --- a/configmgr/source/inc/roottree.hxx +++ b/configmgr/source/inc/roottree.hxx @@ -2,9 +2,9 @@ * * $RCSfile: roottree.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,8 @@ #ifndef CONFIGMGR_ROOTTREE_HXX_ #define CONFIGMGR_ROOTTREE_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" // for NotCopyable ... +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" #endif #ifndef INCLUDED_MEMORY @@ -120,7 +120,7 @@ namespace configmgr TemplateProvider const& aTemplateProvider); //----------------------------------------------------------------------------- - class CommitHelper : NotCopyable + class CommitHelper : Noncopyable { struct Data; diff --git a/configmgr/source/inc/serviceinfohelper.hxx b/configmgr/source/inc/serviceinfohelper.hxx index 622579b63409..6fe4926438ca 100644 --- a/configmgr/source/inc/serviceinfohelper.hxx +++ b/configmgr/source/inc/serviceinfohelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: serviceinfohelper.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:07:49 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,7 +114,9 @@ namespace configmgr { /// The name of this singleton AsciiServiceName singletonName; - /// The implementation, which should be instatiated for this singleton + /// The implementation, which owns this singleton + AsciiServiceName implementationName; + /// The service, which should be instatiated for this singleton AsciiServiceName instantiatedServiceName; /// A name for a pseudo-implementation, which is mapped to this singleton ServiceRegistrationInfo const * mappedImplementation; diff --git a/configmgr/source/inc/strdecl.hxx b/configmgr/source/inc/strdecl.hxx index b49a6f3e9d4b..17a7fd249473 100644 --- a/configmgr/source/inc/strdecl.hxx +++ b/configmgr/source/inc/strdecl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: strdecl.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2001-11-14 16:53:25 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,34 +70,10 @@ namespace configmgr { //......................................................................... -// extern declaration for predefined strings, uncompleted - // tag names - // <name>...</name> - DECLARE_CONSTASCII_USTRING(TAG_VALUE); - - DECLARE_CONSTASCII_USTRING(ATTR_NAME); - DECLARE_CONSTASCII_USTRING(ATTR_PACKAGE); - DECLARE_CONSTASCII_USTRING(ATTR_TYPE); - DECLARE_CONSTASCII_USTRING(ATTR_TYPE_MODIFIER); - DECLARE_CONSTASCII_USTRING(ATTR_INSTANCE); - DECLARE_CONSTASCII_USTRING(ATTR_MODULE); - DECLARE_CONSTASCII_USTRING(ATTR_ENCODING); - DECLARE_CONSTASCII_USTRING(ATTR_SEPARATOR); - DECLARE_CONSTASCII_USTRING(ATTR_NULL); - DECLARE_CONSTASCII_USTRING(ATTR_LANG); - DECLARE_CONSTASCII_USTRING(ATTR_LOCALIZE); - DECLARE_CONSTASCII_USTRING(ATTR_NULLABLE); - DECLARE_CONSTASCII_USTRING(ATTR_WRITABLE); - DECLARE_CONSTASCII_USTRING(ATTR_FINALIZE); - DECLARE_CONSTASCII_USTRING(ATTR_STATE); - - // boolean constants - DECLARE_CONSTASCII_USTRING(ATTR_VALUE_TRUE); - DECLARE_CONSTASCII_USTRING(ATTR_VALUE_FALSE); +// extern declaration for predefined strings // simple types names DECLARE_CONSTASCII_USTRING(TYPE_BOOLEAN); - DECLARE_CONSTASCII_USTRING(TYPE_BYTE); DECLARE_CONSTASCII_USTRING(TYPE_SHORT); DECLARE_CONSTASCII_USTRING(TYPE_INT); DECLARE_CONSTASCII_USTRING(TYPE_LONG); @@ -107,24 +83,6 @@ namespace configmgr DECLARE_CONSTASCII_USTRING(TYPE_BINARY); // Universal type: Any DECLARE_CONSTASCII_USTRING(TYPE_ANY); - // special non-value types - DECLARE_CONSTASCII_USTRING(TYPE_SET); - DECLARE_CONSTASCII_USTRING(TYPE_GROUP); - - // type modifier values - DECLARE_CONSTASCII_USTRING(TYPE_MODIFIER_LIST); - - // States for update actions - DECLARE_CONSTASCII_USTRING(STATE_MODIFIED); - DECLARE_CONSTASCII_USTRING(STATE_REPLACED); - DECLARE_CONSTASCII_USTRING(STATE_DELETED); - DECLARE_CONSTASCII_USTRING(STATE_DEFAULT); - - // the encoding for binary values - DECLARE_CONSTASCII_USTRING(ENCODING_HEX); - DECLARE_CONSTASCII_USTRING(ENCODING_BASE64); - - DECLARE_CONSTASCII_USTRING(XML_CDATA); // special template names for native/localized value types DECLARE_CONSTASCII_USTRING(TEMPLATE_MODULE_NATIVE_PREFIX); @@ -133,33 +91,6 @@ namespace configmgr DECLARE_CONSTASCII_USTRING(TEMPLATE_LIST_SUFFIX); - // the default separator for strings - DECLARE_CONSTASCII_USTRING(DEFAULT_SEPARATOR); - - // specials for im-/export - DECLARE_CONSTASCII_USTRING(TAG_DATA); - DECLARE_CONSTASCII_USTRING(ATTR_PATH); - - // Parameter (?) - DECLARE_CONSTASCII_USTRING(PARAM_OBJECT); - DECLARE_CONSTASCII_USTRING(PARAM_NAME); - DECLARE_CONSTASCII_USTRING(PARAM_ISNEWOBJECT); - DECLARE_CONSTASCII_USTRING(PARAM_GROUP); - - // Properties - DECLARE_CONSTASCII_USTRING(PROP_MEMBEROF); - - // node constants - DECLARE_CONSTASCII_USTRING(NODE_TOPLEVEL); - DECLARE_CONSTASCII_USTRING(NODE_USERPROFILE); - DECLARE_CONSTASCII_USTRING(NODE_USERPROFILE_GROUP_PATH); - DECLARE_CONSTASCII_USTRING(NODE_USERPROFILE_GROUP_FIELD); - DECLARE_CONSTASCII_USTRING(NODE_USERPROFILE_DEFAULTGROUP); - DECLARE_CONSTASCII_USTRING(NODE_USERPROFILE_GROUPLIST); - DECLARE_CONSTASCII_USTRING(NODE_USERPROFILE_USERLIST); - DECLARE_CONSTASCII_USTRING(NODE_USERTEMPLATE_MODULE); - DECLARE_CONSTASCII_USTRING(NODE_USERTEMPLATE_NAME); - } // namespace configmgr #endif diff --git a/configmgr/source/inc/template.hxx b/configmgr/source/inc/template.hxx index 824c1d23d23e..da9803ea9b90 100644 --- a/configmgr/source/inc/template.hxx +++ b/configmgr/source/inc/template.hxx @@ -2,9 +2,9 @@ * * $RCSfile: template.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:28:32 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGTEMPLATE_HXX_ #define CONFIGMGR_CONFIGTEMPLATE_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif @@ -83,15 +80,11 @@ #include <salhelper/simplereferenceobject.hxx> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif - namespace configmgr { //----------------------------------------------------------------------------- struct IConfigTemplateManager; - class OOptions; + class RequestOptions; //----------------------------------------------------------------------------- namespace data { class SetNodeAccess; } //----------------------------------------------------------------------------- @@ -119,7 +112,7 @@ namespace configmgr typedef rtl::Reference< IConfigTemplateManager > TemplateManagerRef; public: TemplateProvider(); // creates an empty (invalid) template instance provider - TemplateProvider(TemplateManagerRef const & xProvider, vos::ORef< OOptions > const& xOptions); + TemplateProvider(TemplateManagerRef const & xProvider, RequestOptions const& xOptions); TemplateProvider(TemplateProvider const& aOther); TemplateProvider& operator=(TemplateProvider const& aOther); ~TemplateProvider(); diff --git a/configmgr/source/inc/tracer.hxx b/configmgr/source/inc/tracer.hxx index 524fa406cdcc..15d35dba1a30 100644 --- a/configmgr/source/inc/tracer.hxx +++ b/configmgr/source/inc/tracer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: tracer.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kz $ $Date: 2001-03-13 15:27:02 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -167,37 +167,3 @@ public: #endif // _CONFIGMGR_TRACER_HXX_ -//************************************************************************** -// history: -// $Log: not supported by cvs2svn $ -// Revision 1.3 2001/03/11 02:16:12 pluby -// Replaced ftime() calls with gettimeofday() since ftime() is obsolete on Linux and Mac OS X -// -// Revision 1.2 2001/02/13 09:47:14 dg -// #83239# timing output -// -// Revision 1.1.1.1 2000/09/18 16:13:41 hr -// initial import -// -// Revision 1.6 2000/09/15 09:51:50 willem.vandorp -// OpenOffice header added -// -// Revision 1.5 2000/08/30 10:00:40 fs -// getTimeStamp -// -// Revision 1.4 2000/08/20 12:52:14 fs -// #77860# introduced an impl class; introduces virtual trace devices -// -// Revision 1.3 2000/08/10 11:37:30 hjs -// filled defines with correct dummies -// -// Revision 1.2 2000/08/10 06:53:08 fs -// m_bInitialized -// -// Revision 1.1 2000/08/09 18:53:41 fs -// helper classes for tracing -// -// -// Revision 1.0 09.08.00 13:10:04 fs -//************************************************************************** - diff --git a/configmgr/source/inc/treeactions.hxx b/configmgr/source/inc/treeactions.hxx index 86637825585e..9bd0149a41be 100644 --- a/configmgr/source/inc/treeactions.hxx +++ b/configmgr/source/inc/treeactions.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treeactions.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,6 +66,11 @@ #include "change.hxx" #endif +#ifndef INCLUDED_VECTOR +#include <vector> +#define INCLUDED_VECTOR +#endif + //.......................................................................... namespace configmgr { diff --git a/configmgr/source/inc/treechangefactory.hxx b/configmgr/source/inc/treechangefactory.hxx index b786c807ca55..5f843c35b192 100644 --- a/configmgr/source/inc/treechangefactory.hxx +++ b/configmgr/source/inc/treechangefactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treechangefactory.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,7 +90,7 @@ namespace configmgr //= ValueChanges ============================================================ std::auto_ptr<ValueChange> createValueChange( Name const& _aName, - configuration::Attributes _aAttrs, + node::Attributes _aAttrs, ValueChange::Mode _eMode, uno::Any const& _aNewValue, uno::Any const& _aOldValue = uno::Any() @@ -117,7 +117,7 @@ namespace configmgr //= SubtreeChanges ============================================================ std::auto_ptr<SubtreeChange> createGroupNodeChange( Name const& _aName, - configuration::Attributes _aAttrs, + node::Attributes _aAttrs, bool _bToDefault = false); //----------------------------------------------- @@ -125,7 +125,7 @@ namespace configmgr Name const& _aName, Name const& _aTemplateName, Name const& _aTemplateModule, - configuration::Attributes _aAttrs, + node::Attributes _aAttrs, bool _bToDefault = false); //----------------------------------------------- diff --git a/configmgr/source/inc/treechangelist.hxx b/configmgr/source/inc/treechangelist.hxx index 5424a66b284a..55ed9d5248a1 100644 --- a/configmgr/source/inc/treechangelist.hxx +++ b/configmgr/source/inc/treechangelist.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treechangelist.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,11 +74,8 @@ #ifndef CONFIGMGR_CONFIGPATH_HXX_ #include "configpath.hxx" #endif -#ifndef CONFIGMGR_MISC_OPTIONS_HXX_ -#include <options.hxx> -#endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_ +#include "requestoptions.hxx" #endif namespace configmgr @@ -93,13 +90,13 @@ namespace configmgr { typedef configuration::AbsolutePath AbsolutePath; typedef configuration::Name Name; - typedef configuration::Attributes NodeAttributes; + typedef node::Attributes NodeAttributes; - TreeChangeList(const vos::ORef < OOptions >& _xOptions, + TreeChangeList(const RequestOptions& _aOptions, const AbsolutePath& _rRootPath, const SubtreeChange& _aSubtree, SubtreeChange::DeepChildCopy _doDeepCopy) - : m_xOptions(_xOptions), + : m_aOptions(_aOptions), m_aLocation(_rRootPath), root(_aSubtree,_doDeepCopy) {} @@ -107,10 +104,10 @@ namespace configmgr /** ctor @param _rRootPath path to the root of the whole to-be-updated subtree */ - TreeChangeList( const vos::ORef < OOptions >& _xOptions, + TreeChangeList( const RequestOptions& _aOptions, const AbsolutePath& _rRootPath, const NodeAttributes& _rAttr = NodeAttributes()) - : m_xOptions(_xOptions) + : m_aOptions(_aOptions) , m_aLocation(_rRootPath) , root(_rRootPath.getLocalName().getName().toString(), _rAttr) {} @@ -118,35 +115,21 @@ namespace configmgr /** ctor @param _rLocalName relative path within the to-be-updated subtree */ - TreeChangeList( const vos::ORef < OOptions >& _xOptions, + TreeChangeList( const RequestOptions& _aOptions, const AbsolutePath& _rRootPath, const Name& _rChildTemplateName, const Name& _rChildTemplateModule, const NodeAttributes& _rAttr = NodeAttributes()) - : m_xOptions(_xOptions) + : m_aOptions(_aOptions) , m_aLocation(_rRootPath) , root(_rRootPath.getLocalName().getName().toString(), _rChildTemplateName.toString(), _rChildTemplateModule.toString(), _rAttr) {} /** ctor - @param _rPathToRoot path to the root of the whole to-be-updated subtree - @param _rLocalName relative path within the to-be-updated subtree - TreeChangeList( const vos::ORef < OOptions >& _xOptions, - const AbsolutePath& _rRootPath, - const ISubtree& _rTree) - : m_xOptions(_xOptions) - , m_aLocation(_rRootPath) - , root(_rTree) - { - OSL_ENSURE(false, "Test only, because deep copy of subtreechange is very expensive."); - } - */ - - /** ctor @param _rTreeList list to initialize the path, no childs are copied */ TreeChangeList( const TreeChangeList& _rTree, SubtreeChange::NoChildCopy _rNoCopy) - : m_xOptions(_rTree.m_xOptions) + : m_aOptions(_rTree.m_aOptions) , m_aLocation(_rTree.m_aLocation) , root(_rTree.root, _rNoCopy) {} @@ -167,13 +150,13 @@ namespace configmgr /// get the full path to the root (location) AbsolutePath getRootContextPath() const { return m_aLocation.getParentPath(); } - vos::ORef < OOptions > getOptions() const { return m_xOptions; } + RequestOptions const & getOptions() const { return m_aOptions; } public: SubtreeChange root; // the root of the whole tree of updates private: AbsolutePath m_aLocation; // absolute path to the parent of the node corresponding to this->root - vos::ORef < OOptions > m_xOptions; // options for the tree that is concerned by these changes + RequestOptions m_aOptions; // options for the tree that is concerned by these changes }; //---------------------------------------------------------------------------- diff --git a/configmgr/source/inc/treemanager.hxx b/configmgr/source/inc/treemanager.hxx index f1b6024477af..f5c2613bc529 100644 --- a/configmgr/source/inc/treemanager.hxx +++ b/configmgr/source/inc/treemanager.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treemanager.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:30:52 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -137,7 +137,8 @@ namespace configmgr memory::HeapManager & getCacheHeapManager() const; // ITreeManager - virtual memory::Segment* getDataSegment(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions); + virtual memory::Segment* getDataSegment(AbsolutePath const& _rAccessor, + RequestOptions const& _aOptions); /** requests a node given by it's path. Basicly, this means that the node is fetch from the cache when it contains it else it ask the server @@ -147,32 +148,33 @@ namespace configmgr should be loaded */ virtual data::NodeAccess requestSubtree(AbsolutePath const& _rSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 _nMinLevels = ALL_LEVELS) CFG_UNO_THROW_ALL( ); + RequestOptions const& _aOptions + ) CFG_UNO_THROW_ALL( ); virtual void updateTree(memory::UpdateAccessor& _aAccessToken, TreeChangeList& aChanges) CFG_UNO_THROW_ALL( ); - virtual void saveAndNotifyUpdate(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& aChanges) CFG_UNO_THROW_ALL( ); + virtual void saveAndNotifyUpdate(memory::Accessor const& _aChangedDataAccessor, + TreeChangeList const& aChanges) CFG_UNO_THROW_ALL( ); virtual void releaseSubtree(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions ) CFG_NOTHROW(); + RequestOptions const& _aOptions ) CFG_NOTHROW(); - virtual void disposeData(const vos::ORef < OOptions >& _xOptions) CFG_NOTHROW(); + virtual void disposeData(const RequestOptions& _aOptions) CFG_NOTHROW(); virtual void fetchSubtree( AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels = ALL_LEVELS) CFG_NOTHROW(); + RequestOptions const& _xOptions + ) CFG_NOTHROW(); // IDefaultableTreeManager virtual sal_Bool fetchDefaultData( memory::UpdateAccessor& _aAccessToken, AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ); + RequestOptions const& _aOptions + ) CFG_UNO_THROW_ALL( ); // IDefaultProvider virtual std::auto_ptr<ISubtree> requestDefaultData(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ); + const RequestOptions& _aOptions + ) CFG_UNO_THROW_ALL( ); // ITemplateManager virtual data::TreeAccessor requestTemplate( memory::Accessor const& _aAccessor, Name const& aName, Name const& aModule @@ -183,7 +185,7 @@ namespace configmgr // implementation interfaces void refreshSubtree(const AbsolutePath &_aAbsoluteSubtreePath, - const vos::ORef<OOptions>& _aOptions) CFG_UNO_THROW_ALL( ); + const RequestOptions& _aOptions) CFG_UNO_THROW_ALL( ); private: CacheData & getTemplates() { return * m_aTemplates.get(); } @@ -202,7 +204,7 @@ namespace configmgr void implDisposeOne(CacheRef const & _aCache, RequestOptions const & _aOptions); // ConfigChangeBroadcaster - virtual ConfigChangeBroadcastHelper* getBroadcastHelper(vos::ORef<OOptions> const& _xOptions, bool bCreate); + virtual ConfigChangeBroadcastHelper* getBroadcastHelper(RequestOptions const& _aOptions, bool bCreate); // former INotifyListener void nodeUpdated(TreeChangeList& _rChanges); diff --git a/configmgr/source/inc/treenodefactory.hxx b/configmgr/source/inc/treenodefactory.hxx index 6116016b10a9..a917ce5713bb 100644 --- a/configmgr/source/inc/treenodefactory.hxx +++ b/configmgr/source/inc/treenodefactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treenodefactory.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2001-07-16 17:01:35 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,32 +91,32 @@ namespace configmgr std::auto_ptr<ValueNode> createValueNode( rtl::OUString const& aName, uno::Any const& aValue, - configuration::Attributes _aAttrs); + node::Attributes _aAttrs); //----------------------------------------------- std::auto_ptr<ValueNode> createValueNode( rtl::OUString const& aName, uno::Any const& aValue, uno::Any const& aDefault, - configuration::Attributes _aAttrs); + node::Attributes _aAttrs); //----------------------------------------------- std::auto_ptr<ValueNode> createNullValueNode( rtl::OUString const& aName, uno::Type const& aType, - configuration::Attributes _aAttrs); + node::Attributes _aAttrs); //= ISubtree ============================================================ std::auto_ptr<ISubtree> createGroupNode( rtl::OUString const& aName, - configuration::Attributes _aAttrs); + node::Attributes _aAttrs); //----------------------------------------------- std::auto_ptr<ISubtree> createSetNode( rtl::OUString const& aName, rtl::OUString const& _rTemplateName, rtl::OUString const& _rTemplateModule, - configuration::Attributes _aAttrs); + node::Attributes _aAttrs); //----------------------------------------------- //= special case: Dummy ISubtree ============================================================ diff --git a/configmgr/source/inc/treeprovider.hxx b/configmgr/source/inc/treeprovider.hxx index 71d288a86ce8..a78febe3a716 100644 --- a/configmgr/source/inc/treeprovider.hxx +++ b/configmgr/source/inc/treeprovider.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treeprovider.hxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:27:46 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,9 +72,6 @@ #ifndef _CONFIGMGR_TREE_VALUENODE_HXX #include "valuenode.hxx" #endif -#ifndef CONFIGMGR_MISC_OPTIONS_HXX_ -#include <options.hxx> -#endif #ifndef CONFIGMGR_UTILITY_HXX_ #include "utility.hxx" #endif @@ -86,10 +83,6 @@ #include <com/sun/star/uno/RuntimeException.hpp> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif - #ifndef INCLUDED_MEMORY #include <memory> #define INCLUDED_MEMORY @@ -125,41 +118,21 @@ namespace configmgr class ISubtree; struct TreeChangeList; - //========================================================================== - //= ITreeProvider - //========================================================================== - struct SAL_NO_VTABLE ITreeProvider - { - typedef configuration::AbsolutePath AbsolutePath; - - enum { ALL_LEVELS = -1 }; - - /// load the tree named by a path using certain options and requiring a specific loading depth - return it yielding ownership - virtual std::auto_ptr<ISubtree> loadSubtree(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels = ALL_LEVELS) CFG_UNO_THROW_ALL( ) = 0; - - /// update the stored data according to a changes list - virtual void updateTree(TreeChangeList& aChanges) CFG_UNO_THROW_ALL( ) = 0; - - }; + class RequestOptions; //========================================================================== //= ITreeManager //========================================================================== - // a ITreeProvider which can notify changes that were done, and manages the lifetime of subtrees + // a TreeProvider which can notify changes that were done, and manages the lifetime of subtrees class SAL_NO_VTABLE ITreeManager { public: typedef configuration::AbsolutePath AbsolutePath; - enum { ALL_LEVELS = ITreeProvider::ALL_LEVELS }; - - /// get a data segment to host the given location virtual memory::Segment* getDataSegment( AbsolutePath const& _rAccessor, - const vos::ORef < OOptions >& _xOptions) = 0; + const RequestOptions& _aOptions) = 0; /** request that the tree named by a path is added to the collection of managed trees respecting certain options and requiring a specific loading depth. @@ -167,15 +140,13 @@ namespace configmgr The reference must later be released by calling releaseSubtree with the same path and options. */ virtual data::NodeAccess requestSubtree(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels = ALL_LEVELS) CFG_UNO_THROW_ALL( ) = 0; + const RequestOptions& _aOptions) CFG_UNO_THROW_ALL( ) = 0; /** request that the tree named by a path is added to the collection of managed trees respecting certain options and requiring a specific loading depth. */ virtual void fetchSubtree(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels = ALL_LEVELS) CFG_NOTHROW() = 0; + const RequestOptions& _aOptions) CFG_NOTHROW() = 0; /// update the managed data according to a changes list - update the changes list accordingly with old values virtual void updateTree(memory::UpdateAccessor& _aAccessToken, TreeChangeList& aChanges) CFG_UNO_THROW_ALL( ) = 0; @@ -185,13 +156,13 @@ namespace configmgr // bookkeeping support virtual void releaseSubtree(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions ) CFG_NOTHROW() = 0; + const RequestOptions& _aOptions ) CFG_NOTHROW() = 0; /** data for the given options may not be used any more <p>all clients of such data must be disposed</p> <p>If the locale is not set, the whole user has become invalid</p> */ - virtual void disposeData(const vos::ORef < OOptions >& _xOptions) CFG_NOTHROW() = 0; + virtual void disposeData(const RequestOptions& _aOptions) CFG_NOTHROW() = 0; }; @@ -206,7 +177,7 @@ namespace configmgr virtual ::std::auto_ptr<INode> loadTemplate( Name const& aName, Name const& aModule, - const vos::ORef < OOptions >& _xOptions + const RequestOptions& _aOptions ) CFG_UNO_THROW_ALL( ) = 0; }; @@ -243,20 +214,6 @@ namespace configmgr }; //========================================================================== - //= INotifyBroadcaster - //========================================================================== - /** a broadcaster of changes on configuration nodes. Able to broadcast all changes in one or more - specific registry sub trees. - - */ - struct SAL_NO_VTABLE INotifyBroadcaster - { - /** registers a listener for node changes. - */ - virtual void setNotifyListener(const ::vos::ORef< INotifyListener >& _rListener) = 0; - }; - - //========================================================================== /// a refcounted TemplateManager struct SAL_NO_VTABLE IConfigTemplateManager : public Refcounted diff --git a/configmgr/source/inc/utility.hxx b/configmgr/source/inc/utility.hxx index a3e3eb7a63bb..d32843754f78 100644 --- a/configmgr/source/inc/utility.hxx +++ b/configmgr/source/inc/utility.hxx @@ -2,9 +2,9 @@ * * $RCSfile: utility.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-04-25 15:46:40 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,9 @@ #ifndef CONFIGMGR_UTILITY_HXX_ #define CONFIGMGR_UTILITY_HXX_ +#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_ +#include <com/sun/star/uno/RuntimeException.hpp> +#endif #ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_ #include <salhelper/simplereferenceobject.hxx> #endif diff --git a/configmgr/source/inc/valuenode.hxx b/configmgr/source/inc/valuenode.hxx index ddd2e9d8a7ae..8c835aa70953 100644 --- a/configmgr/source/inc/valuenode.hxx +++ b/configmgr/source/inc/valuenode.hxx @@ -2,9 +2,9 @@ * * $RCSfile: valuenode.hxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: jb $ $Date: 2002-07-14 16:49:39 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,15 +62,12 @@ #ifndef _CONFIGMGR_TREE_VALUENODE_HXX #define _CONFIGMGR_TREE_VALUENODE_HXX -#ifndef CONFIGMGR_RTTIMACROS_HXX -#include "rttimacros.hxx" +#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_ +#include "attributes.hxx" #endif #ifndef CFGMGR_ANYPAIR_HXX #include "anypair.hxx" #endif -#ifndef CONFIGMGR_CONFIGPATH_HXX_ -#include "configpath.hxx" -#endif #ifndef _COM_SUN_STAR_UNO_ANY_H_ #include <com/sun/star/uno/Any.h> @@ -80,6 +77,10 @@ #include <rtl/ustring.hxx> #endif +#ifndef CONFIGMGR_RTTIMACROS_HXX +#include "rttimacros.hxx" +#endif + #include <string.h> #ifndef INCLUDED_MEMORY #include <memory> @@ -99,7 +100,7 @@ namespace configmgr using rtl::OUString; // helper (tag) class - namespace treeop { struct NoChildCopy {}; struct DeepChildCopy {}; } + namespace treeop { struct NoChildCopy {}; struct DeepChildCopy {}; enum { ALL_LEVELS = -1 }; } //========================================================================== //= Visitors //========================================================================== @@ -170,47 +171,6 @@ namespace configmgr RTTI_BASE(INode); }; - -#if 0 // for future redesign - //========================================================================== - //= ISubtree - //========================================================================== - // Abstract class - - class ASubtree : public INode - { - sal_Int16 m_nLevel; /// determines if everything is read - OUString m_sId; - - public: - virtual bool isSetNode() const = 0; - - }; - - //========================================================================== - //= GroupTree - //========================================================================== - class GroupTree : public ASubtree - { - public: - virtual bool isSetNode() const; // always false! - - }; - - //========================================================================== - //= SetTree - //========================================================================== - class SetTree : public ASubtree - { - OUString m_sTemplateName; /// path of the template for child instantiation - OUString m_sTemplateModule; /// module of the template for child instantiation - public: - virtual bool isSetNode() const; // always true! - }; -#endif - -// ----------------------------------------------------------------------------- -// ----------------------------------- O L D ----------------------------------- // ----------------------------------------------------------------------------- //========================================================================== diff --git a/configmgr/source/inc/valueref.hxx b/configmgr/source/inc/valueref.hxx index 0ce1c3687886..d5fed20b3d22 100644 --- a/configmgr/source/inc/valueref.hxx +++ b/configmgr/source/inc/valueref.hxx @@ -2,9 +2,9 @@ * * $RCSfile: valueref.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,11 +68,12 @@ namespace configmgr { + namespace node { struct Attributes; } + namespace configuration { //------------------------------------------------------------------------- class Name; - struct Attributes; //------------------------------------------------------------------------- namespace argument { struct NoValidate; } diff --git a/configmgr/source/inc/valuetypeconverter.hxx b/configmgr/source/inc/valuetypeconverter.hxx index a2295e61bdd2..024f33696ba9 100644 --- a/configmgr/source/inc/valuetypeconverter.hxx +++ b/configmgr/source/inc/valuetypeconverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: valuetypeconverter.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-05-28 15:44:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,7 +90,6 @@ namespace configmgr // ----------------------------------------------------------------------------- class ValueConverter { - typedef std::vector< OUString > StringList; /// TypeConverter is used for converting type from string values uno::Reference< script::XTypeConverter > m_xTypeConverter; /// Value info @@ -98,6 +97,8 @@ namespace configmgr OUString m_sSeparator; bool m_bNull; public: + typedef std::vector< OUString > StringList; + public: /// construct a value converter with no initial type info ValueConverter(const uno::Reference< script::XTypeConverter > & _xTC) : m_xTypeConverter(_xTC) diff --git a/configmgr/source/inc/wrapexception.hxx b/configmgr/source/inc/wrapexception.hxx index 7988c92e200a..ae13774430b0 100644 --- a/configmgr/source/inc/wrapexception.hxx +++ b/configmgr/source/inc/wrapexception.hxx @@ -2,9 +2,9 @@ * * $RCSfile: wrapexception.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-10-01 16:08:14 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,16 @@ #ifndef CONFIGMGR_WRAPEXCEPTION_HXX #define CONFIGMGR_WRAPEXCEPTION_HXX +#include <com/sun/star/configuration/MissingBootstrapFileException.hpp> +#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> +#include <com/sun/star/configuration/InstallationIncompleteException.hpp> +#include <com/sun/star/configuration/CannotLoadConfigurationException.hpp> +#include <drafts/com/sun/star/configuration/backend/BackendSetupException.hpp> +#include <drafts/com/sun/star/configuration/backend/AuthenticationFailedException.hpp> +#include <drafts/com/sun/star/configuration/backend/InvalidAuthenticationMechanismException.hpp> +#include <drafts/com/sun/star/configuration/backend/CannotConnectException.hpp> +#include <drafts/com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp> + #include <drafts/com/sun/star/configuration/backend/BackendAccessException.hpp> #include <drafts/com/sun/star/configuration/backend/ConnectionLostException.hpp> #include <drafts/com/sun/star/configuration/backend/MalformedDataException.hpp> @@ -71,10 +81,12 @@ #include <com/sun/star/beans/UnknownPropertyException.hpp> #include <com/sun/star/container/ElementExistException.hpp> #include <com/sun/star/container/NoSuchElementException.hpp> +#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/NoSupportException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/IllegalAccessException.hpp> #include <com/sun/star/lang/WrappedTargetException.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/xml/sax/SAXException.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp> @@ -87,6 +99,23 @@ #define PASS_EXCEPTION( ETyp ) \ catch (ETyp & ) { throw; } +#define WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS( Raise ) \ + WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::InsufficientAccessRightsException, Raise) \ + WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::AuthenticationFailedException, Raise) \ + WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::InvalidAuthenticationMechanismException, Raise) \ + WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::CannotConnectException, Raise) \ + WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::BackendSetupException, Raise) \ + WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::BackendAccessException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::configuration::MissingBootstrapFileException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::configuration::InvalidBootstrapFileException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::configuration::InstallationIncompleteException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::configuration::CannotLoadConfigurationException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::lang::WrappedTargetException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::lang::WrappedTargetRuntimeException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::lang::DisposedException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::uno::RuntimeException, Raise) \ + WRAP_EXCEPTION(::com::sun::star::uno::Exception, Raise) + #define WRAP_CONFIGBACKEND_EXCEPTIONS( Raise ) \ WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::ConnectionLostException, Raise) \ WRAP_EXCEPTION(::drafts::com::sun::star::configuration::backend::BackendAccessException, Raise) \ @@ -109,6 +138,23 @@ #define WRAP_OTHER_EXCEPTIONS( Raise ) \ WRAP_EXCEPTION(::com::sun::star::uno::Exception, Raise) +#define WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS1( Raise, Arg ) \ + WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::InsufficientAccessRightsException, Raise, Arg) \ + WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::AuthenticationFailedException, Raise, Arg) \ + WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::InvalidAuthenticationMechanismException, Raise, Arg) \ + WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::CannotConnectException, Raise, Arg) \ + WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::BackendSetupException, Raise, Arg) \ + WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::BackendAccessException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::configuration::MissingBootstrapFileException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::configuration::InvalidBootstrapFileException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::configuration::InstallationIncompleteException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::configuration::CannotLoadConfigurationException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::lang::WrappedTargetException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::lang::WrappedTargetRuntimeException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::lang::DisposedException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::uno::RuntimeException, Raise, Arg) \ + WRAP_EXCEPTION1(::com::sun::star::uno::Exception, Raise, Arg) + #define WRAP_CONFIGBACKEND_EXCEPTIONS1( Raise, Arg ) \ WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::ConnectionLostException, Raise, Arg) \ WRAP_EXCEPTION1(::drafts::com::sun::star::configuration::backend::BackendAccessException, Raise, Arg) \ diff --git a/configmgr/source/localbe/localdataimportsvc.cxx b/configmgr/source/localbe/localdataimportsvc.cxx index 57759b195b4f..49beda9a1e33 100644 --- a/configmgr/source/localbe/localdataimportsvc.cxx +++ b/configmgr/source/localbe/localdataimportsvc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: localdataimportsvc.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:33 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,18 +118,18 @@ ServiceInfoHelper LocalDataImportService::getServiceInfo() // ----------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL instantiateLocalDataImporter -( CreationContext const& rServiceManager ) +( CreationContext const& xContext ) { - return * new LocalDataImportService( rServiceManager ); + return * new LocalDataImportService( xContext ); } // ----------------------------------------------------------------------------- -LocalDataImportService::LocalDataImportService(CreationArg _xServiceFactory) -: m_xServiceFactory(_xServiceFactory) +LocalDataImportService::LocalDataImportService(CreationArg _xContext) +: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY) { if (!m_xServiceFactory.is()) { - OUString sMessage = OUSTRING("Configuration Importer: Unexpected NULL context"); + OUString sMessage = OUSTRING("Configuration Importer: Context has no service manager (or interface is missing)"); throw lang::NullPointerException(sMessage,NULL); } } diff --git a/configmgr/source/localbe/localdataimportsvc.hxx b/configmgr/source/localbe/localdataimportsvc.hxx index d1b78f920e66..db8ab5259bca 100644 --- a/configmgr/source/localbe/localdataimportsvc.hxx +++ b/configmgr/source/localbe/localdataimportsvc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: localdataimportsvc.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-11-28 09:05:15 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,9 @@ #include <osl/mutex.hxx> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -101,10 +104,10 @@ namespace configmgr > { public: - typedef uno::Reference< lang::XMultiServiceFactory > const & CreationArg; + typedef uno::Reference< uno::XComponentContext > const & CreationArg; explicit - LocalDataImportService(CreationArg _xServiceFactory); + LocalDataImportService(CreationArg _xContext); ~LocalDataImportService(); // XServiceInfo diff --git a/configmgr/source/localbe/localhierarchybrowsersvc.cxx b/configmgr/source/localbe/localhierarchybrowsersvc.cxx index 7a43091c7f8d..b72b32a7b085 100644 --- a/configmgr/source/localbe/localhierarchybrowsersvc.cxx +++ b/configmgr/source/localbe/localhierarchybrowsersvc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: localhierarchybrowsersvc.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:33 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -124,8 +124,8 @@ uno::Reference< uno::XInterface > SAL_CALL instantiateLocalHierarchyBrowser } // ----------------------------------------------------------------------------- -LocalHierarchyBrowserService::LocalHierarchyBrowserService(CreationArg _xServiceFactory) -: m_xServiceFactory(_xServiceFactory) +LocalHierarchyBrowserService::LocalHierarchyBrowserService(CreationArg _xContext) +: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY) { if (!m_xServiceFactory.is()) { diff --git a/configmgr/source/localbe/localhierarchybrowsersvc.hxx b/configmgr/source/localbe/localhierarchybrowsersvc.hxx index 87ee2181cd2e..0afa04531db8 100644 --- a/configmgr/source/localbe/localhierarchybrowsersvc.hxx +++ b/configmgr/source/localbe/localhierarchybrowsersvc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: localhierarchybrowsersvc.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-11-28 09:05:16 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,9 @@ #include <osl/mutex.hxx> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -101,10 +104,10 @@ namespace configmgr > { public: - typedef uno::Reference< lang::XMultiServiceFactory > const & CreationArg; + typedef uno::Reference< uno::XComponentContext > const & CreationArg; explicit - LocalHierarchyBrowserService(CreationArg _xServiceFactory); + LocalHierarchyBrowserService(CreationArg _xContext); ~LocalHierarchyBrowserService(); // XServiceInfo diff --git a/configmgr/source/localbe/localsinglebackend.cxx b/configmgr/source/localbe/localsinglebackend.cxx index 2a07865613dc..89d8b8d35b53 100644 --- a/configmgr/source/localbe/localsinglebackend.cxx +++ b/configmgr/source/localbe/localsinglebackend.cxx @@ -2,9 +2,9 @@ * * $RCSfile: localsinglebackend.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:33 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,9 +59,7 @@ * ************************************************************************/ -#ifndef CONFIGMGR_LOCALBE_LOCALSINGLEBACKEND_HXX_ #include "localsinglebackend.hxx" -#endif // CONFIGMGR_LOCALBE_LOCALSINGLEBACKEND_HXX_ #ifndef CONFIGMGR_LOCALBE_LOCALFILELAYER_HXX_ #include "localfilelayer.hxx" @@ -79,13 +77,27 @@ #include "serviceinfohelper.hxx" #endif // CONFIGMGR_SERVICEINFOHELPER_HXX_ +#ifndef CONFIGMGR_BOOTSTRAP_HXX_ +#include "bootstrap.hxx" +#endif +#ifndef _CONFIGMGR_FILEHELPER_HXX_ +#include "filehelper.hxx" +#endif + #ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> #endif // _RTL_USTRBUF_HXX_ -#ifndef _COM_SUN_STAR_UNO_XCURRENTCONTEXT_HPP_ -#include <com/sun/star/uno/XCurrentContext.hpp> -#endif // _COM_SUN_STAR_UNO_XCURRENTCONTEXT_HPP_ +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif namespace configmgr { namespace localbe { @@ -94,14 +106,82 @@ namespace configmgr { namespace localbe { //------------------------------------------------------------------------------ LocalSingleBackend::LocalSingleBackend( - const uno::Reference<lang::XMultiServiceFactory>& aFactory) -: SingleBackendBase(mMutex), mFactory(aFactory) { + const uno::Reference<uno::XComponentContext>& xContext) + : SingleBackendBase(mMutex), mFactory(xContext->getServiceManager(),uno::UNO_QUERY) { } //------------------------------------------------------------------------------ LocalSingleBackend::~LocalSingleBackend(void) {} //------------------------------------------------------------------------------ +static inline bool isValidFileURL (rtl::OUString& _sFileURL) +{ + using osl::File; + + rtl::OUString sSystemPath; + return _sFileURL.getLength() && (File::E_None == File::getSystemPathFromFileURL(_sFileURL, sSystemPath)); +} +// --------------------------------------------------------------------------------------- +static +bool implEnsureAbsoluteURL(rtl::OUString & _rsURL) // also strips embedded dots etc. +{ + using osl::File; + + rtl::OUString sBasePath = _rsURL; + OSL_VERIFY(osl_Process_E_None == osl_getProcessWorkingDir(&sBasePath.pData)); + + rtl::OUString sAbsolute; + if ( File::E_None == File::getAbsoluteFileURL(sBasePath, _rsURL, sAbsolute)) + { + _rsURL = sAbsolute; + return true; + } + else + { + OSL_ENSURE(false, "Could not get absolute file URL for valid URL"); + return false; + } +} +// --------------------------------------------------------------------------------------- + +static +bool implNormalizeURL(OUString & _sURL, osl::DirectoryItem& aDirItem) +{ + using namespace osl; + + OSL_PRECOND(aDirItem.is(), "Opened DirItem required"); + static const sal_uInt32 cFileStatusMask = FileStatusMask_FileURL; + + FileStatus aFileStatus(cFileStatusMask); + + if (aDirItem.getFileStatus(aFileStatus) != DirectoryItem::E_None) + return false; + + OUString aNormalizedURL = aFileStatus.getFileURL(); + + if (aNormalizedURL.getLength() == 0) + return false; + + _sURL = aNormalizedURL; + return true; +} + +// --------------------------------------------------------------------------------------- +static +bool normalizeURL(OUString & _sURL) +{ + using namespace osl; + + DirectoryItem aDirItem; + + bool bResult = DirectoryItem::get(_sURL, aDirItem) == DirectoryItem::E_None; + + if ( bResult ) + bResult = implNormalizeURL(_sURL,aDirItem); + + return bResult; +} +// --------------------------------------------------------------------------------------- static void fillFromBlankSeparated(const rtl::OUString& aList, uno::Sequence<rtl::OUString>& aTarget) { std::vector<rtl::OUString> tokens ; @@ -122,25 +202,24 @@ static void fillFromBlankSeparated(const rtl::OUString& aList, } //------------------------------------------------------------------------------ -static const rtl::OUString kMetaConfPrefix( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.bootstrap.")) ; -static const rtl::OUString kSchemaDataUrl(kMetaConfPrefix + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SchemaDataUrl"))) ; -static const rtl::OUString kDefaultDataUrl(kMetaConfPrefix + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLayerUrls"))) ; -static const rtl::OUString kUserDataUrl(kMetaConfPrefix + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserLayerUrl"))) ; -static const rtl::OUString kEntity(kMetaConfPrefix + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EntityLayer"))) ; - -static const rtl::OUString kAdminMode(kMetaConfPrefix + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_session_class_"))) ; -static const rtl::OUString kAdminModeValue( - RTL_CONSTASCII_USTRINGPARAM("adminconfiguration")) ; +static const rtl::OUString kSchemaDataUrl( + RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"SchemaDataUrl")) ; +static const rtl::OUString kDefaultDataUrl( + RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"DefaultLayerUrls")) ; +static const rtl::OUString kUserDataUrl( + RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"UserLayerUrl")) ; +static const rtl::OUString kEntity( + RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"EntityLayer")) ; + +static const rtl::OUString kAdminModeFlag( + RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_ADMINFLAG)) ; void SAL_CALL LocalSingleBackend::initialize( const uno::Sequence<uno::Any>& aParameters) - throw (uno::RuntimeException, uno::Exception) + throw (uno::RuntimeException, uno::Exception, + css::configuration::InvalidBootstrapFileException, + backend::CannotConnectException, + backend::BackendSetupException) { if (aParameters.getLength() == 0) { throw lang::IllegalArgumentException( @@ -148,7 +227,7 @@ void SAL_CALL LocalSingleBackend::initialize( "No parameters provided to SingleBackend")), *this, 0) ; } - uno::Reference<uno::XCurrentContext> context ; + uno::Reference<uno::XComponentContext> context ; for (sal_Int32 i = 0 ; i < aParameters.getLength() ; ++ i) { if (aParameters [i] >>= context) { break ; } @@ -156,6 +235,14 @@ void SAL_CALL LocalSingleBackend::initialize( // Setting: schema context->getValueByName(kSchemaDataUrl) >>= mSchemaDataUrl; + //validate SchemaDataUrl + validateFileURL(mSchemaDataUrl); + //NormalizeURL + implEnsureAbsoluteURL(mSchemaDataUrl); + normalizeURL(mSchemaDataUrl); + + checkFileExists(mSchemaDataUrl); + checkIfDirectory(mSchemaDataUrl); // Setting: default layer(s) uno::Any aDefaultDataSetting = context->getValueByName(kDefaultDataUrl); @@ -163,39 +250,57 @@ void SAL_CALL LocalSingleBackend::initialize( if (context->getValueByName(kDefaultDataUrl) >>= defaults) { - fillFromBlankSeparated(defaults, mDefaultDataUrl) ; + fillFromBlankSeparated(defaults, mDefaultDataUrls) ; } else { - context->getValueByName(kDefaultDataUrl) >>= mDefaultDataUrl ; + context->getValueByName(kDefaultDataUrl) >>= mDefaultDataUrls ; + } + //validate DefaultDataUrls + for (sal_Int32 ix = 0; ix < mDefaultDataUrls.getLength(); ++ix) + { + validateFileURL(mDefaultDataUrls[ix]); + //NormalizeURL + implEnsureAbsoluteURL(mDefaultDataUrls[ix]); + normalizeURL(mDefaultDataUrls[ix]); + if(FileHelper::fileExists(mDefaultDataUrls[ix])) + { + checkIfDirectory(mDefaultDataUrls[ix]); + } } // Setting: admin mode tag - rtl::OUString adminModeSelector ; - bool bAdminMode = - (context->getValueByName(kAdminMode) >>= adminModeSelector) && - adminModeSelector.equalsIgnoreAsciiCase(kAdminModeValue) ; + sal_Bool bAdminMode = false; + context->getValueByName(kAdminModeFlag) >>= bAdminMode; if (bAdminMode) { // find given entity - if ( (context->getValueByName(kEntity) >>= mOwnId) && mOwnId.getLength() ) + if ( (context->getValueByName(kEntity) >>= mUserDataUrl) && mUserDataUrl.getLength() ) { - for (sal_Int32 ix = 0; ix < mDefaultDataUrl.getLength(); ++ix) + //Validate UserDataUrl + validateFileURL(mUserDataUrl); + //NormalizeURL + implEnsureAbsoluteURL(mUserDataUrl); + normalizeURL(mUserDataUrl); + if(FileHelper::fileExists(mUserDataUrl)) { - if (mDefaultDataUrl.getConstArray()[ix].equals(mOwnId)) + checkIfDirectory(mUserDataUrl); + } + + for (sal_Int32 ix = 0; ix < mDefaultDataUrls.getLength(); ++ix) + { + if (mDefaultDataUrls.getConstArray()[ix].equals(mUserDataUrl)) { - mDefaultDataUrl.realloc(ix); + mDefaultDataUrls.realloc(ix); // this is the last round through the loop } } - mUserDataUrl = mOwnId; } - else if (sal_Int32 nLen = mDefaultDataUrl.getLength()) // administrate last default layer + else if (mDefaultDataUrls.getLength()) // administrate first default layer { - --nLen; - mUserDataUrl = mOwnId = mDefaultDataUrl[nLen]; - mDefaultDataUrl.realloc(nLen); + mUserDataUrl = mDefaultDataUrls[0]; + mDefaultDataUrls.realloc(0); } else { @@ -207,7 +312,15 @@ void SAL_CALL LocalSingleBackend::initialize( if (!bAdminMode) { context->getValueByName(kUserDataUrl) >>= mUserDataUrl ; - mOwnId = mUserDataUrl; + //Validate UserDataUrl + validateFileURL(mUserDataUrl); + //GetAbsolsoluteURL + implEnsureAbsoluteURL(mUserDataUrl); + normalizeURL(mUserDataUrl); + if(FileHelper::fileExists(mUserDataUrl)) + { + checkIfDirectory(mUserDataUrl); + } } } //------------------------------------------------------------------------------ @@ -265,13 +378,13 @@ uno::Sequence<rtl::OUString> SAL_CALL LocalSingleBackend::listLayerIds( throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException) { - if (aEntity.getLength() > 0 && !aEntity.equals(mOwnId)) { + if (aEntity.getLength() > 0 && !aEntity.equals(mUserDataUrl)) { throw lang::IllegalArgumentException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Can only access user data")), *this, 1) ; } - sal_Int32 nbLayers = mDefaultDataUrl.getLength() + 1 ; + sal_Int32 nbLayers = mDefaultDataUrls.getLength() + 1 ; uno::Sequence<rtl::OUString> retCode(nbLayers) ; rtl::OUString componentSubPath = componentToPath(aComponent) + kDataSuffix ; @@ -290,20 +403,55 @@ rtl::OUString SAL_CALL LocalSingleBackend::getUpdateLayerId( throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException) { - if (aEntity.getLength() > 0 && !aEntity.equals(mOwnId)) { - throw lang::IllegalArgumentException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Can only access user data")), - *this, 1) ; + sal_Bool bFoundDefaultLayer = sal_False; + sal_Int32 nIndex = 0; + + if ((aEntity.getLength() > 0) && aEntity.equals(mUserDataUrl)) + { + nIndex=-1; + } + else + { + OUString sTempEntityUrl(aEntity); + normalizeURL(sTempEntityUrl); + for (sal_Int32 ix = 0; ix < mDefaultDataUrls.getLength()&&!bFoundDefaultLayer; ix++) + { + OUString sTempDefaultUrl(mDefaultDataUrls[ix]); + normalizeURL(sTempDefaultUrl); + if (sTempEntityUrl.equals(sTempDefaultUrl)) + { + bFoundDefaultLayer = sal_True; + nIndex = ix; + } + } + if (!bFoundDefaultLayer) + { + //Try normalized version of mUserDataUrl + OUString sTempUserUrl(mUserDataUrl); + normalizeURL(sTempUserUrl); + if (sTempUserUrl.equals(sTempEntityUrl)) + { + nIndex=-1; + } + else + { + rtl::OUStringBuffer sMsg; + sMsg.appendAscii(" Cannot update data: Invalid Layer URL: \""); + sMsg.append(aEntity); + sMsg.appendAscii("\""); + throw lang::IllegalArgumentException(sMsg.makeStringAndClear(), + *this, 1) ; + } + } } - return urlToLayerId(componentToPath(aComponent) + kDataSuffix, -1) ; + return urlToLayerId(componentToPath(aComponent) + kDataSuffix, nIndex) ; } //------------------------------------------------------------------------------ rtl::OUString SAL_CALL LocalSingleBackend::getOwnId(void) throw (uno::RuntimeException) { - return mOwnId ; + return mUserDataUrl ; } //------------------------------------------------------------------------------ @@ -466,7 +614,7 @@ void LocalSingleBackend::getLayerDirectories(sal_Int32 aLayerIndex, rtl::OUString& aLayerUrl, rtl::OUString& aSubLayerUrl) { - OUString aLayerBaseUrl = (aLayerIndex == -1 ? mUserDataUrl : mDefaultDataUrl [aLayerIndex]) ; + OUString aLayerBaseUrl = (aLayerIndex == -1 ? mUserDataUrl : mDefaultDataUrls [aLayerIndex]) ; impl_getLayerSubDirectories(aLayerBaseUrl,aLayerUrl,aSubLayerUrl); } @@ -530,8 +678,8 @@ const ServiceRegistrationInfo *getLocalBackendServiceInfo() { return getRegistrationInfo(&kServiceInfo) ; } uno::Reference<uno::XInterface> SAL_CALL -instantiateLocalBackend(const CreationContext& aServiceManager) { - return *new LocalSingleBackend(aServiceManager) ; +instantiateLocalBackend(const CreationContext& xContext) { + return *new LocalSingleBackend(xContext) ; } //------------------------------------------------------------------------------ @@ -570,6 +718,46 @@ SAL_CALL LocalSingleBackend::getSupportedServiceNames(void) { return ServiceInfoHelper(&kServiceInfo).getSupportedServiceNames() ; } + +// --------------------------------------------------------------------------------------- + +void LocalSingleBackend::validateFileURL(rtl::OUString& aFileURL) +{ + rtl::OUStringBuffer sMsg; + sMsg.appendAscii(" Not a Valid File URL: \""); + sMsg.append(aFileURL); + sMsg.appendAscii("\""); + if (!isValidFileURL( aFileURL)) + { + throw com::sun::star::configuration::InvalidBootstrapFileException( + sMsg.makeStringAndClear(),*this, aFileURL ) ; + } +} //------------------------------------------------------------------------------ +void LocalSingleBackend::checkFileExists(rtl::OUString& aFileURL) + throw (backend::CannotConnectException) +{ + rtl::OUStringBuffer sMsg; + sMsg.appendAscii(" No Such File or Directory: \""); + sMsg.append(aFileURL); + sMsg.appendAscii("\""); + if (!FileHelper::fileExists(aFileURL)) + { + throw backend::CannotConnectException(sMsg.makeStringAndClear(), *this, uno::Any()) ; + } +} +//------------------------------------------------------------------------------ +void LocalSingleBackend::checkIfDirectory(rtl::OUString& aFileURL) + throw (backend::BackendSetupException) +{ + rtl::OUStringBuffer sMsg; + sMsg.appendAscii(" File:\""); + sMsg.append(aFileURL); + sMsg.appendAscii("\" Must be a Directory\""); + if (!FileHelper::dirExists(aFileURL)) + { + throw backend::BackendSetupException(sMsg.makeStringAndClear(),*this, uno::Any()) ; + } +} } } // configmgr.localbe diff --git a/configmgr/source/localbe/localsinglebackend.hxx b/configmgr/source/localbe/localsinglebackend.hxx index f0706795c93b..3b28f48161e9 100644 --- a/configmgr/source/localbe/localsinglebackend.hxx +++ b/configmgr/source/localbe/localsinglebackend.hxx @@ -2,9 +2,9 @@ * * $RCSfile: localsinglebackend.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-11-28 09:05:17 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,6 +66,10 @@ #include <drafts/com/sun/star/configuration/backend/XSingleBackend.hpp> #endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_XSINGLEBACKEND_HPP_ +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif + #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ #include <com/sun/star/lang/XInitialization.hpp> #endif // _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ @@ -82,6 +86,14 @@ #include <cppuhelper/compbase3.hxx> #endif // _CPPUHELPER_COMPBASE3_HXX_ +#ifndef _COM_SUN_STAR_CONFIGURATION_INVALIDBOOTSTRAPFILEEXCEPTION_HPP_ +#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> +#endif + +#ifndef _DRAFTS_COM_SUN_STAR_CONFIGURATION_BACKEND_CANNOTCONNECTEXCEPTION_HPP_ +#include <drafts/com/sun/star/configuration/backend/CannotConnectException.hpp> +#endif + namespace configmgr { namespace localbe { namespace css = com::sun::star ; @@ -108,14 +120,17 @@ class LocalSingleBackend : public SingleBackendBase { @param xFactory service factory */ LocalSingleBackend( - const uno::Reference<lang::XMultiServiceFactory>& xFactory) ; + const uno::Reference<uno::XComponentContext>& xContext) ; /** Destructor */ ~LocalSingleBackend(void) ; // XInitialize virtual void SAL_CALL initialize( const uno::Sequence<uno::Any>& aParameters) - throw (uno::RuntimeException, uno::Exception) ; + throw (uno::RuntimeException, uno::Exception, + css::configuration::InvalidBootstrapFileException, + backend::CannotConnectException, + backend::BackendSetupException); // XSingleBackend virtual uno::Sequence<rtl::OUString> SAL_CALL listLayerIds( const rtl::OUString& aComponent, @@ -210,18 +225,16 @@ class LocalSingleBackend : public SingleBackendBase { rtl::OUString const & aComponentUrl); private : /** Service factory */ - const uno::Reference<lang::XMultiServiceFactory>& mFactory ; + uno::Reference<lang::XMultiServiceFactory> mFactory ; /** Mutex for resources protection */ osl::Mutex mMutex ; - /** Identifier of the user of the backend */ - rtl::OUString mOwnId ; /** Base of the schema data */ rtl::OUString mSchemaDataUrl ; /** Base of the default data. Is a list to allow for multiple layers of default data. */ - uno::Sequence<rtl::OUString> mDefaultDataUrl ; + uno::Sequence<rtl::OUString> mDefaultDataUrls ; /** Base of the user data */ rtl::OUString mUserDataUrl ; @@ -272,6 +285,27 @@ class LocalSingleBackend : public SingleBackendBase { sal_Bool isMoreRecent(const rtl::OUString& aComponent, sal_Int32 aLayerId, const rtl::OUString& aTimestamp) ; + /** + Validates a file URL + + @param aFileURL URL of the file to validate + */ + void validateFileURL(rtl::OUString& aFileURL); + /** + Checks if a Directory exist for a given file URL + + @param aFileURL URL of the file to validate + */ + void checkIfDirectory(rtl::OUString& aFileURL) + throw (backend::BackendSetupException); + /** + Checks if a File exist for a given file URL + + @param aFileURL URL of the file to validate + */ + void checkFileExists(rtl::OUString& aFileURL) + throw (backend::CannotConnectException); + } ; } } // configmgr.localbe diff --git a/configmgr/source/misc/bootstrap.cxx b/configmgr/source/misc/bootstrap.cxx index 59e73d28bc43..ca367c1127b7 100644 --- a/configmgr/source/misc/bootstrap.cxx +++ b/configmgr/source/misc/bootstrap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.cxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.26 $ * - * last change: $Author: jb $ $Date: 2002-10-24 15:44:02 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,9 +63,13 @@ #include "bootstrap.hxx" -#ifndef CONFIGMGR_SESSIONFACTORY_HXX_ -#include "sessionfactory.hxx" +#ifndef CONFIGMGR_API_FACTORY_HXX_ +#include "confapifactory.hxx" #endif +#ifndef CONFIGMGR_SERVICEINFOHELPER_HXX_ +#include "serviceinfohelper.hxx" +#endif + #ifndef CONFIGMGR_MATCHLOCALE_HXX #include "matchlocale.hxx" #endif @@ -74,6 +78,9 @@ #include "tracer.hxx" #endif +#ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ +#include <cppuhelper/component_context.hxx> +#endif #ifndef _RTL_BOOTSTRAP_HXX_ #include <rtl/bootstrap.hxx> #endif @@ -98,6 +105,9 @@ #include <osl/diagnose.h> #endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif #ifndef _COM_SUN_STAR_CONFIGURATION_MISSINGBOOTSTRAPFILEEXCEPTION_HPP_ #include <com/sun/star/configuration/MissingBootstrapFileException.hpp> #endif @@ -115,1052 +125,648 @@ #endif // --------------------------------------------------------------------------------------- -#define BOOTSTRAP_CONFIGMGR_DATA SAL_CONFIGFILE("configmgr") -// --------------------------------------------------------------------------------------- -#define SETTING_UNOSERVICE "BackendService" -#define SETTING_UNOWRAPPER "BackendWrapper" -#define SETTING_OFFLINE "Offline" -// --------------------------------------------------------------------------------------- -// configuration bootstrap items -#define BOOTSTRAP_ITEM_PREFIX_ "CFG_" - -#define BOOTSTRAP_ITEM_SERVERTYPE "CFG_ServerType" -#define BOOTSTRAP_ITEM_UNOSERVICE BOOTSTRAP_ITEM_PREFIX_ SETTING_UNOSERVICE -#define BOOTSTRAP_ITEM_UNOWRAPPER BOOTSTRAP_ITEM_PREFIX_ SETTING_UNOWRAPPER -#define BOOTSTRAP_ITEM_OFFLINE /*BOOTSTRAP_ITEM_PREFIX_*/ SETTING_OFFLINE -#define BOOTSTRAP_ITEM_LOCALE BOOTSTRAP_ITEM_PREFIX_ "Locale" -#define BOOTSTRAP_ITEM_ASYNCENABLE BOOTSTRAP_ITEM_PREFIX_ "EnableAsync" - -#define BOOTSTRAP_ITEM_SOURCE_PATH "CFG_BaseDataURL" -#define BOOTSTRAP_ITEM_UPDATE_PATH "CFG_UserDataURL" - -#define BOOTSTRAP_ITEM_SERVER "CFG_Server" -#define BOOTSTRAP_ITEM_TIMEOUT "CFG_Timeout_ms" - -#define BOOTSTRAP_ITEM_USER "CFG_User" -#define BOOTSTRAP_ITEM_PASSWORD "CFG_Password" - -#define BOOTSTRAP_ITEM_PROFILE_NAME "CFG_INIFILE" - -// --------------------------------------------------------------------------------------- -// default bootstrap values from an INI ('sregistryrc') -#define BOOTSTRAP_FROM_PROFILE(sect,key) "${$" BOOTSTRAP_ITEM_PROFILE_NAME ":" sect ":" key "}" - -#define BOOTSTRAP_SERVERTYPE_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_CONFIGURATION,SREGISTRY_KEY_SERVERTYPE) -#define BOOTSTRAP_UNOSERVICE_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_CONFIGURATION,BOOTSTRAP_ITEM_UNOSERVICE) -#define BOOTSTRAP_UNOWRAPPER_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_CONFIGURATION,BOOTSTRAP_ITEM_UNOWRAPPER) - -#define BOOTSTRAP_LOCALE_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_CONFIGURATION,SREGISTRY_KEY_LOCALE) -#define BOOTSTRAP_ASYNCENABLE_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_CONFIGURATION,SREGISTRY_KEY_ASYNC) - -#define BOOTSTRAP_SERVER_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_REMOTE,SREGISTRY_KEY_SERVER) -#define BOOTSTRAP_TIMEOUT_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_REMOTE,SREGISTRY_KEY_TIMEOUT) - -#define BOOTSTRAP_BASEPATH_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_LOCAL,SREGISTRY_KEY_SOURCEPATH) -#define BOOTSTRAP_DATAPATH_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_LOCAL,SREGISTRY_KEY_UPDATEPATH) - -#define BOOTSTRAP_USER_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_AUTHENTICATION,SREGISTRY_KEY_USER) -#define BOOTSTRAP_PASSWORD_FROM_PROFILE BOOTSTRAP_FROM_PROFILE(SREGISTRY_SECTION_AUTHENTICATION,SREGISTRY_KEY_PASSWORD) - -// --------------------------------------------------------------------------------------- -// sections and entries of srgeistryrc -#define SREGISTRY_SECTION_CONFIGURATION "configuration" -#define SREGISTRY_KEY_SERVERTYPE "servertype" -#define SREGISTRY_KEY_SESSIONCLASS "service" -#define SREGISTRY_KEY_LOCALE "locale" -#define SREGISTRY_KEY_ASYNC "enable_async" - -#define SREGISTRY_SECTION_REMOTE "RemoteRegistry" -#define SREGISTRY_KEY_SERVER "Server" -#define SREGISTRY_KEY_TIMEOUT "Timeout" - -#define SREGISTRY_SECTION_LOCAL "LocalRegistry" -#define SREGISTRY_KEY_SOURCEPATH "sourcepath" -#define SREGISTRY_KEY_UPDATEPATH "updatepath" - -#define SREGISTRY_SECTION_AUTHENTICATION "Authentication" -#define SREGISTRY_KEY_USER "User" -#define SREGISTRY_KEY_PASSWORD "Password" -// --------------------------------------------------------------------------------------- +// legacy argument names +#define ARGUMENT_LOCALE_COMPAT "locale" +#define ARGUMENT_ASYNC_COMPAT "lazywrite" +#define ARGUMENT_SERVERTYPE_COMPAT "servertype" -// legacy settings -#define SETTING_SERVERTYPE "servertype" -#define SETTING_SESSIONCLASS "_session_class_" -#define SETTING_LOCALE "locale" -#define SETTING_ASYNC "lazywrite" - -// portal settings -#define SETTING_SERVICE "service" -// remote settings -#define SETTING_SERVER "server" -#define SETTING_PORT "port" -#define SETTING_TIMEOUT "timeout" -// local settings -#define SETTING_SOURCEPATH "sourcepath" -#define SETTING_UPDATEPATH "updatepath" -#define SETTING_REINITIALIZE "reinitialize" -// authentication settings -#define SETTING_USER "user" -#define SETTING_PASSWORD "password" -// 'option' settings +// legacy servertype setting +#define SETTING_SERVERTYPE_COMPAT "ServerType" +#define BOOTSTRAP_SERVERTYPE_COMPAT CONTEXT_ITEM_PREFIX_ SETTING_SERVERTYPE_COMPAT -// --------------------------------------------------------------------------------------- -#define SERVICE_USERSESSION "configuration" -#define SERVICE_ADMINSESSION "adminconfiguration" +#define SERVERTYPE_UNO_COMPAT "uno" +#define SERVERTYPE_PLUGIN_COMPAT "plugin" // --------------------------------------------------------------------------------------- #define NAME( N ) OUString(RTL_CONSTASCII_USTRINGPARAM(N)) #define ITEM( N ) OUString(RTL_CONSTASCII_USTRINGPARAM(N)) // --------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------- + +// --------------------------------------------------------------------------------------- namespace configmgr { - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::beans; - namespace uno = ::com::sun::star::uno; - // --------------------------------------------------------------------------------------- - static const sal_Char* pKnownSettings[] = - { - SETTING_SERVERTYPE, - SETTING_USER, SETTING_PASSWORD, - SETTING_SERVER, SETTING_SERVICE, SETTING_PORT, - SETTING_TIMEOUT, - SETTING_LOCALE, SETTING_ASYNC, - SETTING_SOURCEPATH, SETTING_UPDATEPATH, SETTING_REINITIALIZE, - SETTING_UNOSERVICE, SETTING_UNOWRAPPER, SETTING_OFFLINE - }; - // --------------------------------------------------------------------------------------- - typedef char const * AsciiString; + const sal_Char k_BootstrapContextImplName[] = "com.sun.star.comp.configuration.bootstrap.BootstrapContext" ; + const sal_Char k_BootstrapContextServiceName[] = "com.sun.star.configuration.bootstrap.BootstrapContext" ; - struct SessionClass + // ------------------------------------------------------------------------- + static AsciiServiceName const k_BootstrapContextServiceNames [] = { - AsciiString name; - SessionFactoryFunc create; + k_BootstrapContextServiceName, + 0 }; - -// --------------------------------------------------------------------------------------- - SessionClass const aSessionClasses[] = + static const ServiceImplementationInfo k_BootstrapContextServiceInfo = { - { UNO_SESSION_IDENTIFIER, createNoSession }, - { REMOTE_SESSION_IDENTIFIER, createRemoteSession }, - { LOCAL_SESSION_IDENTIFIER, createLocalSession }, - { PORTAL_SESSION_IDENTIFIER, createPortalSession }, - { SETUP_SESSION_IDENTIFIER, createSetupSession } + k_BootstrapContextImplName, + k_BootstrapContextServiceNames, + 0 }; - int const nSessionClasses = sizeof(aSessionClasses)/sizeof(aSessionClasses[0]); - -// --------------------------------------------------------------------------------------- - OUString Settings::Setting::toString() const + static const SingletonRegistrationInfo k_BootstrapContextSingletonInfo = { - OUString sReturn; - - sal_Bool bSuccess = this->m_aValue >>= sReturn; - - OSL_ENSURE(bSuccess || !this->m_aValue.hasValue(), "Settings::Setting::toString: setting is not a string!"); - - return sReturn; - } - + A_BootstrapContextSingletonName, + k_BootstrapContextImplName, + k_BootstrapContextServiceName, + 0 + }; // --------------------------------------------------------------------------------------- - sal_Int32 Settings::Setting::toInt32() const - { - sal_Int32 nReturn = 0; - - sal_Bool bSuccess = this->m_aValue >>= nReturn; - if (!bSuccess) - { - OUString sValue; - if (this->m_aValue >>= sValue) - { - nReturn = sValue.toInt32(); - bSuccess = (nReturn != 0 ); - } - } - OSL_ENSURE(bSuccess || !this->m_aValue.hasValue(), "Settings::getIntSetting: setting is not an integer!"); - return nReturn; - } - // --------------------------------------------------------------------------------------- - sal_Bool Settings::Setting::toBool() const + uno::Reference<uno::XInterface> SAL_CALL + instantiateBootstrapContext( CreationContext const& xTargetContext ) { - sal_Bool bReturn = false; + CreationContext xContext = UnoContextTunnel::recoverContext(xTargetContext); - switch (this->m_aValue.getValueTypeClass()) - { - case uno::TypeClass_BOOLEAN: - bReturn = *static_cast<sal_Bool const*>(this->m_aValue.getValue()); - break; - - case uno::TypeClass_LONG: - bReturn = (0 != *static_cast<sal_Int32 const*>(this->m_aValue.getValue())); - break; + BootstrapContext * pContext = new BootstrapContext(xContext); + CreationContext xResult(pContext); - case uno::TypeClass_STRING: - { - - OUString sValue; OSL_VERIFY(this->m_aValue >>= sValue); - if (sValue.getLength() == 0) - { - bReturn = false; - } - else if (sValue.equalsIgnoreAsciiCase(OUString::createFromAscii("true")) || - sValue.equalsIgnoreAsciiCase(OUString::createFromAscii("yes")) ) - { - bReturn = true; - } - else if (sValue.equalsIgnoreAsciiCase(OUString::createFromAscii("false")) || - sValue.equalsIgnoreAsciiCase(OUString::createFromAscii("no")) ) - { - bReturn = false; - } - else - OSL_ENSURE(false, "Settings::Setting::toBool: string setting is no known bool value name!"); - - } break; + pContext->initialize(); - default: - OSL_ENSURE(false, "Settings::Setting::toBool: setting is not a boolean!"); - case uno::TypeClass_VOID: // don't assert, if no value - break; - } - - return bReturn; + return xResult; } -// --------------------------------------------------------------------------------------- - Settings::Settings() + const SingletonRegistrationInfo * getBootstrapContextSingletonInfo() { + return &k_BootstrapContextSingletonInfo; } - -// --------------------------------------------------------------------------------------- - Settings::Settings(const Sequence< Any >& _rOverrides, Origin _eOrigin) + const ServiceRegistrationInfo * getBootstrapContextServiceInfo() { - implAddOverrides(_rOverrides,_eOrigin); + return getRegistrationInfo(&k_BootstrapContextServiceInfo); } - // --------------------------------------------------------------------------------------- - void Settings::mergeOverrides(const Settings& _rOverrides) - { - for (Iterator it = _rOverrides.begin(); it != _rOverrides.end(); ++it) - { - m_aImpl[it->first] = it->second; - } - } +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - void Settings::implAddOverrides(const Sequence< Any >& _rOverrides, Origin _eOrigin) + static + inline + cppu::ContextEntry_Init makeEntry(beans::NamedValue const & aOverride) { - // transfer the runtime overrides - const sal_Int32 nCount = _rOverrides.getLength(); - OSL_ENSURE(0 <= nCount && nCount <= 0x7FFF, "Unexpected number of arguments"); - - Any const * pOverrides = _rOverrides.getConstArray(); - for (sal_Int32 nArg = 0; nArg < nCount; ++nArg) - { - OUString sName; - Any aValue; - - if ( implExtractOverride(pOverrides[nArg],sName,aValue) ) - { - putSetting(sName, Setting(aValue, _eOrigin)); - CFG_TRACE_INFO("provider bootstrapping: runtime parameter: %s", OUSTRING2ASCII(sName)); - } - else - { - CFG_TRACE_ERROR("provider bootstrapping: illegal parameter of type %s", OUSTRING2ASCII(pOverrides[nArg].getValueType().getTypeName())); - throw IllegalArgumentException(OUString::createFromAscii("Configuration: Provider Creation Argument is not a com.sun.star.beans.PropertyValue or NameValue."), NULL, sal_Int16(nArg)); - } - } + return cppu::ContextEntry_Init(aOverride.Name,aOverride.Value); } +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - bool Settings::implExtractOverride(const Any & _rOverride, Name& _rName, Any& _rValue) + static + cppu::ContextEntry_Init makeSingleton(SingletonRegistrationInfo const * pSingletonInfo) { - { - PropertyValue aCurrentArgPV; - // it must be a PropertyValue - if (_rOverride >>= aCurrentArgPV) - { - _rName = aCurrentArgPV.Name; - _rValue = aCurrentArgPV.Value; - - return true; - } - } - { - NamedValue aCurrentArgNV; - // or a NamedValue - if (_rOverride >>= aCurrentArgNV) - { - _rName = aCurrentArgNV.Name; - _rValue = aCurrentArgNV.Value; - - return true; - } - } + OSL_ASSERT( pSingletonInfo && + pSingletonInfo->singletonName && + pSingletonInfo->instantiatedServiceName ); - return false; - } + rtl::OUStringBuffer aSingletonName; + aSingletonName.appendAscii( RTL_CONSTASCII_STRINGPARAM(SINGLETON_) ); + aSingletonName.appendAscii(pSingletonInfo->singletonName); -// --------------------------------------------------------------------------------------- - static bool isEmptySettingValue(uno::Any const& aAny) - { - if (!aAny.hasValue()) - { - return true; - } + OUString const aServiceName = OUString::createFromAscii(pSingletonInfo->instantiatedServiceName); + return cppu::ContextEntry_Init(aSingletonName.makeStringAndClear(), uno::makeAny(aServiceName), true); + } +// --------------------------------------------------------------------------- - // string check - OUString sStringCheck; - if (aAny >>= sStringCheck) - { - // it's a string - check if empty - return (0 == sStringCheck.getLength()); - } +BootstrapContext::Context BootstrapContext::createWrapper(Context const & _xContext, Overrides const & _aOverrides) +{ + std::vector< cppu::ContextEntry_Init > aContextEntries; + aContextEntries.reserve(_aOverrides.getLength() + 6); - // boolean check - 'false' must be accepted - if (aAny.getValueType() == ::getBooleanCppuType()) - { - return false; - } + // marker + bootstrap context + aContextEntries.push_back( cppu::ContextEntry_Init(NAME(CONTEXT_ITEM_IS_WRAPPER_CONTEXT), uno::makeAny(sal_True)) ); + aContextEntries.push_back( cppu::ContextEntry_Init(NAME(CONTEXT_ITEM_IS_BOOTSTRAP_CONTEXT), uno::makeAny(sal_False)) ); - // integer check - sal_Int32 nIntCheck = 0; - if (aAny >>= nIntCheck) - { - // it's an int - check for zero - return(0 == nIntCheck); - } + aContextEntries.push_back( makeSingleton(getBootstrapContextSingletonInfo()) ); - OSL_ENSURE(false, "Unknown settings type"); - return false; // nevertheless accept + // singletons except for passthrough + if (!isPassthrough(_xContext)) + { + aContextEntries.push_back( makeSingleton(getDefaultProviderSingletonInfo()) ); + aContextEntries.push_back( makeSingleton(backend::getDefaultBackendSingletonInfo()) ); + aContextEntries.push_back( makeSingleton(backend::getDefaultSingleBackendSingletonInfo()) ); } -// --------------------------------------------------------------------------------------- - void Settings::putSetting(Name const& _pName, const Setting& _rSetting) - { - // catch invalid settings - if ( ! isEmptySettingValue(_rSetting.value()) ) - { - m_aImpl[_pName] = _rSetting; - } + for (sal_Int32 i = 0; i<_aOverrides.getLength(); ++i) + aContextEntries.push_back( makeEntry(_aOverrides[i]) ); - else - { - CFG_TRACE_WARNING("bootstrap: Putting empty setting for '%s'. Will be cleared instead"); - this->clearSetting(_pName); - } - } + return cppu::createComponentContext(&aContextEntries.front(),aContextEntries.size(),_xContext); +} +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - void Settings::clearSetting(Name const& _pName) - { - m_aImpl.erase(_pName); - } +sal_Bool BootstrapContext::isWrapper(Context const & _xContext) +{ + OSL_ASSERT(_xContext.is()); + if (!_xContext.is()) return false; -// --------------------------------------------------------------------------------------- - sal_Bool Settings::haveSetting(Name const& _pName) const - { - Iterator aPos = m_aImpl.find(_pName); + uno::Any aSetting = _xContext->getValueByName( NAME(CONTEXT_ITEM_IS_WRAPPER_CONTEXT) ); - // have a setting at all ? - return (aPos != m_aImpl.end()); - } + if (!aSetting.hasValue()) return false; -// --------------------------------------------------------------------------------------- - Settings::Origin Settings::getOrigin(Name const& _pName) const - { - Iterator aPos = m_aImpl.find(_pName); + sal_Bool bValue = false; + OSL_VERIFY(aSetting >>= bValue); - // have a setting at all ? - return (aPos != m_aImpl.end()) ? aPos->second.origin() : SO_NOT_SET; - } + return bValue; +} +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - Settings::Setting Settings::getMaybeSetting(Name const& _pName) const - { - Iterator aPos = m_aImpl.find(_pName); +BootstrapContext::BootstrapContext(Context const & _xContext) +: ComponentContext(_xContext) +{ +} +// --------------------------------------------------------------------------- - if (aPos != m_aImpl.end()) - return aPos->second; +BootstrapContext::~BootstrapContext() +{ +} +// --------------------------------------------------------------------------- - else - return Setting(); +void BootstrapContext::initialize() +{ + // get default Bootstrap URL + OUString sURL; + uno::Any aExplicitURL; + if ( this->lookupInContext(aExplicitURL,NAME(CONTEXT_ITEM_PREFIX_ SETTING_INIFILE)) ) + { + OSL_VERIFY(aExplicitURL >>= sURL); } - -// --------------------------------------------------------------------------------------- - Settings::Setting Settings::getSetting(Name const& _pName) const + else if (!rtl::Bootstrap::get(NAME(BOOTSTRAP_ITEM_INIFILE),sURL)) { - OSL_ENSURE(haveSetting(_pName), "Settings::getSetting: don't have the requested setting!"); - return getMaybeSetting(_pName); + sURL = getDefaultConfigurationBootstrapURL(); } -// --------------------------------------------------------------------------------------- - OUString Settings::getStringSetting(Name const& _pName) const + ComponentContext::initialize(sURL); +} +// --------------------------------------------------------------------------- + +static OUString getCurrentModuleDirectory() // URL including terminating slash +{ + OUString aFileURL; + if ( !osl::Module::getUrlFromAddress((void*)&getCurrentModuleDirectory,aFileURL) ) { - Setting aSetting = this->getSetting(_pName); + OSL_TRACE(false, "Cannot locate current module - using executable instead"); - return aSetting.toString(); + OSL_VERIFY(osl_Process_E_None == osl_getExecutableFile(&aFileURL.pData)); } -// --------------------------------------------------------------------------------------- - sal_Int32 Settings::getIntSetting(Name const& _pName) const - { - Setting aSetting = this->getSetting(_pName); + OSL_ENSURE(0 < aFileURL.lastIndexOf('/'), "Cannot find directory for module URL"); - return aSetting.toInt32(); - } + return aFileURL.copy(0, aFileURL.lastIndexOf('/') + 1); +} +// --------------------------------------------------------------------------------------- +OUString BootstrapContext::getDefaultConfigurationBootstrapURL() +{ + return getCurrentModuleDirectory() + OUString(RTL_CONSTASCII_USTRINGPARAM(CONFIGMGR_INIFILE)); +} // --------------------------------------------------------------------------------------- - sal_Bool Settings::getBoolSetting(Name const& _pName) const - { - Setting aSetting = this->getSetting(_pName); - return aSetting.toBool(); - } +OUString BootstrapContext::makeContextName(OUString const & _aName) +{ + // check that it isn't long already + OSL_ENSURE(!_aName.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_MODULE_PREFIX_) ), + "configmgr::BootstrapContext: passing argument in long context form won't work"); -// --------------------------------------------------------------------------------------- - ConnectionSettings::ConnectionSettings(const uno::Sequence< uno::Any >& _rOverrides, - Settings::Origin _eOrigin) - : m_aSettings(_rOverrides, _eOrigin) + return NAME(CONTEXT_ITEM_PREFIX_).concat(_aName); +} +// --------------------------------------------------------------------------- + +OUString BootstrapContext::makeBootstrapName(OUString const & _aName) +{ + // check if already is short + if (!_aName.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_PREFIX_) ) ) { - // translate compatibility and special settings - implNormalizeSettings(); + OSL_TRACE( "configmgr: Cannot map name to bootstrap name: %s", + rtl::OUStringToOString(_aName,RTL_TEXTENCODING_ASCII_US).getStr() ); + return _aName; } + return NAME(BOOTSTRAP_ITEM_PREFIX_).concat(_aName.copy(RTL_CONSTASCII_LENGTH(CONTEXT_ITEM_PREFIX_))); +} +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- +uno::Any SAL_CALL + BootstrapContext::getValueByName( const OUString& aName ) + throw (uno::RuntimeException) +{ + sal_Bool const bOurName = aName.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_MODULE_PREFIX_) ); - uno::Sequence< beans::NamedValue > ConnectionSettings::getUnoSettings() const + if (bOurName) { - uno::Sequence< beans::NamedValue > aResult( m_aSettings.size() ); - - beans::NamedValue * p = aResult.getArray(); + if (aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_BOOTSTRAP_ERROR) ) ) + return this->makeBootstrapException(); - for ( Settings::Iterator it = m_aSettings.begin(); it != m_aSettings.end(); ++it ) - { - p->Name = it->first; - p->Value = it->second.value(); - ++p; - } - - OSL_ASSERT(p - aResult.getConstArray() == aResult.getLength()); - - return aResult; - } -// --------------------------------------------------------------------------------------- + if (aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_PREFIX_ SETTING_INIFILE) ) ) + return uno::makeAny( this->getBootstrapURL() ); - void ConnectionSettings::setSessionType(const OUString& _rSessionIdentifier, Settings::Origin _eOrigin) - { - putSetting(NAME(SETTING_SERVERTYPE), Settings::Setting(_rSessionIdentifier, _eOrigin)); + if (aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_IS_BOOTSTRAP_CONTEXT) ) ) + return uno::makeAny( sal_True ); } - -// --------------------------------------------------------------------------------------- - void ConnectionSettings::setService(const OUString& _rService, Settings::Origin _eOrigin) + else if (aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SINGLETON_ A_BootstrapContextSingletonName) ) ) { - putSetting(NAME(SETTING_SERVICE), Settings::Setting(_rService, _eOrigin)); + return uno::makeAny( Context(this) ); } -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isSessionTypeKnown() const { return haveSetting(NAME(SETTING_SERVERTYPE)); } - sal_Bool ConnectionSettings::hasUnoBackendService() const { return haveSetting(NAME(SETTING_UNOSERVICE)); } - sal_Bool ConnectionSettings::hasUnoBackendWrapper() const { return haveSetting(NAME(SETTING_UNOWRAPPER)); } - sal_Bool ConnectionSettings::hasUser() const { return haveSetting(NAME(SETTING_USER)); } - sal_Bool ConnectionSettings::hasPassword() const { return haveSetting(NAME(SETTING_PASSWORD)); } - sal_Bool ConnectionSettings::hasLocale() const { return haveSetting(NAME(SETTING_LOCALE)); } - sal_Bool ConnectionSettings::hasServer() const { return haveSetting(NAME(SETTING_SERVER)); } - sal_Bool ConnectionSettings::hasService() const { return haveSetting(NAME(SETTING_SERVICE)); } - sal_Bool ConnectionSettings::hasPort() const { return haveSetting(NAME(SETTING_PORT)); } - sal_Bool ConnectionSettings::hasTimeout() const { return haveSetting(NAME(SETTING_TIMEOUT)); } - sal_Bool ConnectionSettings::hasAsyncSetting() const { return haveSetting(NAME(SETTING_ASYNC)); } - sal_Bool ConnectionSettings::hasOfflineSetting() const { return haveSetting(NAME(SETTING_OFFLINE)); } - sal_Bool ConnectionSettings::hasReinitializeFlag() const { return haveSetting(NAME(SETTING_REINITIALIZE)); } + uno::Any aResult; -// --------------------------------------------------------------------------------------- - OUString ConnectionSettings::getSessionType() const { return m_aSettings.getStringSetting(NAME(SETTING_SERVERTYPE)); } - OUString ConnectionSettings::getUnoBackendService() const { return m_aSettings.getStringSetting(NAME(SETTING_UNOSERVICE)); } - OUString ConnectionSettings::getUnoBackendWrapper() const { return m_aSettings.getStringSetting(NAME(SETTING_UNOWRAPPER)); } - OUString ConnectionSettings::getUser() const { return m_aSettings.getStringSetting(NAME(SETTING_USER)); } - OUString ConnectionSettings::getPassword() const { return m_aSettings.getStringSetting(NAME(SETTING_PASSWORD)); } - OUString ConnectionSettings::getLocale() const { return m_aSettings.getStringSetting(NAME(SETTING_LOCALE)); } - OUString ConnectionSettings::getSourcePath() const { return m_aSettings.getStringSetting(NAME(SETTING_SOURCEPATH)); } - OUString ConnectionSettings::getUpdatePath() const { return m_aSettings.getStringSetting(NAME(SETTING_UPDATEPATH)); } - OUString ConnectionSettings::getServer() const { return m_aSettings.getStringSetting(NAME(SETTING_SERVER)); } - OUString ConnectionSettings::getService() const { return m_aSettings.getStringSetting(NAME(SETTING_SERVICE)); } - sal_Int32 ConnectionSettings::getPort() const { return m_aSettings.getIntSetting(NAME(SETTING_PORT)); } - sal_Int32 ConnectionSettings::getTimeout() const { return m_aSettings.getIntSetting(NAME(SETTING_TIMEOUT)); } - sal_Bool ConnectionSettings::getAsyncSetting() const { return m_aSettings.getBoolSetting(NAME(SETTING_ASYNC)); } - sal_Bool ConnectionSettings::getOfflineSetting() const { return m_aSettings.getBoolSetting(NAME(SETTING_OFFLINE)); } - sal_Bool ConnectionSettings::getReinitializeFlag() const { return m_aSettings.getBoolSetting(NAME(SETTING_REINITIALIZE)); } + bool bFound = lookupInContext ( aResult, aName ); -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isSourcePathValid() const + if (!bFound && bOurName) // requires: CONTEXT_ITEM_PREFIX_ starts with CONTEXT_MODULE_PREFIX_ { - return haveSetting(NAME(SETTING_SOURCEPATH)); + if ( aName.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_PREFIX_) ) ) + { + bFound = lookupInBootstrap( aResult, makeBootstrapName(aName) ); + } } - -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isUpdatePathValid() const +#if 0 + if (!bFound && bOurName) { - return haveSetting(NAME(SETTING_UPDATEPATH)); + OSL_TRACE( "configmgr: Cannot find bootstrap data item: %s", + rtl::OUStringToOString(aName,RTL_TEXTENCODING_ASCII_US).getStr() ); } +#endif + return aResult; +} +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - static inline bool isValidFileURL(OUString const& _sFileURL) +#if 0 +uno::Any BootstrapContext::makeDefaultProvider() +{ { - using osl::File; - - OUString sSystemPath; - return _sFileURL.getLength() && (File::E_None == File::getSystemPathFromFileURL(_sFileURL, sSystemPath)); + osl::MutexGuard lock(mutex()); + if (m_xDefaultProvider.is()) + return uno::makeAny(m_xDefaultProvider); } -// --------------------------------------------------------------------------------------- - static - bool implEnsureAbsoluteURL(OUString & _rsURL) // also strips embedded dots etc. + + if (isPassthrough()) { - using osl::File; + Context xDelegate = basecontext(); + if (!xDelegate.is()) + throw lang::DisposedException(NAME("BootstrapContext: No base context"),*this); - OUString sBasePath = _rsURL; - OSL_VERIFY(osl_Process_E_None == osl_getProcessWorkingDir(&sBasePath.pData)); + uno::Any aResult = xDelegate->getValueByName( SINGLETON(A_DefaultProviderSingletonName) ); - OUString sAbsolute; - if ( File::E_None == File::getAbsoluteFileURL(sBasePath, _rsURL, sAbsolute)) + osl::MutexGuard relock(mutex()); + if (!m_xDefaultProvider.is()) { - _rsURL = sAbsolute; - return true; + aResult >>= m_xDefaultProvider; + return aResult; } else - { - OSL_ENSURE(false, "Could not get absolute file URL for valid URL"); - return false; - } + return uno::makeAny(m_xDefaultProvider); } -// --------------------------------------------------------------------------------------- - - static - bool implNormalizeURL(OUString const & _sPathOrURL, OUString& _rsURL) + else { - using osl::File; - - OUString sOther; + ServiceManager xMgr = this->getServiceManager(); + if (!xMgr.is()) + throw lang::DisposedException(NAME("BootstrapContext: No service factory"),*this); - bool bURL = false; - - // if empty, clear _rsURL, but return false - if (_sPathOrURL.getLength() == 0) + try { - _rsURL = _sPathOrURL; - bURL = false; - } + uno::Reference<uno::XInterface> xDefaultProvider = xMgr->createInstanceWithContext(NAME(A_DefaultProviderServiceAndImplName),this); - // check if it already was normalized - else if ( File::E_None == File::getSystemPathFromFileURL(_sPathOrURL, sOther) ) - { - _rsURL = _sPathOrURL; - bURL = true; - } + osl::MutexGuard relock(mutex()); + if (!m_xDefaultProvider.is()) + m_xDefaultProvider = xDefaultProvider; - // allow for system pathes - else if ( File::E_None == File::getFileURLFromSystemPath(_sPathOrURL, sOther) ) + return uno::makeAny(m_xDefaultProvider); + } + catch (uno::RuntimeException &) { throw; } + catch (uno::Exception & ) { - CFG_TRACE_WARNING_NI("provider bootstrapping: URL was specified as system path '%s'.", OUSTRING2ASCII(_sPathOrURL)); - _rsURL = sOther; - bURL = true; + throw uno::RuntimeException(NAME("BootstrapContext:Exception occurred while instantiating DefaultProvider"),*this); } - - else - bURL = false; - - return bURL && implEnsureAbsoluteURL(_rsURL); } -// --------------------------------------------------------------------------------------- - bool ConnectionSettings::implNormalizePathSetting(Settings::Name const& _pSetting) - { - using osl::File; - - if (!haveSetting(_pSetting)) - return false; +} +// --------------------------------------------------------------------------- - Settings::Setting aSetting = getSetting(_pSetting); +uno::Any BootstrapContext::makeDefaultBackend() +{ + { + osl::MutexGuard lock(mutex()); + if (m_xDefaultBackend.is()) + return uno::makeAny(m_xDefaultBackend); + } - OUString const sValue = aSetting.toString(); + if (isPassthrough()) + { + Context xDelegate = basecontext(); + if (!xDelegate.is()) + throw lang::DisposedException(NAME("BootstrapContext: No base context"),*this); - OUString sNormalized; + uno::Any aResult = xDelegate->getValueByName( SINGLETON(K_DefaultBackendSingletonName) ); - if ( implNormalizeURL(sValue,sNormalized) ) + osl::MutexGuard relock(mutex()); + if (!m_xDefaultBackend.is()) { - putSetting(_pSetting, Settings::Setting(sNormalized,aSetting.origin()) ); - return true; + aResult >>= m_xDefaultBackend; + return aResult; } else - { - CFG_TRACE_ERROR_NI("provider bootstrapping: could not normalize URL (setting: %s, value: %s).", OUSTRING2ASCII(_pSetting), OUSTRING2ASCII(sValue)); - clearSetting(_pSetting); - return false; - } + return uno::makeAny(m_xDefaultBackend); } - -// --------------------------------------------------------------------------------------- - bool ConnectionSettings::checkSettings() const + else { - bool bCheckResult = true; + ServiceManager xMgr = this->getServiceManager(); + if (!xMgr.is()) + throw lang::DisposedException(NAME("BootstrapContext: No service factory"),*this); - #if 0 // defined(_DEBUG) || defined(CFG_ENABLE_TRACING) - const int cKnownSettingsCount = sizeof(pKnownSettings)/sizeof(pKnownSettings[0]); + try + { + uno::Reference<uno::XInterface> xDefaultBackend = xMgr->createInstanceWithContext(NAME(K_DefaultBackendServiceAndImplName),this); - // check if we know all the settings - for ( Settings::Iterator aCheck = m_aSettings.begin(); - aCheck != m_aSettings.end(); - ++aCheck - ) + osl::MutexGuard relock(mutex()); + if (!m_xDefaultBackend.is()) + m_xDefaultBackend = xDefaultBackend; + return uno::makeAny(m_xDefaultBackend); + } + catch (uno::RuntimeException &) { throw; } + catch (uno::Exception & ) { - bool bRecognized = false; - for (sal_Int32 i=0; i<cKnownSettingsCount; ++i) - { - if (aCheck->first.equalsAscii(pKnownSettings[i])) - { - bRecognized = true; - break; - } - } - - if (!bRecognized) - { - OSL_ENSURE(bRecognized, "Configuration: unknown provider parameter\n"); - CFG_TRACE_WARNING_NI("provider bootstrapping: unrecognized parameter found: %s", aCheck->first.getStr() ); - bCheckResult = false; - } + throw uno::RuntimeException(NAME("BootstrapContext:Exception occurred while instantiating DefaultBackend"),*this); } - #endif - - return bCheckResult; } +} +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - bool ConnectionSettings::validate() +uno::Any BootstrapContext::makeDefaultSingleBackend() +{ { - checkSettings(); - - // determine the session type - implDetermineSessionType(); - - return implDetermineSessionType() && isComplete( getSessionType() ); + osl::MutexGuard lock(mutex()); + if (m_xDefaultSingleBackend.is()) + return uno::makeAny(m_xDefaultSingleBackend); } -// --------------------------------------------------------------------------------------- - bool ConnectionSettings::isComplete() const + if (isPassthrough()) { - return isSessionTypeKnown() && ! isPlugin() && isComplete(getSessionType()); - } + Context xDelegate = basecontext(); + if (!xDelegate.is()) + throw lang::DisposedException(NAME("BootstrapContext: No base context"),*this); -// --------------------------------------------------------------------------------------- - bool ConnectionSettings::isComplete(OUString const& sSessionType) const - { - if( (0 == sSessionType.compareToAscii(LOCAL_SESSION_IDENTIFIER)) || - (0 == sSessionType.compareToAscii(SETUP_SESSION_IDENTIFIER)) ) - { - // local sessions needs a source path - return !! isSourcePathValid(); - } + uno::Any aResult = xDelegate->getValueByName( SINGLETON(K_DefaultSingleBackendSingletonName) ); - else if(0 == sSessionType.compareToAscii(UNO_SESSION_IDENTIFIER) ) + osl::MutexGuard relock(mutex()); + if (!m_xDefaultSingleBackend.is()) { - // cannot check backend-specific arguments here - return hasUnoBackendService() || - hasUnoBackendWrapper() && hasOfflineSetting() && getOfflineSetting(); + aResult >>= m_xDefaultSingleBackend; + return aResult; } + else + return uno::makeAny(m_xDefaultSingleBackend); + } + else + { + ServiceManager xMgr = this->getServiceManager(); + if (!xMgr.is()) + throw lang::DisposedException(NAME("BootstrapContext: No service factory"),*this); - else if(0 == sSessionType.compareToAscii(PORTAL_SESSION_IDENTIFIER) ) + try { - return true; - } + uno::Reference<uno::XInterface> xDefaultSingleBackend = xMgr->createInstanceWithContext(NAME(K_DefaultSingleBackendServiceAndImplName),this); - else if(0 == sSessionType.compareToAscii(REMOTE_SESSION_IDENTIFIER) ) - { - // remote sessions needs a server (and a user ?) - return hasServer() && hasUser(); + osl::MutexGuard relock(mutex()); + if (!m_xDefaultSingleBackend.is()) + m_xDefaultSingleBackend = xDefaultSingleBackend; + + return uno::makeAny(m_xDefaultSingleBackend); } - else + catch (uno::RuntimeException &) { throw; } + catch (uno::Exception & ) { - OSL_ENSURE(0 == sSessionType.compareToAscii(PLUGIN_SESSION_IDENTIFIER), - "Unknown session type, cannot determine validity of settings"); - return false; // assume false + throw uno::RuntimeException(NAME("BootstrapContext:Exception occurred while instantiating DefaultSingleBackend"),*this); } - } +} +// --------------------------------------------------------------------------- +#endif +// --------------------------------------------------------------------------- +// class ContextReader +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - void ConnectionSettings::implMergeOverrides(const Settings& _rOverrides) + ContextReader::ContextReader(Context const & context) + : m_basecontext(context) + , m_fullcontext() { - // update path validity depends on data in its base source path - if (_rOverrides.haveSetting(NAME(SETTING_SOURCEPATH))) + OSL_ENSURE(context.is(), "ERROR: trying to create reader on NULL context\n"); + if (context.is()) { - this->clearSetting(NAME(SETTING_SOURCEPATH)); - this->clearSetting(NAME(SETTING_UPDATEPATH)); + uno::Any aBootstrapContext = context->getValueByName( SINGLETON(A_BootstrapContextSingletonName) ); + aBootstrapContext >>= m_fullcontext; } + } +// --------------------------------------------------------------------------- - // port is only valid relative to server (and may even be part of the server setting) - if (_rOverrides.haveSetting(NAME(SETTING_SERVER))) - { - this->clearSetting(NAME(SETTING_SERVER)); - this->clearSetting(NAME(SETTING_PORT)); - } + uno::Reference< lang::XMultiComponentFactory > ContextReader::getServiceManager() const + { + OSL_ASSERT(m_basecontext.is()); + return m_basecontext->getServiceManager(); + } +// --------------------------------------------------------------------------- + inline + uno::Any ContextReader::getSetting(OUString const & _aSetting) const + { + OSL_ASSERT(m_basecontext.is()); + return getBestContext()->getValueByName(_aSetting); + } - // if changing the user, password must be changed as well - if (_rOverrides.haveSetting(NAME(SETTING_USER))) - { - this->clearSetting(NAME(SETTING_USER)); - this->clearSetting(NAME(SETTING_PASSWORD)); - } + inline + sal_Bool ContextReader::hasSetting(OUString const & _aSetting) const + { + return getSetting(_aSetting).hasValue(); + } - m_aSettings.mergeOverrides(_rOverrides); + inline + sal_Bool ContextReader::getBoolSetting(OUString const & _aSetting, sal_Bool bValue = false) const + { + getSetting(_aSetting) >>= bValue; + return bValue; } + inline + OUString ContextReader::getStringSetting(OUString const & _aSetting, OUString aValue = OUString()) const + { + getSetting(_aSetting) >>= aValue; + return aValue; + } // --------------------------------------------------------------------------------------- - void ConnectionSettings::implNormalizeRemoteServer() + + sal_Bool ContextReader::isUnoBackend() const { - Settings::Name const sServerSetting = NAME(SETTING_SERVER); - Settings::Name const sPortSetting = NAME(SETTING_PORT); + OUString aSettingName = NAME(BOOTSTRAP_SERVERTYPE_COMPAT); - if (haveSetting(sServerSetting) && !haveSetting(sPortSetting)) + OUString aValue; + if (getSetting(aSettingName) >>= aValue) { - Settings::Setting aServerData = getSetting(sServerSetting); - - OUString sServerAndPort = aServerData.toString(); - - // there was such an entry - const sal_Int32 nColon = sServerAndPort.lastIndexOf(':'); - if (0 <= nColon) - { - if (sal_Int32 nPort = sServerAndPort.copy(nColon+1).toInt32()) - { - OUString sServer = sServerAndPort.copy(0, nColon); - - Settings::Origin eOrigin = aServerData.origin(); - putSetting(sServerSetting, Settings::Setting(sServer, eOrigin)); - putSetting(sPortSetting, Settings::Setting(nPort, eOrigin)); - } - } + return aValue.equalsAscii(SERVERTYPE_UNO_COMPAT); + } + else + { + return true; } - } // --------------------------------------------------------------------------------------- - void ConnectionSettings::implNormalizeSettings() - { - implNormalizePathSetting(NAME(SETTING_SOURCEPATH)); - implNormalizePathSetting(NAME(SETTING_UPDATEPATH)); - implNormalizeRemoteServer(); + sal_Bool ContextReader::hasUnoBackendService() const + { + return hasSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_UNOSERVICE) ); } - -// --------------------------------------------------------------------------------------- - bool ConnectionSettings::implDetermineSessionType() + sal_Bool ContextReader::hasUnoBackendWrapper() const { - Settings::Name const sSettingServertype = NAME(SETTING_SERVERTYPE); - if (!haveSetting(sSettingServertype)) - { // we already have the setting - CFG_TRACE_INFO("provider bootstrapping: no session type. looking for fallback"); - - char const * psSessionType = NULL; - if (haveSetting(NAME(SETTING_UNOSERVICE))) - { - psSessionType = UNO_SESSION_IDENTIFIER; - } - else if (haveSetting(NAME(SETTING_SOURCEPATH)) && haveSetting(NAME(SETTING_UPDATEPATH))) - { - psSessionType = LOCAL_SESSION_IDENTIFIER; - } - else if (haveSetting(NAME(SETTING_SERVER))) - { - psSessionType = REMOTE_SESSION_IDENTIFIER; - } - else if (haveSetting(NAME(SETTING_SERVICE))) - { - psSessionType = PORTAL_SESSION_IDENTIFIER; - } - else - { - CFG_TRACE_WARNING_NI("provider bootstrapping: cannot determine session type" - "- using fallback to '"UNO_SESSION_IDENTIFIER"'"); - psSessionType = PORTAL_SESSION_IDENTIFIER; - } - - if (!psSessionType) - { - CFG_TRACE_WARNING_NI("provider bootstrapping: cannot determine session type"); - return false; - } - - OUString sSessionType = OUString::createFromAscii(psSessionType); - putSetting(sSettingServertype, Settings::Setting(sSessionType, Settings::SO_FALLBACK)); - } - CFG_TRACE_INFO_NI("provider bootstrapping: using session type: %s", - OUSTRING2ASCII(m_aSettings.getStringSetting(sSettingServertype))); - - return true; + return hasSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_UNOWRAPPER) ); } + sal_Bool ContextReader::hasLocale() const + { + return hasSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_LOCALE_NEW) ); + } + sal_Bool ContextReader::hasAsyncSetting() const + { + return hasSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_ASYNC_NEW) ); + } + sal_Bool ContextReader::hasOfflineSetting() const + { + return hasSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_OFFLINE) ); + } // --------------------------------------------------------------------------------------- - bool ConnectionSettings::isUnoBackend() const + OUString ContextReader::getUnoBackendService() const { - if (!isSessionTypeKnown()) return false; - - OUString const sSessionType = getSessionType(); - return (0 == sSessionType.compareToAscii(UNO_SESSION_IDENTIFIER)); + return getStringSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_UNOSERVICE) ); } -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isPlugin() const + OUString ContextReader::getUnoBackendWrapper() const { - if (!isSessionTypeKnown()) return false; - - OUString const sSessionType = getSessionType(); - return (0 == sSessionType.compareToAscii(PLUGIN_SESSION_IDENTIFIER)); - + return getStringSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_UNOWRAPPER) ); } -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isLocalSession() const + OUString ContextReader::getLocale() const { - if (!isSessionTypeKnown()) return false; - - OUString const sSessionType = getSessionType(); - return (0 == sSessionType.compareToAscii(LOCAL_SESSION_IDENTIFIER)) || - (0 == sSessionType.compareToAscii(SETUP_SESSION_IDENTIFIER)); - + return getStringSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_LOCALE_NEW) ); } - -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isRemoteSession() const + sal_Bool ContextReader::getAsyncSetting() const { - if (!isSessionTypeKnown()) return false; - - OUString const sSessionType = getSessionType(); - return (0 == sSessionType.compareToAscii(PORTAL_SESSION_IDENTIFIER)) || - (0 == sSessionType.compareToAscii(REMOTE_SESSION_IDENTIFIER)); - + return getBoolSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_ASYNC_NEW) ); } - -// --------------------------------------------------------------------------------------- - sal_Bool ConnectionSettings::isServiceRequired() const + sal_Bool ContextReader::getOfflineSetting() const { - OUString const sSessionType = getSessionType(); - return (0 == sSessionType.compareToAscii(PORTAL_SESSION_IDENTIFIER)); - + return getBoolSetting( NAME(CONTEXT_ITEM_PREFIX_ SETTING_OFFLINE) ); } -// --------------------------------------------------------------------------------------- - - sal_Bool ConnectionSettings::isAdminSession() const + // get a special setting + sal_Bool ContextReader::isAdminService() const { - OSL_ENSURE(haveSetting(NAME(SETTING_SESSIONCLASS)),"Cannot determine session class"); + return getBoolSetting( NAME(CONTEXT_ITEM_ADMINFLAG) ); + } - return getSetting(NAME(SETTING_SESSIONCLASS)).toString().equalsAscii(SERVICE_ADMINSESSION); + sal_Bool ContextReader::isBootstrapValid() const + { + return this->isUnoBackend() && + this->hasUnoBackendService() && + (this->hasUnoBackendWrapper() || !this->getOfflineSetting()); + } + uno::Any ContextReader::getBootstrapError() const + { + return getSetting( NAME(CONTEXT_ITEM_BOOTSTRAP_ERROR) ); } // --------------------------------------------------------------------------------------- - void ConnectionSettings::setUserSession() + bool ContextReader::isBootstrapContext(Context const & _xContext) { - OSL_ENSURE(isUnoBackend() || isLocalSession() || isRemoteSession(),"Invalid/No session type for user session"); - OSL_ENSURE(getSessionType().compareToAscii(SETUP_SESSION_IDENTIFIER) != 0, "WARNING: Explicit creation of 'setup' sessions is obsolete. Create 'AdministrationProvider' service instead"); + OSL_ASSERT(_xContext.is()); + if (!_xContext.is()) return false; - OUString const sService( RTL_CONSTASCII_USTRINGPARAM(SERVICE_USERSESSION) ); + uno::Any aSetting = _xContext->getValueByName( NAME(CONTEXT_ITEM_IS_BOOTSTRAP_CONTEXT) ); - if( !hasService() && isServiceRequired() ) - { - CFG_TRACE_INFO("No service set for user session. Using default service '%s'",OUSTRING2ASCII(sService)); - - this->setService(sService, Settings::SO_DEFAULT); - } - - if ( !hasAsyncSetting() ) - { - Any aDefaultAsync = makeAny(sal_Bool(true)); - putSetting( NAME(SETTING_ASYNC), Settings::Setting(aDefaultAsync, Settings::SO_DEFAULT) ); - OSL_ASSERT( hasAsyncSetting() && getAsyncSetting() ); - } - - putSetting(NAME(SETTING_SESSIONCLASS),Settings::Setting(sService, Settings::SO_DEFAULT)); + sal_Bool bValue = false; + return (aSetting >>= bValue) && bValue; } +// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------- - void ConnectionSettings::setAdminSession() + bool ContextReader::testAdminService(Context const & context, bool bAdmin) { - OSL_ENSURE(isUnoBackend() || isLocalSession() || isRemoteSession(),"Invalid/No session type for admin session"); - if (isLocalSession()) - { - OSL_ENSURE(!hasUser(), "Local Admin Session has 'user' parameter - ignoring (admin data will be used)"); - - if (getSessionType().compareToAscii(LOCAL_SESSION_IDENTIFIER) == 0) - { - CFG_TRACE_INFO("Local Admin session: Changing session type to 'setup'"); - - OUString const sSetup( RTL_CONSTASCII_USTRINGPARAM(SETUP_SESSION_IDENTIFIER) ); - this->setSessionType(sSetup,Settings::SO_DEFAULT); - } - else - OSL_ENSURE(getSessionType().compareToAscii(SETUP_SESSION_IDENTIFIER) != 0, "WARNING: Explicit creation of 'setup' sessions is obsolete. "); - } + OSL_ASSERT(context.is()); + if (!context.is()) return false; - OUString const sService( RTL_CONSTASCII_USTRINGPARAM(SERVICE_ADMINSESSION) ); + uno::Any aSetting = context->getValueByName( NAME(CONTEXT_ITEM_ADMINFLAG) ); - if( !hasService() && isServiceRequired() ) - { - CFG_TRACE_INFO("No service set for admin session. Using default service '%s'",OUSTRING2ASCII(sService)); + sal_Bool bValue = false; + bool bTest = (aSetting >>= bValue) && bValue; - this->setService(sService, Settings::SO_DEFAULT); - } + return bTest == bAdmin; + } +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------------------- - if ( !hasAsyncSetting() ) + bool ArgumentHelper::extractArgument(beans::NamedValue & rValue, const uno::Any & aOverride) + { + if ( ! (aOverride >>= rValue) ) { - Any aDefaultNoAsync = makeAny(sal_Bool(false)); - putSetting( NAME(SETTING_ASYNC), Settings::Setting(aDefaultNoAsync, Settings::SO_DEFAULT) ); - OSL_ASSERT( hasAsyncSetting() && !getAsyncSetting() ); - } + // it must be a PropertyValue, if it isn't a NamedValue + beans::PropertyValue aPV; + if ( !(aOverride >>= aPV) ) + return false; - if (!hasLocale()) - { - CFG_TRACE_INFO("Settings for Admin session: Using 'all locales' by default"); - this->setAnyLocale(Settings::SO_DEFAULT); + rValue.Name = aPV.Name; + rValue.Value = aPV.Value; } - putSetting(NAME(SETTING_SESSIONCLASS),Settings::Setting(sService, Settings::SO_DEFAULT)); + return true; } // --------------------------------------------------------------------------------------- - void ConnectionSettings::setAnyLocale(Settings::Origin _eOrigin) + + bool ArgumentHelper::checkBackendArgument(beans::NamedValue const & aAdjustedValue) { - rtl::OUString sAnyLocale = localehelper::getAnyLocale(); + bool isWrappable = + aAdjustedValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_PREFIX_ SETTING_ASYNC_NEW)) || + aAdjustedValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(CONTEXT_ITEM_PREFIX_ SETTING_LOCALE_NEW)); + + if (isWrappable) return false; - this->putSetting( NAME(SETTING_LOCALE), Settings::Setting(sAnyLocale, _eOrigin)); + m_bHasBackendArguments = true; + return true; } // --------------------------------------------------------------------------------------- - void ConnectionSettings::setUserSession(const OUString& _rRemoteServiceName) - { - this->setService(_rRemoteServiceName, Settings::SO_MANUAL); - this->setUserSession(); - } -// --------------------------------------------------------------------------------------- - void ConnectionSettings::setAdminSession(const OUString& _rRemoteServiceName) + bool ArgumentHelper::filterAndAdjustArgument(beans::NamedValue & rValue) { - this->setService(_rRemoteServiceName, Settings::SO_MANUAL); - this->setAdminSession(); - } + // handle old servertype argument and filter the 'plugin' value + if (rValue.Name.equalsAscii(ARGUMENT_SERVERTYPE_COMPAT)) + { + OUString aServertype; + if (! (rValue.Value >>= aServertype)) + return false; -// --------------------------------------------------------------------------------------- - IConfigSession* ConnectionSettings::createConnection(Reference<XMultiServiceFactory> const& _rxServiceMgr) const - { - OUString sSessionType = getSessionType(); - OSL_ENSURE(!isPlugin(), "Settings::createConnection: can't create a plugin session!"); + if (aServertype.equalsAscii(SERVERTYPE_PLUGIN_COMPAT)) + return false; - for(int i= 0; i<nSessionClasses; ++i) - { - if (0 == sSessionType.compareToAscii(aSessionClasses[i].name)) - { - return aSessionClasses[i].create(_rxServiceMgr, *this); - } + rValue.Name = NAME(BOOTSTRAP_SERVERTYPE_COMPAT); + // check, if it is already there + uno::Any const aExistingValue = m_context->getValueByName(rValue.Name); + + if (aExistingValue.hasValue()) + return !(aExistingValue == rValue.Value); + + else + return !aServertype.equalsAscii(SERVERTYPE_UNO_COMPAT); } - OSL_ENSURE(false, "unable to bootstrap the configuration - no match for session type!"); - return 0; - } + // map old argument names for comatibility + else if (rValue.Name.equalsAscii(ARGUMENT_LOCALE_COMPAT)) + rValue.Name = NAME(SETTING_LOCALE_NEW); -// --------------------------------------------------------------------------------------- -// caching helpers -//--------------------------------------------------------------------------------------- - OUString buildConnectString(const ConnectionSettings& _rSettings) - { - OSL_ENSURE(_rSettings.isComplete(),"WARNING: creating connect string for incomplete settings"); + else if (rValue.Name.equalsAscii(ARGUMENT_ASYNC_COMPAT)) + rValue.Name = NAME(SETTING_ASYNC_NEW); - rtl::OUStringBuffer sConnect = _rSettings.getSessionType(); + // give the item a long name + rValue.Name = BootstrapContext::makeContextName(rValue.Name); -#if 0 // disabled: service may not be set - if (_rSettings.isServiceRequired() && _rSettings.hasService()) - { - sConnect.append(sal_Unicode(':')); - sConnect.append(_rSettings.getService()); - } -#endif - if (_rSettings.isUnoBackend()) - { - // no support for connection strings - return OUString(); - } - else if (_rSettings.isLocalSession()) - { - if (_rSettings.isSourcePathValid()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(":share@")); - sConnect.append(_rSettings.getSourcePath()); - } - if (_rSettings.isUpdatePathValid()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(":user@")); - sConnect.append(_rSettings.getUpdatePath()); - } - // maybe consider user here as well ? - } - else if (_rSettings.isRemoteSession()) - { - if (_rSettings.hasServer() || _rSettings.hasPort()) - { - sConnect.append(sal_Unicode('@')); - - if ( _rSettings.hasServer()) - { - sConnect.append(_rSettings.getServer()); - } - - if ( _rSettings.hasPort()) - { - sConnect.append(sal_Unicode(':')); - sConnect.append(_rSettings.getPort()); - } - } - - if (_rSettings.hasUser()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";user=")); - sConnect.append(_rSettings.getUser()); - } - if (_rSettings.hasPassword()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";pwd=")); - sConnect.append(_rSettings.getPassword()); - } - if (_rSettings.hasTimeout()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";timeout=")); - sConnect.append( _rSettings.getTimeout()); - } - } - else - { - OSL_ENSURE(false, "Unknown session type"); - } + // check, if it is already there + uno::Any const aExistingValue = m_context->getValueByName(rValue.Name); - if (_rSettings.hasLocale()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";locale=")); - sConnect.append(_rSettings.getLocale()); - } - if (_rSettings.hasAsyncSetting()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";async=")); - sConnect.append(_rSettings.getAsyncSetting()); - } - if (_rSettings.hasReinitializeFlag() && _rSettings.getReinitializeFlag()) - { - sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";reinitialize=")); - sConnect.append(_rSettings.getReinitializeFlag()); - } + return ! (aExistingValue == rValue.Value); + } +// --------------------------------------------------------------------------------------- - return sConnect.makeStringAndClear(); + beans::NamedValue ArgumentHelper::makeAdminServiceOverride(sal_Bool bAdmin) + { + return beans::NamedValue( NAME(CONTEXT_ITEM_ADMINFLAG), uno::makeAny(bAdmin) ); } // --------------------------------------------------------------------------------------- -// - bootstrapping helper +// --------------------------------------------------------------------------------------- +// - bootstrapping error checking helper // --------------------------------------------------------------------------------------- namespace { // --------------------------------------------------------------------------------------- @@ -1208,7 +814,7 @@ namespace { // --------------------------------------------------------------------------------------- static - void impl_raiseBootstrapException( BootstrapResult _rc, OUString const& _sMessage, OUString const& _sURL, Reference< XInterface > _xContext ) + uno::Any impl_makeBootstrapException( BootstrapResult _rc, OUString const& _sMessage, OUString const& _sURL, uno::Reference< uno::XInterface > _xContext ) { OUString sMessage(_sMessage); // ensure a message @@ -1225,348 +831,31 @@ namespace { switch (_rc) { case MISSING_BOOTSTRAP_FILE: - throw MissingBootstrapFileException(sMessage, _xContext, _sURL); + return uno::makeAny( MissingBootstrapFileException(sMessage, _xContext, _sURL) ); case INCOMPLETE_BOOTSTRAP_FILE: - throw InvalidBootstrapFileException(sMessage, _xContext, _sURL); + return uno::makeAny( InvalidBootstrapFileException(sMessage, _xContext, _sURL) ); default: OSL_ENSURE(false, "Undefined BootstrapResult code"); case INCOMPLETE_BOOTSTRAP_DATA: case BOOTSTRAP_FAILURE: - throw CannotLoadConfigurationException(sMessage, _xContext); + return uno::makeAny( CannotLoadConfigurationException(sMessage, _xContext) ); case BOOTSTRAP_DATA_OK: break; } + return uno::Any(); } // --------------------------------------------------------------------------------------- -} // anonymous namespace - -// --------------------------------------------------------------------------------------- -// bootstrapping -// --------------------------------------------------------------------------------------- - -BootstrapSettings::Context getBootstrapContext(const Reference< XMultiServiceFactory >& _xORB) -{ - Reference< XComponentContext > xContext; - - Reference< XPropertySet > xORBPS( _xORB, UNO_QUERY ); - if (xORBPS.is()) - try - { - OUString const k_CONTEXT(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")); - - OSL_VERIFY( xORBPS->getPropertyValue(k_CONTEXT) >>= xContext ); - } - catch (UnknownPropertyException & ) - { - OSL_TRACE("Warning: Cannot get context - Service manager has no DefaultContext property"); - } - catch (Exception& ) - { - OSL_TRACE("Warning: Cannot get context - Unexpected exception retrieving DefaultContext"); - } - else - OSL_TRACE("Warning: Cannot get context - ServiceManager is no PropertySet"); - return xContext; -} -// --------------------------------------------------------------------------------------- -// class BootstrapSettings::Impl -// --------------------------------------------------------------------------------------- - struct BootstrapSettings::Impl - { - Impl(Context const & xContext); - - bool hasInifile() const; - bool getInifile(OUString& _rInifile) const; - bool hasExistingInifile() const; - - void collectSettings(Settings& _rSettings); - void collectDefaultsFromINI(Settings& _rSettings); - void adjustToInstallation(Settings& _rSettings); - - void addSetting(Settings& _rSettings,Settings::Name const & _sSetting, OUString const& _sBootstrapItem); - void addWithDefault(Settings& _rSettings,Settings::Name const & _sSetting, OUString const& _sBootstrapItem, OUString const& _sDefault); - void maybeAddWithDefault(Settings& _rSettings,Settings::Name const & _sSetting, OUString const& _sBootstrapItem, OUString const& _sDefault); - - BootstrapResult getBootstrapErrorMessage(ConnectionSettings const& _rSettings, OUString& _rMessage, OUString& _rIniFile ) const; - - static bool urlExists(OUString const& _sURL); - - rtl::Bootstrap m_data; - Context m_context; - }; - -// --------------------------------------------------------------------------------------- - - void BootstrapSettings::bootstrap(Context const & xContext) - { - CFG_TRACE_INFO("provider bootstrapping: collecting bootstrap setting"); - - Impl aBootstrapper(xContext); - - aBootstrapper.collectSettings(this->settings.m_aSettings); - - if ( aBootstrapper.hasExistingInifile() ) - aBootstrapper.collectDefaultsFromINI(this->settings.m_aSettings); - - this->settings.implNormalizeSettings(); - - this->valid = this->settings.implDetermineSessionType(); - - aBootstrapper.adjustToInstallation(this->settings.m_aSettings); - this->settings.implNormalizeSettings(); - - if (this->valid) - { - this->valid = this->settings.isComplete(); - - if (!this->valid) - CFG_TRACE_WARNING_NI("provider bootstrapping: bootstrap data is incomplete"); - } - else - { - CFG_TRACE_WARNING_NI("provider bootstrapping: could not collect bootstrap data"); - - if (!this->settings.implDetermineSessionType()) - CFG_TRACE_ERROR_NI("provider bootstrapping: no default session available"); - } - } -// --------------------------------------------------------------------------------------- - - void BootstrapSettings::raiseBootstrapException(Reference< XInterface > const & _xContext ) const - { - if (!this->valid) - { - OUString sMessage,sURL; - - BootstrapResult rc = Impl( Context() ).getBootstrapErrorMessage(this->settings,sMessage,sURL); - - impl_raiseBootstrapException(rc,sMessage,sURL,_xContext); - - OSL_ASSERT(rc == BOOTSTRAP_DATA_OK); - - // could not discover what went wrong => no exception here - OSL_ENSURE(false, "cannot detect bootstrap error"); - } - } -// --------------------------------------------------------------------------------------- - - static OUString getCurrentModuleDirectory() - { - OUString aFileURL; - if ( !osl::Module::getUrlFromAddress((void*)&getCurrentModuleDirectory,aFileURL) ) - { - OSL_TRACE(false, "Cannot locate current module - using executable instead"); - - OSL_VERIFY(osl_Process_E_None == osl_getExecutableFile(&aFileURL.pData)); - } - - OSL_ENSURE(0 < aFileURL.lastIndexOf('/'), "Cannot find directory for module URL"); - - return aFileURL.copy(0, aFileURL.lastIndexOf('/')); - } -// --------------------------------------------------------------------------------------- - OUString BootstrapSettings::getURL() - { - return getCurrentModuleDirectory() + OUString(RTL_CONSTASCII_USTRINGPARAM("/"BOOTSTRAP_CONFIGMGR_DATA)); - } -// --------------------------------------------------------------------------------------- - BootstrapSettings::Impl::Impl(Context const & xContext) - : m_data(getURL()) - , m_context(xContext) - { - } -// --------------------------------------------------------------------------------------- + static inline - bool BootstrapSettings::Impl::urlExists(OUString const& _sURL) + bool urlExists(OUString const& _sURL) { osl::DirectoryItem aCheck; return (osl::DirectoryItem::get(_sURL,aCheck) == osl::DirectoryItem::E_None); } // --------------------------------------------------------------------------------------- - inline - bool BootstrapSettings::Impl::getInifile(OUString& _rInifile) const - { - if (m_data.getFrom(ITEM(BOOTSTRAP_ITEM_PROFILE_NAME),_rInifile)) - { - return true; - } - else - { - return false; - } - } -// --------------------------------------------------------------------------------------- - - bool BootstrapSettings::Impl::hasInifile() const - { - OUString sInifile; - bool bResult = getInifile(sInifile); - return bResult; - } -// --------------------------------------------------------------------------------------- - - bool BootstrapSettings::Impl::hasExistingInifile() const - { - OUString sInifile; - if ( getInifile(sInifile) ) - { - if (urlExists(sInifile)) - { - CFG_TRACE_INFO_NI("provider bootstrapping: using configuration INI file '%'", OUSTRING2ASCII(sInifile)); - return true; - } - else - CFG_TRACE_WARNING_NI("provider bootstrapping: specified configuration INI file '%s' does not exist", OUSTRING2ASCII(sInifile)); - } - else - CFG_TRACE_INFO_NI("provider bootstrapping: no configuration INI file specified"); - - return false; - } -// --------------------------------------------------------------------------------------- - - void BootstrapSettings::Impl::addWithDefault(Settings& _rSettings,Settings::Name const & _sSetting, OUString const& _sBootstrapItem, OUString const& _sDefault) - { - OUString sValue; - m_data.getFrom(_sBootstrapItem, sValue, _sDefault); - if (sValue.getLength()) - _rSettings.putSetting( _sSetting, Settings::Setting(sValue, Settings::SO_INIFILE) ); - } -// --------------------------------------------------------------------------------------- - - void BootstrapSettings::Impl::addSetting(Settings& _rSettings,Settings::Name const & _sSetting, OUString const& _sBootstrapItem) - { - if (m_context.is()) - { - static const OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.bootstrap.")); - uno::Any aValue = m_context->getValueByName( sPrefix + _sSetting ); - - if (aValue.hasValue()) - { - _rSettings.putSetting(_sSetting,Settings::Setting(aValue, Settings::SO_BOOTSTRAP) ); - return; - } - } - - // not available from context - OUString sValue; - if (m_data.getFrom(_sBootstrapItem,sValue)) - { - _rSettings.putSetting(_sSetting,Settings::Setting(sValue, Settings::SO_BOOTSTRAP) ); - } - } -// --------------------------------------------------------------------------------------- - - inline - void BootstrapSettings::Impl::maybeAddWithDefault(Settings& _rSettings,Settings::Name const & _sSetting, OUString const& _sBootstrapItem, OUString const& _sDefault) - { - if (!_rSettings.haveSetting(_sSetting)) - { - addWithDefault(_rSettings,_sSetting,_sBootstrapItem,_sDefault); - } - } -// --------------------------------------------------------------------------------------- - - void BootstrapSettings::Impl::collectDefaultsFromINI(Settings& _rSettings) - { - OUString sDummy; - maybeAddWithDefault(_rSettings, NAME(SETTING_SERVERTYPE), ITEM(BOOTSTRAP_ITEM_SERVERTYPE), ITEM(BOOTSTRAP_SERVERTYPE_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_UNOSERVICE), ITEM(BOOTSTRAP_ITEM_UNOSERVICE), ITEM(BOOTSTRAP_UNOSERVICE_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_UNOWRAPPER), ITEM(BOOTSTRAP_ITEM_UNOWRAPPER), ITEM(BOOTSTRAP_UNOWRAPPER_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_LOCALE), ITEM(BOOTSTRAP_ITEM_LOCALE), ITEM(BOOTSTRAP_LOCALE_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_ASYNC), ITEM(BOOTSTRAP_ITEM_ASYNCENABLE), ITEM(BOOTSTRAP_ASYNCENABLE_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_SOURCEPATH), ITEM(BOOTSTRAP_ITEM_SOURCE_PATH), ITEM(BOOTSTRAP_BASEPATH_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_UPDATEPATH), ITEM(BOOTSTRAP_ITEM_UPDATE_PATH), ITEM(BOOTSTRAP_DATAPATH_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_SERVER), ITEM(BOOTSTRAP_ITEM_SERVER), ITEM(BOOTSTRAP_SERVER_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_TIMEOUT), ITEM(BOOTSTRAP_ITEM_TIMEOUT), ITEM(BOOTSTRAP_TIMEOUT_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_USER), ITEM(BOOTSTRAP_ITEM_USER), ITEM(BOOTSTRAP_USER_FROM_PROFILE) ); - maybeAddWithDefault(_rSettings, NAME(SETTING_PASSWORD), ITEM(BOOTSTRAP_ITEM_PASSWORD), ITEM(BOOTSTRAP_PASSWORD_FROM_PROFILE) ); - - } -// --------------------------------------------------------------------------------------- - - void BootstrapSettings::Impl::collectSettings(Settings& _rSettings) - { - addSetting(_rSettings, NAME(SETTING_SERVERTYPE), ITEM(BOOTSTRAP_ITEM_SERVERTYPE) ); - addSetting(_rSettings, NAME(SETTING_UNOSERVICE), ITEM(BOOTSTRAP_ITEM_UNOSERVICE) ); - addSetting(_rSettings, NAME(SETTING_UNOWRAPPER), ITEM(BOOTSTRAP_ITEM_UNOWRAPPER) ); - addSetting(_rSettings, NAME(SETTING_OFFLINE), ITEM(BOOTSTRAP_ITEM_OFFLINE) ); - addSetting(_rSettings, NAME(SETTING_LOCALE), ITEM(BOOTSTRAP_ITEM_LOCALE) ); - addSetting(_rSettings, NAME(SETTING_ASYNC), ITEM(BOOTSTRAP_ITEM_ASYNCENABLE) ); - addSetting(_rSettings, NAME(SETTING_SOURCEPATH), ITEM(BOOTSTRAP_ITEM_SOURCE_PATH) ); - addSetting(_rSettings, NAME(SETTING_UPDATEPATH), ITEM(BOOTSTRAP_ITEM_UPDATE_PATH) ); - addSetting(_rSettings, NAME(SETTING_SERVER), ITEM(BOOTSTRAP_ITEM_SERVER) ); - addSetting(_rSettings, NAME(SETTING_TIMEOUT), ITEM(BOOTSTRAP_ITEM_TIMEOUT) ); - addSetting(_rSettings, NAME(SETTING_USER), ITEM(BOOTSTRAP_ITEM_USER) ); - addSetting(_rSettings, NAME(SETTING_PASSWORD), ITEM(BOOTSTRAP_ITEM_PASSWORD) ); - } -// --------------------------------------------------------------------------------------- - static inline void getDirWithDefault( - rtl::Bootstrap& _rData, - OUString const& _sItem, - OUString& _sResult, - OUString const& _sDefault - ) - { - _rData.getFrom(_sItem,_sResult,_sDefault); - } - //---------------------------------------- - #define BOOTSTRAP_ITEM_SHAREDIR "$BaseInstallation/share" - #define BOOTSTRAP_ITEM_USERDIR "$UserInstallation/user" - #define CONFIGURATION_STANDARDPATH "config/registry" - #define BOOTSTRAP_BASEPATH_DEFAULT ITEM(BOOTSTRAP_ITEM_SHAREDIR"/"CONFIGURATION_STANDARDPATH) - #define BOOTSTRAP_DATAPATH_DEFAULT ITEM(BOOTSTRAP_ITEM_USERDIR "/"CONFIGURATION_STANDARDPATH) - -// --------------------------------------------------------------------------------------- - - static inline OUString getDefaultSourcePath(rtl::Bootstrap& _rData) - { - OUString sResult; - - getDirWithDefault(_rData,ITEM(BOOTSTRAP_ITEM_SOURCE_PATH),sResult,BOOTSTRAP_BASEPATH_DEFAULT); - - return sResult; - } -// --------------------------------------------------------------------------------------- - - static inline OUString getDefaultUpdatePath(rtl::Bootstrap& _rData) - { - OUString sResult; - - getDirWithDefault(_rData,ITEM(BOOTSTRAP_ITEM_UPDATE_PATH),sResult,BOOTSTRAP_DATAPATH_DEFAULT); - - return sResult; - } -// --------------------------------------------------------------------------------------- - // if we do not already have path settings, try to use the defaults (of an office install) - void BootstrapSettings::Impl::adjustToInstallation(Settings& _rSettings) - { - // if we do not already have a source path setting, create one from the base install path - Settings::Name const sSourceSetting = NAME(SETTING_SOURCEPATH); - if (!_rSettings.haveSetting(sSourceSetting)) - { - OUString aSourcePath = getDefaultSourcePath(m_data); - - if (isValidFileURL(aSourcePath) && urlExists(aSourcePath)) - { - _rSettings.putSetting(sSourceSetting,Settings::Setting(aSourcePath,Settings::SO_DEFAULT)); - - // and then also try to update the Update-path - Settings::Name const sUpdateSetting = NAME(SETTING_UPDATEPATH); - if (!_rSettings.haveSetting(sUpdateSetting)) - { - OUString aUpdatePath = getDefaultUpdatePath(m_data); - - if (isValidFileURL(aUpdatePath)) - _rSettings.putSetting(sUpdateSetting,Settings::Setting(aUpdatePath,Settings::SO_DEFAULT)); - } - } - } - } -// --------------------------------------------------------------------------------------- static OUString buildBootstrapError( sal_Char const* _sWhat, OUString const& _sName, sal_Char const* _sHow) @@ -1582,38 +871,46 @@ BootstrapSettings::Context getBootstrapContext(const Reference< XMultiServiceFac } // --------------------------------------------------------------------------------------- - BootstrapResult BootstrapSettings::Impl::getBootstrapErrorMessage(ConnectionSettings const & _rSettings, OUString& _rMessage, OUString& _rIniFile ) const + BootstrapResult getBootstrapErrorMessage(BootstrapContext const & aContext, ContextReader const & aSettings, OUString& _rMessage, OUString& _rIniFile ) { BootstrapResult eResult = BOOTSTRAP_DATA_OK; - if ( this->getInifile(_rIniFile) ) + _rIniFile = aContext.getBootstrapURL(); + + if ( !urlExists(_rIniFile) ) { - if ( urlExists(_rIniFile) ) - { - _rMessage = buildBootstrapError("The configuration file ",_rIniFile.copy(1+_rIniFile.lastIndexOf('/')),"is invalid"); - eResult = INCOMPLETE_BOOTSTRAP_FILE; - } - else - { - _rMessage = buildBootstrapError("The configuration file ",_rIniFile.copy(1+_rIniFile.lastIndexOf('/')),"is missing"); - eResult = MISSING_BOOTSTRAP_FILE; - } + _rMessage = buildBootstrapError("The configuration file ",_rIniFile.copy(1+_rIniFile.lastIndexOf('/')),"is missing"); + eResult = MISSING_BOOTSTRAP_FILE; } - else if (!_rSettings.isSessionTypeKnown()) + else if (!aSettings.isUnoBackend()) { - _rMessage = buildBootstrapError("Needed information to access",OUString::createFromAscii("application"),"configuration data is missing"); - eResult = BOOTSTRAP_FAILURE; + _rMessage = buildBootstrapError("The configuration file ",_rIniFile.copy(1+_rIniFile.lastIndexOf('/')),"is for an older version of the configuration database"); + eResult = INCOMPLETE_BOOTSTRAP_FILE; } - else if (!_rSettings.isComplete() ) + else if (!aSettings.isBootstrapValid() ) { - _rMessage = buildBootstrapError("Needed information to access",_rSettings.getSessionType(), "configuration data is missing"); + _rMessage = buildBootstrapError("Needed information to access",OUString::createFromAscii("application"), "configuration data is missing"); eResult = INCOMPLETE_BOOTSTRAP_DATA; } return eResult; } // --------------------------------------------------------------------------------------- +} // anonymous namespace +// --------------------------------------------------------------------------------------- +uno::Any BootstrapContext::makeBootstrapException() +{ + ContextReader aReader(this); + + if (aReader.isBootstrapValid()) return uno::Any(); + OUString sMessage,sURL; + + BootstrapResult rc = getBootstrapErrorMessage(*this,aReader,sMessage,sURL); + + return impl_makeBootstrapException(rc,sMessage,sURL,*this); +} +// --------------------------------------------------------------------------- // --------------------------------------------------------------------------------------- } // namespace configmgr diff --git a/configmgr/source/misc/bootstrapcontext.cxx b/configmgr/source/misc/bootstrapcontext.cxx index 86c5b0f02015..aa3aa027ce20 100644 --- a/configmgr/source/misc/bootstrapcontext.cxx +++ b/configmgr/source/misc/bootstrapcontext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrapcontext.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-06-12 16:37:43 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,125 +61,202 @@ #include "bootstrapcontext.hxx" -#ifndef CONFIGMGR_BOOTSTRAP_HXX_ -#include "bootstrap.hxx" +#ifndef _UNO_CURRENT_CONTEXT_HXX_ +#include <uno/current_context.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> #endif #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ #include <com/sun/star/uno/XComponentContext.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif namespace configmgr { // --------------------------------------------------------------------------- -static const sal_Char k_BOOTSTRAP_ARGNAME_PREFIX[] = "com.sun.star.configuration.bootstrap."; -static const sal_Char k_BOOTSTRAP_ITEM_PROFILE_NAME[] = "CFG_INIFILE"; +#define IMPL_ITEM_PREFIX_ "/implementations/com.sun.star.com.configuration.bootstrap.ComponentContext/" +#define IMPL_ITEM_PASSTHRU IMPL_ITEM_PREFIX_"isPassthrough" +#define IMPL_ITEM_BASECONTEXT IMPL_ITEM_PREFIX_"theBaseContext" +#define A_SERVICEMANAGER "com.sun.star.lang.theServiceManager" // --------------------------------------------------------------------------- #define OUSTR( text ) OUString( RTL_CONSTASCII_USTRINGPARAM( text ) ) #define OU2ASCII( str ) ( rtl::OUStringToOString(str,RTL_TEXTENCODING_ASCII_US) .getStr() ) // --------------------------------------------------------------------------- - -static void testComplete(BootstrapContext::Arguments const & _aArguments) +#if 0 +static void testComplete() { - uno::Reference< uno::XInterface > test = * new BootstrapContext(_aArguments); + uno::Reference< uno::XInterface > test = * new ComponentContext(ComponentContext::Context(),ComponentContext::Overrides(),true); } +#endif // --------------------------------------------------------------------------- -BootstrapContext::BootstrapContext(Arguments const & _aArguments, ComponentContext const & _xContext) -: m_aArguments(_aArguments) +ComponentContext::ComponentContext(Context const & _xContext) +: ComponentContext_Base(m_aMutex) +, m_aMutex() , m_xContext(_xContext) , m_hBootstrapData(NULL) { - uno::Any aExplicitURL = getValueByName(OUSTR(k_BOOTSTRAP_ITEM_PROFILE_NAME)); - - OUString sURL; - if (!(aExplicitURL >>= sURL)) - sURL = BootstrapSettings::getURL(); +} +// --------------------------------------------------------------------------- - this->setBootstrapURL(sURL); +ComponentContext::~ComponentContext() +{ + if (m_hBootstrapData) rtl_bootstrap_args_close(m_hBootstrapData); } // --------------------------------------------------------------------------- -BootstrapContext::~BootstrapContext() +void ComponentContext::initialize( const OUString& _aURL ) { - rtl_bootstrap_args_close(m_hBootstrapData); + osl::ClearableMutexGuard lock(mutex()); + + OSL_ASSERT(!m_hBootstrapData); + m_hBootstrapData = rtl_bootstrap_args_open(_aURL.pData); + + uno::Reference< lang::XComponent > xOwner(m_xContext, uno::UNO_QUERY); + + lock.clear(); + + if (xOwner.is()) DisposingForwarder::forward(xOwner,this); + + if (!m_xContext.is()) + { + OSL_ENSURE(rBHelper.bDisposed,"ComponentContext::initialize - Context unexpectedly missing"); + throw lang::DisposedException(OUSTR("Parent context has been disposed early"),*this); + } } // --------------------------------------------------------------------------- -void BootstrapContext::setBootstrapURL( const OUString& _aURL ) +// ComponentHelper +void SAL_CALL ComponentContext::disposing() { - if (rtlBootstrapHandle hNew = rtl_bootstrap_args_open(_aURL.pData)) + osl::MutexGuard lock(mutex()); + + m_xContext.clear(); + + if (m_hBootstrapData) { rtl_bootstrap_args_close(m_hBootstrapData); - m_hBootstrapData = hNew; + m_hBootstrapData = NULL; + } +} +// --------------------------------------------------------------------------- + +OUString ComponentContext::getBootstrapURL() const +{ + OUString aResult; + + osl::MutexGuard lock(mutex()); + if (m_hBootstrapData) + { + rtl_bootstrap_get_iniName_from_handle(m_hBootstrapData,&aResult.pData); } else { - OSL_TRACE( "configmgr: Cannot open bootstrap data URL: %s", OU2ASCII(_aURL) ); + OSL_TRACE( "configmgr: No bootstrap data URL set"); } + + return aResult; } // --------------------------------------------------------------------------- -OUString BootstrapContext::makeLongName(OUString const & _aName) +void ComponentContext::changeBootstrapURL( const OUString& _aURL ) { - // check if already is long - if (_aName.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM(k_BOOTSTRAP_ARGNAME_PREFIX) ) ) - return _aName; + osl::MutexGuard lock(mutex()); - return OUSTR(k_BOOTSTRAP_ARGNAME_PREFIX).concat(_aName); + if (rtlBootstrapHandle hNew = rtl_bootstrap_args_open(_aURL.pData)) + { + rtl_bootstrap_args_close(m_hBootstrapData); + m_hBootstrapData = hNew; + } + else + { + OSL_TRACE( "configmgr: Cannot open bootstrap data URL: %s", OU2ASCII(_aURL) ); + } } // --------------------------------------------------------------------------- -OUString BootstrapContext::makeShortName(OUString const & _aName) +uno::Reference< lang::XMultiComponentFactory > SAL_CALL + ComponentContext::getServiceManager( ) + throw (uno::RuntimeException) { - // check if already is short - if (!_aName.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM(k_BOOTSTRAP_ARGNAME_PREFIX) ) ) - return _aName; + Context xBase = basecontext(); + if (!xBase.is()) + throw lang::DisposedException(OUSTR("Parent context has been disposed"),*this); - return _aName.copy(RTL_CONSTASCII_LENGTH(k_BOOTSTRAP_ARGNAME_PREFIX)); + return xBase->getServiceManager(); } // --------------------------------------------------------------------------- uno::Any SAL_CALL - BootstrapContext::getValueByName( const OUString& Name ) + ComponentContext::getValueByName( const OUString& aName ) throw (uno::RuntimeException) { - OUString aShortName = makeShortName(Name); - uno::Any aResult; bool bFound = - lookupInArguments( aResult, aShortName ) || - lookupInContext ( aResult, makeLongName(Name) ) || - lookupInBootstrap( aResult, aShortName ); + lookupInContext ( aResult, aName ) || + lookupInBootstrap( aResult, aName ); - if (!bFound) - { - OSL_TRACE( "configmgr: Cannot find bootstrap data item: %s", OU2ASCII(Name) ); - } return aResult; } // --------------------------------------------------------------------------- -bool BootstrapContext::lookupInArguments( uno::Any & _rValue, const OUString& _aName ) +sal_Bool ComponentContext::isPassthrough(Context const & _xContext) { - for (sal_Int32 nIx = 0; nIx < m_aArguments.getLength(); ++nIx) + OSL_ENSURE(_xContext.is(),"Unexpected NULL context"); + if (!_xContext.is()) return false; + + sal_Bool bValue = false; + _xContext->getValueByName(OUSTR(IMPL_ITEM_PASSTHRU)) >>= bValue; + return bValue; +} +// --------------------------------------------------------------------------- + +beans::NamedValue ComponentContext::makePassthroughMarker(sal_Bool bPassthrough) +{ + return beans::NamedValue(OUSTR(IMPL_ITEM_PASSTHRU),uno::makeAny(bPassthrough)); +} +// --------------------------------------------------------------------------- + +ComponentContext::Context ComponentContext::getBaseContext(Context const & _xContext) +{ + OSL_ENSURE(_xContext.is(),"Unexpected NULL context"); + + Context xResult = _xContext; + if (_xContext.is()) { - if (m_aArguments[nIx].Name.equalsIgnoreAsciiCase(_aName)) - { - _rValue = m_aArguments[nIx].Value; - return true; - } + _xContext->getValueByName(OUSTR(IMPL_ITEM_BASECONTEXT)) >>= xResult; } - return false; + return xResult; } // --------------------------------------------------------------------------- -bool BootstrapContext::lookupInContext( uno::Any & _rValue, const OUString& _aName ) +bool ComponentContext::lookupInContext( uno::Any & _rValue, const OUString& _aName ) const { - if (!m_xContext.is()) return false; + Context xBase = basecontext(); + if (!xBase.is()) + throw lang::DisposedException(OUSTR("Parent context has been disposed"),const_cast<ComponentContext&>(*this)); - uno::Any aCtxValue = m_xContext->getValueByName( _aName ); + if (_aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( IMPL_ITEM_BASECONTEXT ))) + { + _rValue = uno::makeAny(xBase); + return true; + } + + uno::Any aCtxValue = xBase->getValueByName( _aName ); if (aCtxValue.hasValue()) { @@ -191,8 +268,9 @@ bool BootstrapContext::lookupInContext( uno::Any & _rValue, const OUString& _aNa } // --------------------------------------------------------------------------- -bool BootstrapContext::lookupInBootstrap( uno::Any & _rValue, const OUString& _aName ) +bool ComponentContext::lookupInBootstrap( uno::Any & _rValue, const OUString& _aName ) const { + osl::MutexGuard lock(mutex()); OUString sResult; if ( rtl_bootstrap_get_from_handle( m_hBootstrapData, _aName.pData, &sResult.pData, 0) ) { @@ -203,7 +281,192 @@ bool BootstrapContext::lookupInBootstrap( uno::Any & _rValue, const OUString& _a return false; } // --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +static const char k_TunneledContext[] = "/services/com.sun.star.configuration.bootstrap.Context"; + +class UnoContextTunnel::Tunnel +: public ::cppu::WeakImplHelper2< uno::XCurrentContext, lang::XUnoTunnel > +{ + Context m_xTunneledContext; + CurrentContext m_xOldContext; + uno::Any m_aFailure; +public: + Tunnel(Context const & xTunneledContext, CurrentContext const & xOldContext) + : m_xTunneledContext(xTunneledContext) + , m_xOldContext(xOldContext) + , m_aFailure() + {} + + virtual uno::Any SAL_CALL + getValueByName( const OUString& Name ) + throw (uno::RuntimeException) + { + if (Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(k_TunneledContext) ) ) + { + return uno::makeAny(m_xTunneledContext); + } + else if (m_xOldContext.is()) + { + return m_xOldContext->getValueByName(Name); + } + else + { + return uno::Any(); + } + } + + virtual sal_Int64 SAL_CALL + getSomething( const uno::Sequence< sal_Int8 >& aIdentifier ) + throw (uno::RuntimeException) + { + if (getTunnelId() == aIdentifier) + return reinterpret_cast<sal_Int64>(&m_aFailure); + else + return 0; + } + + static uno::Any * getFailure(FailureTunnel const & xTunnel); + + static uno::Sequence< sal_Int8 > getTunnelId(); +}; +// --------------------------------------------------------------------------- + +uno::Sequence< sal_Int8 > UnoContextTunnel::Tunnel::getTunnelId() +{ + static ::cppu::OImplementationId aTunnelId; + return aTunnelId.getImplementationId(); +} +// --------------------------------------------------------------------------- + +uno::Any * UnoContextTunnel::Tunnel::getFailure(FailureTunnel const & xTunnel) +{ + if (xTunnel.is()) + { + if (sal_Int64 nSomething = xTunnel->getSomething(getTunnelId())) + { + return reinterpret_cast<uno::Any *>(nSomething); + } + } + return NULL; +} +// --------------------------------------------------------------------------- + +UnoContextTunnel::UnoContextTunnel() +: m_xOldContext( uno::getCurrentContext() ) +, m_xActiveTunnel() +{ +} +// --------------------------------------------------------------------------- + +UnoContextTunnel::~UnoContextTunnel() +{ + uno::setCurrentContext( m_xOldContext ); +} +// --------------------------------------------------------------------------- + +void UnoContextTunnel::passthru(Context const & xContext) +{ + OSL_ASSERT( xContext.is() ); + if ( ComponentContext::isPassthrough(xContext) ) + { + this ->tunnel(xContext); + } + else + { + this->tunnel(NULL); + } +} +// --------------------------------------------------------------------------- + +void UnoContextTunnel::tunnel(Context const & xContext) +{ + Tunnel * pNewTunnel = new Tunnel(xContext,m_xOldContext); + m_xActiveTunnel = pNewTunnel; + uno::setCurrentContext( pNewTunnel ); +} +// --------------------------------------------------------------------------- + +UnoContextTunnel::Context UnoContextTunnel::recoverContext(Context const & xFallback ) +{ + try + { + CurrentContext const xCurrContext = uno::getCurrentContext(); + + if (xCurrContext.is()) + { + OUString aName(RTL_CONSTASCII_USTRINGPARAM(k_TunneledContext)); + Context xResult; + if (xCurrContext->getValueByName(aName) >>= xResult) + { + if (xResult.is()) + return xResult; + } + else + { + OSL_ASSERT( !xResult.is() ); + OSL_ENSURE( !xCurrContext->getValueByName(aName).hasValue(), + "Value in context has wrong type"); + } + } + } + catch (uno::Exception &) + { + OSL_ENSURE(false, "Unexpected: Exception from accessing current context"); + } + + return xFallback; +} +// --------------------------------------------------------------------------- + +uno::Any UnoContextTunnel::recoverFailure(bool bRaise) +{ + if (uno::Any * pFail = UnoContextTunnel::Tunnel::getFailure(m_xActiveTunnel)) + { + if (bRaise) + { + if (pFail->hasValue()) + cppu::throwException(*pFail); + else + throw; + } + return *pFail; + } + + return uno::Any(); +} +// --------------------------------------------------------------------------- + +bool UnoContextTunnel::tunnelFailure(uno::Any const & aException, bool bRaise) +{ + OSL_ASSERT( !aException.hasValue() || aException.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + FailureTunnel xTunnel( uno::getCurrentContext(), uno::UNO_QUERY ); + + if (uno::Any * pFail = Tunnel::getFailure(xTunnel)) + { + *pFail = aException; + + if (bRaise && aException.hasValue()) + cppu::throwException(aException); + + if (bRaise) throw; + return true; + } + else + { + if (bRaise) throw; + return false; + } +} +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +void DisposingForwarder::disposing( lang::EventObject const & rSource ) +throw (uno::RuntimeException) +{ + m_xTarget->dispose(); + m_xTarget.clear(); +} // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- } // namespace config diff --git a/configmgr/source/misc/configunoreg.cxx b/configmgr/source/misc/configunoreg.cxx index a01bffb6ecea..c05fd74948c9 100644 --- a/configmgr/source/misc/configunoreg.cxx +++ b/configmgr/source/misc/configunoreg.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configunoreg.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:07:48 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,48 +60,32 @@ ************************************************************************/ #include <stdio.h> -#ifndef _CONFIGMGR_PROVIDER_FACTORY_HXX_ -#include "providerfactory.hxx" -#endif +#include "confapifactory.hxx" + #ifndef CONFIGMGR_SERVICEINFOHELPER_HXX_ #include "serviceinfohelper.hxx" #endif -#ifndef CONFIGMGR_API_FACTORY_HXX_ -#include "confapifactory.hxx" -#endif + #ifndef _CPPUHELPER_FACTORY_HXX_ #include <cppuhelper/factory.hxx> #endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif using ::rtl::OUString; +using ::rtl::OUStringBuffer; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::Sequence; using ::com::sun::star::registry::XRegistryKey; -using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XSingleComponentFactory; using ::com::sun::star::lang::XMultiServiceFactory; using ::configmgr::ServiceRegistrationInfo; using ::configmgr::SingletonRegistrationInfo; using ::configmgr::AsciiServiceName; -typedef Reference< XSingleServiceFactory > (SAL_CALL * createFactoryFunc) - ( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ::cppu::ComponentInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames, - rtl_ModuleCount* - ); - -typedef Reference< XSingleServiceFactory > (SAL_CALL * createProviderFactoryFunc) - ( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ::configmgr::ProviderInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames - ); - // *************************************************************************************** // // Die vorgeschriebene C-Api muss erfuellt werden! @@ -116,11 +100,12 @@ void RegisterService( if (pInfo == 0 || pInfo->registeredServiceNames==0 || pInfo->implementationName==0) return; - OUString aMainKeyName(OUString(RTL_CONSTASCII_USTRINGPARAM("/"))); - aMainKeyName += OUString::createFromAscii(pInfo->implementationName); - aMainKeyName += OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); + OUStringBuffer aMainKeyName; + aMainKeyName.appendAscii("/"); + aMainKeyName.appendAscii(pInfo->implementationName); + aMainKeyName.appendAscii("/UNO/SERVICES"); - Reference< XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + Reference< XRegistryKey > xNewKey( xKey->createKey(aMainKeyName.makeStringAndClear()) ); OSL_ENSURE(xNewKey.is(), "CONFMGR::component_writeInfo : could not create a registry key !"); for(AsciiServiceName const* p = pInfo->registeredServiceNames ; *p; ++p) @@ -135,13 +120,18 @@ void RegisterSingleton( const SingletonRegistrationInfo* pInfo, const Reference< XRegistryKey > & xKey) { - if (pInfo == 0 || pInfo->singletonName==0 || pInfo->instantiatedServiceName==0) + if (pInfo == 0 || pInfo->singletonName ==0 || + pInfo->implementationName ==0 || + pInfo->instantiatedServiceName ==0 ) return; - OUString aSingletonKeyName(OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SINGLETONS/"))); - aSingletonKeyName += OUString::createFromAscii(pInfo->singletonName); + OUStringBuffer aSingletonKeyName; + aSingletonKeyName.appendAscii("/"); + aSingletonKeyName.appendAscii(pInfo->implementationName); + aSingletonKeyName.appendAscii("/UNO/SINGLETONS/"); + aSingletonKeyName.appendAscii(pInfo->singletonName); - Reference< XRegistryKey > xNewKey( xKey->createKey(aSingletonKeyName) ); + Reference< XRegistryKey > xNewKey( xKey->createKey(aSingletonKeyName.makeStringAndClear()) ); OSL_ENSURE(xNewKey.is(), "CONFMGR::component_writeInfo : could not create a registry key !"); xNewKey->setStringValue(OUString::createFromAscii(pInfo->instantiatedServiceName)); @@ -154,7 +144,7 @@ void RegisterSingleton( //----------------------------------------------------------------------------- struct ServiceImplementationRequest { - Reference< XSingleServiceFactory > xRet; + Reference< XInterface > xRet; Reference< XMultiServiceFactory > const m_xServiceManager; OUString const sImplementationName; @@ -179,10 +169,9 @@ struct ServiceImplementationRequest //------------------------------------------------------------------------- - sal_Bool CreateService( + sal_Bool CreateProviderFactory( const ServiceRegistrationInfo* pInfo, - ::cppu::ComponentInstantiation Factory, - createFactoryFunc creator + bool bAdmin ) { if (this->shouldCreate(pInfo)) @@ -192,7 +181,7 @@ struct ServiceImplementationRequest const Sequence< OUString > Services= aInfo.getRegisteredServiceNames(); - xRet = creator( m_xServiceManager, aInfo.getImplementationName(), Factory, Services, 0); + xRet = configmgr::createProviderFactory( aInfo.getImplementationName(), bAdmin); OSL_ENSURE(xRet.is(), "CreateProvider : WHERE IS THE return value !"); } @@ -204,10 +193,9 @@ struct ServiceImplementationRequest //------------------------------------------------------------------------- - sal_Bool CreateProvider( + sal_Bool CreateServiceFactory( const ServiceRegistrationInfo* pInfo, - ::configmgr::ProviderInstantiation Factory, - createProviderFactoryFunc creator + ::cppu::ComponentFactoryFunc Factory ) { if (this->shouldCreate(pInfo)) @@ -217,7 +205,8 @@ struct ServiceImplementationRequest const Sequence< OUString > Services= aInfo.getRegisteredServiceNames(); - xRet = creator( m_xServiceManager, aInfo.getImplementationName(), Factory, Services); + xRet = cppu::createSingleComponentFactory( Factory, aInfo.getImplementationName(), Services, 0); + OSL_ENSURE(xRet.is(), "CreateProvider : WHERE IS THE return value !"); } catch(Exception&) @@ -228,16 +217,15 @@ struct ServiceImplementationRequest //------------------------------------------------------------------------- - sal_Bool MapSingleton( + sal_Bool CreateSingletonMapperFactory( const SingletonRegistrationInfo* pInfo, - ::cppu::ComponentInstantiation Mapper, - createFactoryFunc creator + ::cppu::ComponentFactoryFunc Mapper ) { OSL_ENSURE(pInfo && pInfo->mappedImplementation, "CreateProvider : Cannot map unmapped singleton !"); return pInfo && pInfo->mappedImplementation && - CreateService(pInfo->mappedImplementation,Mapper,creator); + CreateServiceFactory(pInfo->mappedImplementation,Mapper); } //------------------------------------------------------------------------- @@ -273,8 +261,11 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( Reference< XRegistryKey > xKey(reinterpret_cast<XRegistryKey*>(pRegistryKey)); // configuration access entry points: configuration provider - RegisterService(configmgr::getConfigurationProviderServices(), xKey); - RegisterService(configmgr::getAdminProviderServices(), xKey); + RegisterSingleton(configmgr::getDefaultProviderSingletonInfo(), xKey) ; + + RegisterService(configmgr::getConfigurationProviderServiceInfo(), xKey); + RegisterService(configmgr::getDefaultProviderServiceInfo(), xKey); + RegisterService(configmgr::getAdminProviderServiceInfo(), xKey); // registry wrapper (deprecated) RegisterService(configmgr::getConfigurationRegistryServiceInfo(), xKey); @@ -286,11 +277,23 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( RegisterService(configmgr::xml::getSchemaParserServiceInfo(), xKey); RegisterService(configmgr::xml::getLayerParserServiceInfo(), xKey); RegisterService(configmgr::xml::getLayerWriterServiceInfo(), xKey); + + // bootstrap handling + RegisterSingleton(configmgr::getBootstrapContextSingletonInfo(), xKey) ; + RegisterService(configmgr::getBootstrapContextServiceInfo(), xKey) ; + + // backend singletons + RegisterSingleton(configmgr::backend::getDefaultBackendSingletonInfo(), xKey) ; + RegisterSingleton(configmgr::backend::getDefaultSingleBackendSingletonInfo(), xKey) ; + // backends + RegisterService(configmgr::backend::getDefaultBackendServiceInfo(), xKey) ; + RegisterService(configmgr::backend::getDefaultSingleBackendServiceInfo(), xKey) ; RegisterService(configmgr::backend::getSingleBackendAdapterServiceInfo(), xKey) ; RegisterService(configmgr::localbe::getLocalBackendServiceInfo(), xKey) ; RegisterService(configmgr::localbe::getLocalDataImportServiceInfo(), xKey) ; RegisterService(configmgr::localbe::getLocalHierarchyBrowserServiceInfo(), xKey) ; + // im/export RegisterService(configmgr::backend::getMergeImportServiceInfo(), xKey); RegisterService(configmgr::backend::getCopyImportServiceInfo(), xKey); @@ -317,75 +320,88 @@ extern "C" void* SAL_CALL component_getFactory( ServiceImplementationRequest aReq(pServiceManager,pImplementationName); // configuration access entry points: configuration provider - aReq.CreateProvider( - configmgr::getConfigurationProviderServices(), - &configmgr::instantiateConfigProvider, - ::configmgr::createProviderFactory) + aReq.CreateProviderFactory( + configmgr::getConfigurationProviderServiceInfo(), + false) + || + aReq.CreateProviderFactory( + configmgr::getAdminProviderServiceInfo(), + true) || - aReq.CreateProvider( - configmgr::getAdminProviderServices(), - &configmgr::instantiateAdminProvider, - ::configmgr::createProviderFactory) + aReq.CreateServiceFactory( + configmgr::getDefaultProviderServiceInfo(), + &configmgr::instantiateDefaultProvider) || // registry wrapper (deprecated) - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::getConfigurationRegistryServiceInfo(), - &configmgr::instantiateConfigRegistry, - ::cppu::createSingleFactory) + &configmgr::instantiateConfigRegistry) || // updating - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::backend::getUpdateMergerServiceInfo(), - &configmgr::backend::instantiateUpdateMerger, - ::cppu::createSingleFactory) + &configmgr::backend::instantiateUpdateMerger) || // xml handling - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::xml::getSchemaParserServiceInfo(), - &configmgr::xml::instantiateSchemaParser, - ::cppu::createSingleFactory) + &configmgr::xml::instantiateSchemaParser) || - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::xml::getLayerParserServiceInfo(), - &configmgr::xml::instantiateLayerParser, - ::cppu::createSingleFactory) + &configmgr::xml::instantiateLayerParser) || - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::xml::getLayerWriterServiceInfo(), - &configmgr::xml::instantiateLayerWriter, - ::cppu::createSingleFactory) + &configmgr::xml::instantiateLayerWriter) + || + // bootstrap handling + aReq.CreateServiceFactory( + configmgr::getBootstrapContextServiceInfo(), + &configmgr::instantiateBootstrapContext) + || + // backend singletons + aReq.CreateSingletonMapperFactory( + configmgr::backend::getDefaultBackendSingletonInfo(), + configmgr::backend::getDefaultBackendSingleton) + || + aReq.CreateSingletonMapperFactory( + configmgr::backend::getDefaultSingleBackendSingletonInfo(), + configmgr::backend::getDefaultSingleBackendSingleton) || // backends - aReq.CreateService( + aReq.CreateServiceFactory( + configmgr::backend::getDefaultBackendServiceInfo(), + configmgr::backend::instantiateDefaultBackend) + || + aReq.CreateServiceFactory( + configmgr::backend::getDefaultSingleBackendServiceInfo(), + configmgr::backend::instantiateDefaultSingleBackend) + || + aReq.CreateServiceFactory( configmgr::backend::getSingleBackendAdapterServiceInfo(), - configmgr::backend::instantiateSingleBackendAdapter, - cppu::createSingleFactory) + configmgr::backend::instantiateSingleBackendAdapter) || - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::localbe::getLocalBackendServiceInfo(), - configmgr::localbe::instantiateLocalBackend, - cppu::createSingleFactory) + configmgr::localbe::instantiateLocalBackend) || - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::localbe::getLocalDataImportServiceInfo(), - configmgr::localbe::instantiateLocalDataImporter, - cppu::createSingleFactory) + configmgr::localbe::instantiateLocalDataImporter) || - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::localbe::getLocalHierarchyBrowserServiceInfo(), - configmgr::localbe::instantiateLocalHierarchyBrowser, - cppu::createSingleFactory) + configmgr::localbe::instantiateLocalHierarchyBrowser) || // im/export - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::backend::getMergeImportServiceInfo(), - &configmgr::backend::instantiateMergeImporter, - ::cppu::createSingleFactory) + &configmgr::backend::instantiateMergeImporter) || - aReq.CreateService( + aReq.CreateServiceFactory( configmgr::backend::getCopyImportServiceInfo(), - &configmgr::backend::instantiateCopyImporter, - ::cppu::createSingleFactory) + &configmgr::backend::instantiateCopyImporter) || false; diff --git a/configmgr/source/misc/makefile.mk b/configmgr/source/misc/makefile.mk index 481fe68b87e9..8338b3d84c15 100644 --- a/configmgr/source/misc/makefile.mk +++ b/configmgr/source/misc/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.20 $ +# $Revision: 1.21 $ # -# last change: $Author: jb $ $Date: 2002-10-24 15:39:15 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:19:23 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -75,31 +75,27 @@ ENABLE_EXCEPTIONS=TRUE # --- Files ------------------------------------- SLOFILES= \ - $(SLO)$/anypair.obj \ $(SLO)$/bootstrap.obj \ $(SLO)$/providerfactory.obj \ + $(SLO)$/providerwrapper.obj \ $(SLO)$/tracer.obj \ - $(SLO)$/saxtools.obj \ - $(SLO)$/oslstream.obj \ - $(SLO)$/attributelist.obj \ - $(SLO)$/confname.obj \ $(SLO)$/configunoreg.obj \ - $(SLO)$/filehelper.obj \ + $(SLO)$/serviceinfohelper.obj \ + $(SLO)$/bootstrapcontext.obj \ + $(SLO)$/attributelist.obj \ + $(SLO)$/anypair.obj \ $(SLO)$/strimpl.obj \ $(SLO)$/mergechange.obj \ - $(SLO)$/serviceinfohelper.obj \ + $(SLO)$/oslstream.obj \ + $(SLO)$/filehelper.obj \ $(SLO)$/trivialbufferedfile.obj \ $(SLO)$/requestoptions.obj \ - $(SLO)$/bootstrapcontext.obj \ OBJFILES= \ $(OBJ)$/oslstream.obj \ $(OBJ)$/filehelper.obj \ $(OBJ)$/trivialbufferedfile.obj \ -# $(SLO)$/synchronize.obj \ -# $(SLO)$/memory.obj \ - .IF "$(OS)"=="MACOSX" SYMBOLPREFIX=$(CFGMGR_TARGET)$(CFGMGR_MAJOR) diff --git a/configmgr/source/misc/providerfactory.cxx b/configmgr/source/misc/providerfactory.cxx index fe07ea4cca74..e049e1071efc 100644 --- a/configmgr/source/misc/providerfactory.cxx +++ b/configmgr/source/misc/providerfactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: providerfactory.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: jb $ $Date: 2002-10-24 15:44:02 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,25 +65,26 @@ #ifndef CONFIGMGR_API_FACTORY_HXX_ #include "confapifactory.hxx" #endif -#ifndef CONFIGMGR_API_SVCCOMPONENT_HXX_ -#include "confsvccomponent.hxx" -#endif #ifndef CONFIGMGR_BOOTSTRAP_HXX_ #include "bootstrap.hxx" #endif +#ifndef CONFIGMGR_API_PROVIDERWRAPPER_HXX_ +#include "providerwrapper.hxx" +#endif -#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ -#include <com/sun/star/lang/XComponent.hpp> +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ +#include <com/sun/star/lang/IllegalArgumentException.hpp> #endif #ifndef _COM_SUN_STAR_CONFIGURATION_CANNOTLOADCONFIGURATIONEXCEPTION_HPP_ #include <com/sun/star/configuration/CannotLoadConfigurationException.hpp> #endif -#ifndef _UNO_LBNAMES_H_ -#include <uno/lbnames.h> +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> #endif - -#define THISREF() static_cast< ::cppu::OWeakObject* >(this) #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> @@ -92,425 +93,201 @@ #include <rtl/logfile.hxx> #endif -//........................................................................ +//--------------------------------------------------------------------------------------- namespace configmgr { -//........................................................................ - - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - namespace csscfg = ::com::sun::star::configuration; - using namespace ::cppu; - using namespace ::osl; - - - //======================================================================================= - //= OProviderFactory - //======================================================================================= - typedef ::cppu::WeakImplHelper1<XEventListener> XEventListener_BASE; - class ODisposingListener : public XEventListener_BASE - { - OProviderFactory& m_aFactory; - public: - ODisposingListener(OProviderFactory& _aFactory): - m_aFactory(_aFactory){} - - virtual void SAL_CALL disposing(com::sun::star::lang::EventObject const& rEvt) throw() - { - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::ODisposingListener", "jb99855", "configmgr::ODisposingListener::disposing()"); - m_aFactory.disposing(rEvt); - } - ~ODisposingListener() - { - volatile int dummy = 0; - } - - }; //--------------------------------------------------------------------------------------- - - //======================================================================================= //= OProviderFactory - //======================================================================================= //--------------------------------------------------------------------------------------- - OProviderFactory::OProviderFactory(const Reference< XMultiServiceFactory >& _rxORB, ProviderInstantiation _pObjectCreator) - :m_pObjectCreator(_pObjectCreator) - ,m_xORB(_rxORB) - ,m_pPureSettings(NULL) - { - ODisposingListener *pListener = new ODisposingListener(*this); - m_xEventListener = pListener; - Reference<com::sun::star::lang::XComponent> xComponent(_rxORB, UNO_QUERY); - if (xComponent.is()) - { - xComponent->addEventListener(m_xEventListener); - // CFG_TRACE_INFO("insert disposeListener."); - } - } + //--------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------- - OProviderFactory::~OProviderFactory() + ProviderFactory::ProviderFactory(OUString const & aImplementationName, bool bAdmin) + : m_aImplementationName(aImplementationName) + , m_bAdmin(bAdmin) { - delete m_pPureSettings; - - Reference<com::sun::star::lang::XComponent> xComponent(m_xORB, UNO_QUERY); - if (xComponent.is()) - { - xComponent->removeEventListener(m_xEventListener); - } - xComponent = xComponent.query(m_xDefaultProvider); - if (xComponent.is()) - { - xComponent->removeEventListener(m_xEventListener); - } } - //--------------------------------------------------------------------------------------- - void OProviderFactory::ensureBootstrapSettings(Context const & xContext) - { - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderFactory", "jb99855", "configmgr::OProviderFactory::ensureBootstrapSettings()"); - if (!m_pPureSettings) - m_pPureSettings = new BootstrapSettings( xContext ); - } - //--------------------------------------------------------------------------------------- - static bool isReusableConnection(const ConnectionSettings& _rSettings) + ProviderFactory::~ProviderFactory() { - if (_rSettings.isUnoBackend()) - return false; - - // #78409 - // if a provider is queried with a password, we always create a new instance for it, - // as don't wan't to remember the passwords for the user. - - if ( _rSettings.hasPassword() && !_rSettings.isLocalSession()) - return false; - - if (_rSettings.hasReinitializeFlag() && _rSettings.getReinitializeFlag()) - return false; - - return true; } - //--------------------------------------------------------------------------------------- - extern OUString buildConnectString(const ConnectionSettings& _rSettings); - //--------------------------------------------------------------------------------------- - Reference< XInterface > OProviderFactory::implGetProvider(const ConnectionSettings& _rSettings) + uno::Reference< uno::XInterface > ProviderFactory::getProviderAlways(Context const & xContext) { - OUString const sConnectString = buildConnectString(_rSettings); + RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::ProviderFactory", "jb99855", "configmgr::ProviderFactory::getProviderAlways()"); + uno::Reference< uno::XInterface > xResult = getDefaultConfigProviderSingleton(xContext); - Reference< XInterface > xReturn; - - ProviderCacheIterator aExistentProviderPos = m_aProviders.find(sConnectString); - if (m_aProviders.end() != aExistentProviderPos) + // check for success + OSL_ENSURE(xResult.is(), "Context could not create provider, but returned NULL instead of throwing an exception"); + if (!xResult.is()) { - xReturn = aExistentProviderPos->second; - } + using ::com::sun::star::configuration::CannotLoadConfigurationException; - if (!xReturn.is()) - { - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderFactory", "jb99855", "configmgr::OProviderFactory: (*m_pObjectCreator)()"); - - // create and connect the provider (may still throw exceptions) - xReturn = (*m_pObjectCreator)(m_xORB, _rSettings); - - // check for success - if (!xReturn.is()) - { - OSL_ENSURE(false, "Object creator could not create provider, but returned NULL instead of throwing an exception"); - sal_Char const sCannotCreate[] = "Cannot create ConfigurationProvider. Unknown backend or factory error."; - // should become CannotLoadConfigurationException - throw csscfg::CannotLoadConfigurationException( OUString::createFromAscii(sCannotCreate), *this ); - } + static sal_Char const sCannotCreate[] = "Cannot create ConfigurationProvider. Unknown backend or factory error."; - // remember it for later usage - if (isReusableConnection(_rSettings)) - m_aProviders[sConnectString] = xReturn; + throw CannotLoadConfigurationException( OUString(RTL_CONSTASCII_USTRINGPARAM(sCannotCreate)), *this ); } - return xReturn; + return xResult; } - //--------------------------------------------------------------------------------------- - Reference< XInterface > OProviderFactory::implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool _bRequiresBootstrap) + uno::Reference< uno::XInterface > ProviderFactory::getProviderFromContext(Context const & xContext) { + OSL_ENSURE(ContextReader::testAdminService(xContext, this->m_bAdmin), + "Creation context admin flag does not match service being created"); + try { - return implGetProvider(_rSettings); + return getProviderAlways(xContext); } catch(uno::Exception& e) { - if (_bRequiresBootstrap) - { - OSL_ASSERT(m_pPureSettings); - m_pPureSettings->raiseBootstrapException(*this); + ContextReader aContext(xContext); - OSL_ASSERT(m_pPureSettings->valid); + uno::Any aError = aContext.getBootstrapError(); + if (aError.hasValue()) + { + OSL_ASSERT(aError.getValueTypeClass() == uno::TypeClass_EXCEPTION); + cppu::throwException(aError); } - sal_Char const sConnectionFailure[] = "Cannot open Configuration: "; - OUString const sFailure = OUString::createFromAscii(sConnectionFailure); - e.Message = sFailure.concat(e.Message); + OSL_ASSERT(aContext.isBootstrapValid()); + + static const sal_Char sErrContext[] = "Cannot open Configuration: "; + OUString const sContext(RTL_CONSTASCII_USTRINGPARAM(sErrContext)); + e.Message = sContext.concat(e.Message); throw; } } - //--------------------------------------------------------------------------------------- - void OProviderFactory::ensureDefaultProvider(Context const & xContext) + uno::Reference< uno::XInterface > ProviderFactory::createProviderWithArguments(Context const & xContext, Arguments const & _aArguments) { - if (m_xDefaultProvider.is()) - return; - - // force new BootstrapSettings - delete m_pPureSettings,m_pPureSettings = NULL; - ensureBootstrapSettings(xContext); + RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::ProviderFactory", "jb99855", "configmgr::ProviderFactory::createProviderWithArguments()"); - ConnectionSettings aThisRoundSettings(m_pPureSettings->settings); + ContextReader aContext(xContext); + ArgumentHelper aParser(aContext.getBootstrapContext()); - aThisRoundSettings.validate(); - OSL_ENSURE(aThisRoundSettings.isComplete(), "Incomplete Data for creating a ConfigurationProvider"); + NamedValues aValues(_aArguments.getLength() + 2); + sal_Int32 nCount = parseArguments(aParser,aValues,_aArguments); - m_xDefaultProvider = implCreateProviderWithSettings(aThisRoundSettings,true); + bool bNeedNewBackend = aParser.hasBackendArguments(); - // register disposing listener - Reference<com::sun::star::lang::XComponent> xComponent(m_xDefaultProvider, UNO_QUERY); - if (xComponent.is()) + if (!aContext.testAdminService(aContext.getBaseContext(),m_bAdmin)) { - xComponent->addEventListener(m_xEventListener); + bNeedNewBackend = true; + OSL_ASSERT( nCount+2 <= aValues.getLength()); + aValues[nCount++] = ArgumentHelper::makeAdminServiceOverride(m_bAdmin); + aValues[nCount++] = BootstrapContext::makePassthroughMarker(sal_False); } - } - //--------------------------------------------------------------------------------------- - Reference< XInterface > OProviderFactory::createProvider(Context const & xContext) - { - MutexGuard aGuard(m_aMutex); - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderFactory", "jb99855", "configmgr::OProviderFactory::createProvider()"); + OSL_ASSERT(nCount <= aValues.getLength()); + aValues.realloc(nCount); - ensureDefaultProvider(xContext); - return m_xDefaultProvider; - } + if (bNeedNewBackend) + { + Context xMergedContext = BootstrapContext::createWrapper(xContext,aValues); + uno::Reference< uno::XInterface > xResult = getProviderFromContext(xMergedContext); - //--------------------------------------------------------------------------------------- - Reference< XInterface > OProviderFactory::createProviderWithArguments(Context const & xContext, const Sequence< Any >& _rArguments) - { - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderFactory", "jb99855", "configmgr::OProviderFactory::createProviderWithArguments()"); - ConnectionSettings aSettings(_rArguments); - return createProviderWithSettings( xContext, aSettings ); - } + return xResult; + } + else + { + uno::Reference< uno::XInterface > xBaseProvider = getProviderFromContext(xContext); + uno::Reference< uno::XInterface > xResult = ProviderWrapper::create(xBaseProvider,aValues); + return xResult; + } + } //--------------------------------------------------------------------------------------- - Reference< XInterface > OProviderFactory::createProviderWithSettings(Context const & xContext, const ConnectionSettings& _rSettings) + uno::Reference< uno::XInterface > ProviderFactory::createProvider(Context const & xContext, bool bAdmin) { - MutexGuard aGuard(m_aMutex); - - ConnectionSettings aThisRoundSettings(_rSettings); + RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::ProviderFactory", "jb99855", "configmgr::ProviderFactory::createProvider(bAdmin)"); - // use bootstrap data if necessary - bool bUseBootstrapData = !aThisRoundSettings.isComplete(); + NamedValues aValues(2); + aValues[0] = ArgumentHelper::makeAdminServiceOverride(bAdmin); + aValues[1] = BootstrapContext::makePassthroughMarker(sal_False); - // detect a plugin session. Can be specified only as argument - sal_Bool bIsPluginSession = aThisRoundSettings.isPlugin(); + Context xMergedContext = BootstrapContext::createWrapper(xContext,aValues); + uno::Reference< uno::XInterface > xResult = getProviderFromContext(xMergedContext); - OSL_ASSERT(bUseBootstrapData || !bIsPluginSession); - OSL_ENSURE(!bIsPluginSession || !aThisRoundSettings.isSourcePathValid(),"Invalid Argument: No explicit source path should be specified for plugin session"); + return xResult; + } + //--------------------------------------------------------------------------------------- + uno::Reference< uno::XInterface > ProviderFactory::createProvider(Context const & xContext) + { + RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::ProviderFactory", "jb99855", "configmgr::ProviderFactory::createProvider()"); - // use bootstrap data if necessary - if (bUseBootstrapData) + if (BootstrapContext::isPassthrough(xContext)) { - ensureBootstrapSettings(xContext); - - // hack to disable 'plugin' behavior for new-style sessions - if (bIsPluginSession && m_pPureSettings->settings.isUnoBackend()) - return this->createProvider(xContext); //--> use default provider - - ConnectionSettings aMergedSettings = m_pPureSettings->settings; - aMergedSettings.mergeOverrides(aThisRoundSettings); - aMergedSettings.swap(aThisRoundSettings); + // make sure this uses a new BootstrapContext ! + Context xPatchedContext = BootstrapContext::createWrapper(xContext,NamedValues()); + return getProviderFromContext(xPatchedContext); } + else + return getProviderFromContext(xContext); + } + //--------------------------------------------------------------------------------------- - // if we have a plugin session, translate the session type into the one appliable. - if (bIsPluginSession) - { - // try to create (or share) a local-session provider + sal_Int32 ProviderFactory::parseArguments(ArgumentHelper & aParser, NamedValues & rValues, Arguments const & _aArguments) + { + OSL_ASSERT(rValues.getLength() >= _aArguments.getLength()); - // For a plugin-local session, we need a valid update directory. - // (We can't just rely on the session to fail if it is created with a valid source directory and an - // invalid update directory. In such a scenario it will succeed to open, but not to update.) - if (!m_pPureSettings->settings.isLocalSession()) + sal_Int32 nCount = 0; + for (sal_Int32 i = 0; i < _aArguments.getLength(); ++i) + { + if (!aParser.extractArgument(rValues[nCount],_aArguments[i])) { - const OUString sLocalSessionIdentifier = OUString::createFromAscii(LOCAL_SESSION_IDENTIFIER); - - // (We can't just rely on the session to fail if it is created with a valid source directory and an - // invalid update directory. In such a scenario it will succeed to open, but not to update.) - if (aThisRoundSettings.isComplete(sLocalSessionIdentifier) && - aThisRoundSettings.isUpdatePathValid()) - try - { - aThisRoundSettings.setSessionType(sLocalSessionIdentifier, Settings::SO_ADJUSTMENT); - - Reference< XInterface > xLocalProvider - = implGetProvider(aThisRoundSettings); - - if (xLocalProvider.is()) return xLocalProvider; - } - catch(Exception&) - { - // allowed. The creation of the local provider may fail. - } + rtl::OUStringBuffer sMsg; + sMsg.appendAscii("ProviderFactory: Unexpected Argument Type. "); + sMsg.appendAscii("Expected NamedValue or PropertyValue, "); + sMsg.appendAscii("found ").append(_aArguments[i].getValueTypeName()).appendAscii(". "); + throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),*this,static_cast<sal_Int16>(i)); } - // did not create the local session - // -> create the original one - if (m_pPureSettings->settings.isSessionTypeKnown()) + if (aParser.filterAndAdjustArgument(rValues[nCount])) { - OUString sOriginalType = m_pPureSettings->settings.getSessionType(); - aThisRoundSettings.setSessionType(sOriginalType, Settings::SO_ADJUSTMENT); - } - else - { - OUString const sPortalSessionIdentifier = OUString::createFromAscii(PORTAL_SESSION_IDENTIFIER); - aThisRoundSettings.setSessionType(sPortalSessionIdentifier, Settings::SO_ADJUSTMENT); + aParser.checkBackendArgument(rValues[nCount]); + ++nCount; } } - - aThisRoundSettings.validate(); - OSL_ENSURE(aThisRoundSettings.isComplete(), "Incomplete Data for creating a ConfigurationProvider"); - - Reference< XInterface > xProvider = - implCreateProviderWithSettings( aThisRoundSettings,bUseBootstrapData); - - return xProvider; - } - - //--------------------------------------------------------------------------------------- - Reference< XInterface > SAL_CALL OProviderFactory::createInstance( ) throw(Exception, RuntimeException) - { - // default provider - return createProvider( getBootstrapContext(m_xORB) ); - } - - //--------------------------------------------------------------------------------------- - Reference< XInterface > SAL_CALL OProviderFactory::createInstanceWithArguments( const Sequence< Any >& _rArguments ) throw(Exception, RuntimeException) - { - return createProviderWithArguments(getBootstrapContext(m_xORB), _rArguments); + return nCount; } //--------------------------------------------------------------------------------------- uno::Reference< uno::XInterface > - SAL_CALL OProviderFactory::createInstanceWithContext( const uno::Reference< uno::XComponentContext >& xContext ) + SAL_CALL ProviderFactory::createInstanceWithContext( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::Exception, ::com::sun::star::uno::RuntimeException) { - // default provider - return createProvider( xContext ); + // default provider ? + if (ContextReader::testAdminService(xContext,m_bAdmin)) + return createProvider( xContext ); + + else + return createProvider(xContext,m_bAdmin); } //--------------------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL - OProviderFactory::createInstanceWithArgumentsAndContext( const uno::Sequence< uno::Any >& aArguments, const uno::Reference< uno::XComponentContext >& xContext ) + ProviderFactory::createInstanceWithArgumentsAndContext( const uno::Sequence< uno::Any >& aArguments, const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::Exception, uno::RuntimeException) { + // default request return createProviderWithArguments(xContext, aArguments); } //--------------------------------------------------------------------------------------- - //======================================================================================= - Reference< XSingleServiceFactory > SAL_CALL createProviderFactory( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ProviderInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames - ) - { - return new OProviderFactory(rServiceManager, pCreateFunction); - } + //--------------------------------------------------------------------------------------- - void OProviderFactory::disposing(com::sun::star::lang::EventObject const& _rEvt) throw() + uno::Reference< lang::XSingleComponentFactory > SAL_CALL createProviderFactory( + OUString const & aImplementationName, + bool bAdmin + ) { - MutexGuard aGuard(m_aMutex); - if (_rEvt.Source == m_xORB) - { - Reference<com::sun::star::lang::XComponent> xComponent(m_xDefaultProvider, UNO_QUERY); - if (xComponent.is()) - { - xComponent->removeEventListener(m_xEventListener); - } - m_xORB = NULL; - m_xDefaultProvider = NULL; - } - else if (_rEvt.Source == m_xDefaultProvider) - { - m_xDefaultProvider = NULL; - } - else - OSL_ENSURE(sal_False, "unknown object disposed."); + return new ProviderFactory(aImplementationName, bAdmin); } - -//........................................................................ + //--------------------------------------------------------------------------------------- } // namespace configmgr //........................................................................ -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.19 2002/10/14 14:19:27 jb - * #104043# Add/adjust log point for TIMELOG - * - * Revision 1.18 2002/09/19 10:52:06 jb - * #102850# Support for contexts to allow fallback initialization - * - * Revision 1.17 2002/07/03 15:54:38 jb - * #98489# Added support for uno backend bootstrapping - * - * Revision 1.16 2002/06/12 16:44:14 jb - * #98489# Initial support for new UNO-based backends - * - * Revision 1.15 2001/11/09 12:03:36 jb - * #86080# Corrected exception thrown for creation failures - * - * Revision 1.14 2001/11/02 12:22:35 jb - * #91782# Adjusted to change in BootstrapSettings - * - * Revision 1.13 2001/08/06 16:06:35 jb - * #85017#,#81412# Moved common bootstrap code to unotools (utl::Bootstrap) - * - * Revision 1.12 2001/08/01 12:16:00 lla - * #90434# some logging code implemented. - * - * Revision 1.11 2001/06/22 08:26:18 jb - * Correct argument-dependent caching of providers - * - * Revision 1.10 2001/05/22 07:42:07 jb - * #81412# Erroneous handling of default provider - * - * Revision 1.9 2001/05/18 16:16:52 jb - * #81412# Cleaned up bootstrap settings handling; Added recognition of bootstrap errors - * - * Revision 1.8 2001/04/03 16:33:58 jb - * Local AdministrationProvider now mapped to Setup-session - * - * Revision 1.7 2001/03/21 12:15:40 jl - * OSL_ENSHURE replaced by OSL_ENSURE - * - * Revision 1.6 2001/01/26 07:54:21 lla - * #82734# disposing with lasy writing necessary - * - * Revision 1.5 2000/12/07 16:46:12 dg - * #81469# incomplete adjustments to portal environment fixed - * - * Revision 1.4 2000/12/07 13:56:21 tlx - * #81469# - * - * Revision 1.3 2000/12/03 17:12:52 dg - * #81164# stdio missing - * - * Revision 1.2 2000/12/03 11:52:13 dg - * #81164# invalid provider instantiation - * - * Revision 1.1 2000/12/01 13:53:17 fs - * initial checkin - afctory for configuration provider(s) - * - * - * Revision 1.0 30.11.00 19:05:35 fs - ************************************************************************/ - diff --git a/configmgr/source/misc/providerfactory.hxx b/configmgr/source/misc/providerfactory.hxx index 9ec5a6d89c00..08b31c98c598 100644 --- a/configmgr/source/misc/providerfactory.hxx +++ b/configmgr/source/misc/providerfactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: providerfactory.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-09-19 10:52:06 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,15 +62,22 @@ #ifndef _CONFIGMGR_PROVIDER_FACTORY_HXX_ #define _CONFIGMGR_PROVIDER_FACTORY_HXX_ -#ifndef _CPPUHELPER_IMPLBASE2_HXX_ -#include <cppuhelper/implbase2.hxx> +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> #endif #ifndef _COM_SUN_STAR_LANG_XSINGLECOMPONENTFACTORY_HPP_ #include <com/sun/star/lang/XSingleComponentFactory.hpp> #endif -#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ +#include <com/sun/star/lang/XEventListener.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ +#include <com/sun/star/beans/NamedValue.hpp> +#endif +/* #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ #include <com/sun/star/lang/IllegalArgumentException.hpp> #endif @@ -80,121 +87,59 @@ #ifndef _COMPHELPER_STLTYPES_HXX_ #include <comphelper/stl_types.hxx> #endif - -#include "confapifactory.hxx" - -#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ -#include <com/sun/star/lang/XEventListener.hpp> -#endif - -//........................................................................ +*/ +//------------------------------------------------------------------------ namespace configmgr { -//........................................................................ - namespace uno = ::com::sun::star::uno; - namespace lang = ::com::sun::star::lang; - using ::rtl::OUString; -//........................................................................ - - uno::Reference< lang::XSingleServiceFactory > SAL_CALL - createProviderFactory( - const uno::Reference< lang::XMultiServiceFactory >& _rServiceManager, - const OUString& _rComponentName, - ::configmgr::ProviderInstantiation _pCreateFunction, - const uno::Sequence< OUString >& _rServiceNames - ); - - class ConnectionSettings; - class BootstrapSettings; - - //==================================================================== + //------------------------------------------------------------------------ + namespace uno = ::com::sun::star::uno; + namespace lang = ::com::sun::star::lang; + namespace beans = ::com::sun::star::beans; + using rtl::OUString; + //------------------------------------------------------------------------ + class ContextReader; + class ArgumentHelper; + //------------------------------------------------------------------------ //= OProviderFactory - //==================================================================== - typedef ::cppu::WeakImplHelper2< lang::XSingleServiceFactory, lang::XSingleComponentFactory > OProviderFactory_Base; - /** a special factory for the configuration provider, which implements some kind of - "shared multiple instances" factory. - */ + //------------------------------------------------------------------------ + typedef ::cppu::WeakImplHelper1< lang::XSingleComponentFactory > ProviderFactory_Base; - class OProviderFactory : public OProviderFactory_Base + /** a special factory for the configuration provider, + which maps creation arguments into a context. + */ + class ProviderFactory : public ProviderFactory_Base { - friend class ODisposingListener; - protected: - ::osl::Mutex m_aMutex; - ProviderInstantiation m_pObjectCreator; - - uno::Reference< lang::XEventListener > m_xEventListener; // must be the first uno::object - uno::Reference< lang::XMultiServiceFactory > m_xORB; - uno::Reference< uno::XInterface > m_xDefaultProvider; - - // the pure settings, not overwritten by any runtime arguments - BootstrapSettings const* m_pPureSettings; - - typedef uno::WeakReference< uno::XInterface > ProviderReference; - DECLARE_STL_USTRINGACCESS_MAP(ProviderReference, ProviderCache); - ProviderCache m_aProviders; + OUString const m_aImplementationName; + bool m_bAdmin; + public: typedef uno::Reference< uno::XComponentContext > Context; + typedef uno::Sequence < uno::Any > Arguments; + typedef uno::Sequence < beans::NamedValue > NamedValues; public: - OProviderFactory( - const uno::Reference< lang::XMultiServiceFactory >& _rxORB, - ProviderInstantiation _pObjectCreator); - ~OProviderFactory(); - - virtual uno::Reference< uno::XInterface > SAL_CALL createInstance( ) throw(uno::Exception, uno::RuntimeException); - virtual uno::Reference< uno::XInterface > SAL_CALL createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments ) throw(uno::Exception, uno::RuntimeException); + explicit + ProviderFactory(OUString const & aImplementationName, bool bAdmin); + ~ProviderFactory(); virtual uno::Reference< uno::XInterface > - SAL_CALL createInstanceWithContext( const uno::Reference< uno::XComponentContext >& xContext ) - throw (uno::Exception, ::com::sun::star::uno::RuntimeException); + SAL_CALL createInstanceWithContext(Context const & xContext ) + throw (uno::Exception, uno::RuntimeException); virtual uno::Reference< uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( const uno::Sequence< uno::Any >& aArguments, const uno::Reference< uno::XComponentContext >& xContext ) + createInstanceWithArgumentsAndContext( Arguments const & aArguments, Context const & xContext ) throw (uno::Exception, uno::RuntimeException); + private: + uno::Reference< uno::XInterface > getProviderFromContext(Context const & aContext); + uno::Reference< uno::XInterface > getProviderAlways(Context const & xContext); + uno::Reference< uno::XInterface > createProviderWithArguments(Context const & xContext, Arguments const & _aArguments); + uno::Reference< uno::XInterface > createProvider(Context const & xContext,bool bAdmin); uno::Reference< uno::XInterface > createProvider(Context const & xContext); - uno::Reference< uno::XInterface > createProviderWithArguments(Context const & xContext, const uno::Sequence< uno::Any >& _rArguments); - uno::Reference< uno::XInterface > createProviderWithSettings(Context const & xContext, const ConnectionSettings& _rSettings); - - protected: - void ensureDefaultProvider(Context const & xContext); - void ensureBootstrapSettings(Context const & xContext); - - uno::Reference< uno::XInterface > implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool bRequiresBootstrap); - // from the given map, extract a provider for the given user. (if necessary, create one and insert it into the map) - uno::Reference< uno::XInterface > implGetProvider( const ConnectionSettings& _rSettings ); - - // to be called with m:aMutex locked - void disposing(com::sun::star::lang::EventObject const& rEvt) throw(); + sal_Int32 parseArguments(ArgumentHelper & aParser, NamedValues & rValues, Arguments const & _aArguments); }; - -//........................................................................ +//------------------------------------------------------------------------ } // namespace configmgr -//........................................................................ +//------------------------------------------------------------------------ #endif // _CONFIGMGR_PROVIDER_FACTORY_HXX_ -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.6 2001/06/22 08:26:18 jb - * Correct argument-dependent caching of providers - * - * Revision 1.5 2001/05/18 16:16:52 jb - * #81412# Cleaned up bootstrap settings handling; Added recognition of bootstrap errors - * - * Revision 1.4 2001/04/03 16:33:58 jb - * Local AdministrationProvider now mapped to Setup-session - * - * Revision 1.3 2001/01/29 08:51:11 dg - * #82336# invalid syntax for template - * - * Revision 1.2 2001/01/26 07:54:21 lla - * #82734# disposing with lasy writing necessary - * - * Revision 1.1 2000/12/01 13:53:17 fs - * initial checkin - afctory for configuration provider(s) - * - * - * Revision 1.0 30.11.00 19:03:57 fs - ************************************************************************/ - diff --git a/configmgr/source/misc/providerwrapper.cxx b/configmgr/source/misc/providerwrapper.cxx new file mode 100644 index 000000000000..86d0a68b36b8 --- /dev/null +++ b/configmgr/source/misc/providerwrapper.cxx @@ -0,0 +1,220 @@ +/************************************************************************* + * + * $RCSfile: providerwrapper.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2003-03-19 16:19:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "providerwrapper.hxx" + +#ifndef CONFIGMGR_BOOTSTRAPCONTEXT_HXX_ +#include "bootstrapcontext.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HPP_ +#include <com/sun/star/lang/NullPointerException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +#include <algorithm> + +namespace configmgr +{ + //========================================================================== + namespace uno = com::sun::star::uno; + namespace lang = com::sun::star::lang; + using rtl::OUString; + //========================================================================== + //= ProviderWrapper + //========================================================================== + + uno::Reference< uno::XInterface > ProviderWrapper::create( uno::Reference< uno::XInterface > xDelegate, NamedValues const & aPresets) + { + Provider xProvDelegate(xDelegate, uno::UNO_QUERY); + if (!xProvDelegate.is()) + { + OUString sMsg(RTL_CONSTASCII_USTRINGPARAM("ProviderWrapper: Cannot wrap a NULL provider")); + throw lang::NullPointerException(sMsg,NULL); + } + + Provider xResult( new ProviderWrapper(xProvDelegate,aPresets) ); + + typedef uno::Reference< lang::XComponent > Comp; + DisposingForwarder::forward( Comp::query(xProvDelegate),Comp::query(xResult) ); + return xResult; + } + + + ProviderWrapper::ProviderWrapper(Provider const & xDelegate, NamedValues const & aPresets) + : ProviderWrapper_Base( PWMutexHolder::mutex ) + , m_xDelegate(xDelegate) + , m_aDefaults(aPresets.getLength()) + { + OSL_ASSERT(m_xDelegate.is()); + + for (sal_Int32 i = 0; i<aPresets.getLength(); ++i) + { + m_aDefaults[i] <<= aPresets[i]; + } + } + + ProviderWrapper::~ProviderWrapper() {} + + void SAL_CALL ProviderWrapper::disposing() + { + osl::MutexGuard lock(mutex); + m_xDelegate.clear(); + } + + ProviderWrapper::Provider ProviderWrapper::getDelegate() + { + osl::MutexGuard lock(mutex); + if (!m_xDelegate.is()) + { + OUString sMsg(RTL_CONSTASCII_USTRINGPARAM("ProviderWrapper: Delegate Provider has been disposed")); + throw lang::DisposedException(sMsg,*this); + } + return m_xDelegate; + } + + + uno::Reference<lang::XServiceInfo> ProviderWrapper::getDelegateInfo() + { + uno::Reference<lang::XServiceInfo> xDelegate( this->getDelegate(), uno::UNO_QUERY ); + if (!xDelegate.is()) + { + OUString sMsg(RTL_CONSTASCII_USTRINGPARAM("ProviderWrapper: Delegate Provider has no service info")); + throw uno::RuntimeException(sMsg,*this); + } + return xDelegate; + } + + /// XMultiServiceFactory + static inline uno::Any const * begin(ProviderWrapper::Arguments const & aArgs) + { return aArgs.getConstArray(); } + static inline uno::Any const * end(ProviderWrapper::Arguments const & aArgs) + { return aArgs.getConstArray() + aArgs.getLength(); } + static inline uno::Any * begin(ProviderWrapper::Arguments & aArgs) + { return aArgs.getArray(); } + static inline uno::Any * end(ProviderWrapper::Arguments & aArgs) + { return aArgs.getArray() + aArgs.getLength(); } + + ProviderWrapper::Arguments ProviderWrapper::patchArguments(Arguments const & aArgs) const + { + // rely on evaluation order front to back + if (m_aDefaults.getLength() == 0) return aArgs; + + Arguments aResult(m_aDefaults.getLength() + aArgs.getLength()); + + uno::Any * pNext = std::copy(begin(m_aDefaults),end(m_aDefaults),begin(aResult)); + pNext = std::copy(begin(aArgs),end(aArgs),pNext); + + OSL_ASSERT(end(aResult) == pNext); + + return aResult; + } + + uno::Reference< uno::XInterface > SAL_CALL + ProviderWrapper::createInstance( const OUString& aServiceSpecifier ) + throw(uno::Exception, uno::RuntimeException) + { + return getDelegate()->createInstanceWithArguments(aServiceSpecifier,m_aDefaults); + } + + uno::Reference< uno::XInterface > SAL_CALL + ProviderWrapper::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) + throw(uno::Exception, uno::RuntimeException) + { + return getDelegate()->createInstanceWithArguments(ServiceSpecifier,patchArguments(Arguments)); + } + + uno::Sequence< OUString > SAL_CALL + ProviderWrapper::getAvailableServiceNames( ) + throw(uno::RuntimeException) + { + return getDelegate()->getAvailableServiceNames( ); + } + + /// XServiceInfo + OUString SAL_CALL + ProviderWrapper::getImplementationName( ) + throw(uno::RuntimeException) + { + return OUString::createFromAscii("com.sun.star.comp.configuration.ConfigurationProviderWrapper"); + } + + sal_Bool SAL_CALL + ProviderWrapper::supportsService( const ::rtl::OUString& ServiceName ) + throw(uno::RuntimeException) + { + return getDelegateInfo()->supportsService( ServiceName ); + } + + uno::Sequence< OUString > SAL_CALL + ProviderWrapper::getSupportedServiceNames( ) + throw(uno::RuntimeException) + { + return getDelegateInfo()->getSupportedServiceNames( ); + } + + +} // namespace configmgr + + + diff --git a/configmgr/source/misc/providerwrapper.hxx b/configmgr/source/misc/providerwrapper.hxx new file mode 100644 index 000000000000..e407e2249cf5 --- /dev/null +++ b/configmgr/source/misc/providerwrapper.hxx @@ -0,0 +1,155 @@ +/************************************************************************* + * + * $RCSfile: providerwrapper.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2003-03-19 16:19:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef CONFIGMGR_API_PROVIDERWRAPPER_HXX_ +#define CONFIGMGR_API_PROVIDERWRAPPER_HXX_ + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ +#include <com/sun/star/beans/NamedValue.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +namespace configmgr +{ + //========================================================================== + namespace uno = com::sun::star::uno; + namespace lang = com::sun::star::lang; + using rtl::OUString; + //========================================================================== + //= ProviderWrapper + //========================================================================== + typedef ::cppu::WeakComponentImplHelper2 < lang::XMultiServiceFactory, + lang::XServiceInfo + > ProviderWrapper_Base; + + struct PWMutexHolder { osl::Mutex mutex; }; // ad hoc ... + + class ProviderWrapper : private PWMutexHolder, public ProviderWrapper_Base + { + public: + typedef uno::Reference< lang::XMultiServiceFactory > Provider; + typedef uno::Sequence< com::sun::star::beans::NamedValue > NamedValues; + typedef uno::Sequence< uno::Any > Arguments; + + private: + Provider m_xDelegate; + Arguments m_aDefaults; + private: + ProviderWrapper(Provider const & xDelegate, NamedValues const & aPresets); + + public: + static uno::Reference< uno::XInterface > create( uno::Reference< uno::XInterface > xDelegate, NamedValues const & aPresets); + ~ProviderWrapper(); + + /// XMultiServiceFactory + virtual uno::Reference< uno::XInterface > SAL_CALL + createInstance( const OUString& aServiceSpecifier ) + throw(uno::Exception, uno::RuntimeException); + + virtual uno::Reference< uno::XInterface > SAL_CALL + createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) + throw(uno::Exception, uno::RuntimeException); + + virtual uno::Sequence< OUString > SAL_CALL + getAvailableServiceNames( ) + throw(uno::RuntimeException); + + /// XServiceInfo + virtual OUString SAL_CALL + getImplementationName( ) + throw(uno::RuntimeException); + + virtual sal_Bool SAL_CALL + supportsService( const ::rtl::OUString& ServiceName ) + throw(uno::RuntimeException); + + virtual uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames( ) + throw(uno::RuntimeException); + + protected: + virtual void SAL_CALL disposing(); + private: + Provider getDelegate(); + uno::Reference<lang::XServiceInfo> getDelegateInfo(); + Arguments patchArguments(Arguments const & aArgs) const; + }; + + +} // namespace configmgr + +#endif // CONFIGMGR_API_CONFPROVIDER2_HXX_ + + diff --git a/configmgr/source/misc/requestoptions.cxx b/configmgr/source/misc/requestoptions.cxx index 1eb3676bbffd..d96b8286646b 100644 --- a/configmgr/source/misc/requestoptions.cxx +++ b/configmgr/source/misc/requestoptions.cxx @@ -2,9 +2,9 @@ * * $RCSfile: requestoptions.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-04-25 15:48:42 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,18 +100,6 @@ namespace configmgr } // --------------------------------------------------------------------------- - void RequestOptions::forceReload(bool _bNoCache) - { - if (_bNoCache) - { - m_nCacheID = getNextCacheID(); - } - else - { - m_nCacheID = 0; - } - } -// --------------------------------------------------------------------------- bool RequestOptions::isForAllLocales() const { @@ -127,7 +115,7 @@ namespace configmgr sal_Int32 RequestOptions::hashCode() const { - return m_sLocale.hashCode() ^ m_sEntity.hashCode() ^ m_nCacheID; + return m_sLocale.hashCode() ^ m_sEntity.hashCode(); } // --------------------------------------------------------------------------- @@ -137,9 +125,6 @@ namespace configmgr if (nDiff == 0) nDiff = lhs.getLocale().compareTo(rhs.getLocale()); - if (nDiff == 0) - nDiff = rhs.m_nCacheID - lhs.m_nCacheID; - return nDiff; } // --------------------------------------------------------------------------- diff --git a/configmgr/source/misc/strimpl.cxx b/configmgr/source/misc/strimpl.cxx index ad54ee56c723..9cdbbac39a92 100644 --- a/configmgr/source/misc/strimpl.cxx +++ b/configmgr/source/misc/strimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: strimpl.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: jb $ $Date: 2001-11-14 16:53:26 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,40 +59,14 @@ * ************************************************************************/ -#ifndef _CONFIGMGR_STRINGS_HXX_ -#include "strings.hxx" +#ifndef _CONFIGMGR_STRDECL_HXX_ +#include "strdecl.hxx" #endif namespace configmgr { - // tag names - // <name>...</name> - IMPLEMENT_CONSTASCII_USTRING(TAG_VALUE, "cfg:value"); - - // Attributes name="..." - IMPLEMENT_CONSTASCII_USTRING(ATTR_NAME, "cfg:name"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_TYPE, "cfg:type"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_TYPE_MODIFIER,"cfg:derivedBy"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_INSTANCE, "cfg:element-type"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_MODULE, "cfg:component"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_ENCODING, "cfg:encoding"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_SEPARATOR, "cfg:separator"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_NULL, "xsi:null"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_LANG, "xml:lang"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_LOCALIZE, "cfg:localized"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_NULLABLE, "cfg:nullable"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_WRITABLE, "cfg:writable"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_FINALIZE, "cfg:finalized"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_STATE, "state"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_PACKAGE, "cfg:package"); - - // boolean constants - IMPLEMENT_CONSTASCII_USTRING(ATTR_VALUE_TRUE, "true"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_VALUE_FALSE, "false"); - // simple types names IMPLEMENT_CONSTASCII_USTRING(TYPE_BOOLEAN, "boolean"); - IMPLEMENT_CONSTASCII_USTRING(TYPE_BYTE, "byte"); IMPLEMENT_CONSTASCII_USTRING(TYPE_SHORT, "short"); IMPLEMENT_CONSTASCII_USTRING(TYPE_INT, "int"); IMPLEMENT_CONSTASCII_USTRING(TYPE_LONG, "long"); @@ -102,24 +76,6 @@ namespace configmgr IMPLEMENT_CONSTASCII_USTRING(TYPE_BINARY, "binary"); // Universal type: Any IMPLEMENT_CONSTASCII_USTRING(TYPE_ANY, "any"); - // special non-value types - IMPLEMENT_CONSTASCII_USTRING(TYPE_SET, "set"); - IMPLEMENT_CONSTASCII_USTRING(TYPE_GROUP, "group"); - - // type modifier values - IMPLEMENT_CONSTASCII_USTRING(TYPE_MODIFIER_LIST, "list"); - - // States for update actions - IMPLEMENT_CONSTASCII_USTRING(STATE_MODIFIED, "modified"); - IMPLEMENT_CONSTASCII_USTRING(STATE_REPLACED, "replaced"); - IMPLEMENT_CONSTASCII_USTRING(STATE_DELETED, "deleted"); - IMPLEMENT_CONSTASCII_USTRING(STATE_DEFAULT, "default"); - - // the encoding for binary values - IMPLEMENT_CONSTASCII_USTRING(ENCODING_HEX, "hex"); - IMPLEMENT_CONSTASCII_USTRING(ENCODING_BASE64, "base64"); - - IMPLEMENT_CONSTASCII_USTRING(XML_CDATA, "CDATA"); // special template names for native/localized value types IMPLEMENT_CONSTASCII_USTRING(TEMPLATE_MODULE_NATIVE_PREFIX, "cfg:"); @@ -128,32 +84,6 @@ namespace configmgr IMPLEMENT_CONSTASCII_USTRING(TEMPLATE_LIST_SUFFIX, "-list"); - // the default separator for strings - IMPLEMENT_CONSTASCII_USTRING(DEFAULT_SEPARATOR, " "); - - // im-/export specific - IMPLEMENT_CONSTASCII_USTRING(TAG_DATA, "data"); - IMPLEMENT_CONSTASCII_USTRING(ATTR_PATH, "path"); - - // Parameter (?) - IMPLEMENT_CONSTASCII_USTRING(PARAM_OBJECT, "Object"); - IMPLEMENT_CONSTASCII_USTRING(PARAM_NAME, "Name"); - IMPLEMENT_CONSTASCII_USTRING(PARAM_ISNEWOBJECT, "IsNewObject"); - IMPLEMENT_CONSTASCII_USTRING(PARAM_GROUP, "Group"); - - // Properties - IMPLEMENT_CONSTASCII_USTRING(PROP_MEMBEROF, "MemberOf"); - - // node strings - IMPLEMENT_CONSTASCII_USTRING(NODE_TOPLEVEL, "TOPLEVEL"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERPROFILE, "org.openoffice.UserProfile"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERPROFILE_GROUP_PATH, "Data"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERPROFILE_GROUP_FIELD, "UserGroup"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERPROFILE_DEFAULTGROUP, "defaultGroup"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERPROFILE_GROUPLIST, "Template/Group"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERPROFILE_USERLIST, "Template/User"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERTEMPLATE_MODULE, "org.openoffice.Webtop.Common"); - IMPLEMENT_CONSTASCII_USTRING(NODE_USERTEMPLATE_NAME, "User"); // emacs: diff --git a/configmgr/source/misc/tracer.cxx b/configmgr/source/misc/tracer.cxx index f48f7a08ba78..19642d1758a4 100644 --- a/configmgr/source/misc/tracer.cxx +++ b/configmgr/source/misc/tracer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: tracer.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:55 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -536,58 +536,3 @@ void OConfigTracer::implTrace(const sal_Char* _pType, const sal_Char* _pFormat, #endif // defined(DEBUG) || defined(_DEBUG) -//************************************************************************** -// history: -// $Log: not supported by cvs2svn $ -// Revision 1.9 2001/05/14 08:50:25 lla -// Some bugs removed withhin tracing. -// -// Revision 1.8 2001/03/13 15:26:48 kz -// use ftime() for windows -// -// Revision 1.7 2001/03/11 02:16:13 pluby -// Replaced ftime() calls with gettimeofday() since ftime() is obsolete on Linux and Mac OS X -// -// Revision 1.6 2001/02/27 14:27:25 jb -// Correction: Do not print the message type twice -// -// Revision 1.5 2001/02/26 15:53:00 jb -// Add thread-sensitive tracing -// -// Revision 1.4 2001/02/13 09:48:02 dg -// #83239# timing output -// -// Revision 1.3 2000/11/29 12:45:31 fs -// #80122# additional traces upon initialization (process id / executable name) -// -// Revision 1.2 2000/11/07 12:14:37 hr -// #65293#: includes -// -// Revision 1.1.1.1 2000/09/18 16:13:41 hr -// initial import -// -// Revision 1.7 2000/09/15 09:51:51 willem.vandorp -// OpenOffice header added -// -// Revision 1.6 2000/08/31 10:00:21 fs -// time_t unknown -// -// Revision 1.5 2000/08/30 14:34:09 fs -// getTimeStamp -// -// Revision 1.4 2000/08/20 12:55:42 fs -// #77860# introduced an impl class; introduces virtual trace devices -// -// Revision 1.3 2000/08/17 07:18:02 lla -// im/export -// -// Revision 1.2 2000/08/10 06:53:45 fs -// read settings from the ENVCFGFLAGS environment variable -// -// Revision 1.1 2000/08/09 18:52:46 fs -// helper classes for tracing -// -// -// Revision 1.0 09.08.00 13:10:05 fs -//************************************************************************** - diff --git a/configmgr/source/registry/configregistry.cxx b/configmgr/source/registry/configregistry.cxx index 8eab1cc7aac1..a0c8c146e5cb 100644 --- a/configmgr/source/registry/configregistry.cxx +++ b/configmgr/source/registry/configregistry.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configregistry.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:34 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,6 +66,9 @@ #ifndef _CONFIGMGR_REGISTRY_CFGREGISTRYKEY_HXX_ #include "cfgregistrykey.hxx" #endif +#ifndef CONFIGMGR_API_FACTORY_HXX_ +#include "confapifactory.hxx" +#endif #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> @@ -76,18 +79,25 @@ #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> #endif + #ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_ #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETRUNTIMEEXCEPTION_HPP_ +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#endif #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include <com/sun/star/beans/PropertyValue.hpp> #endif #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ #include <com/sun/star/container/XNameAccess.hpp> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #define THISREF() static_cast< ::cppu::OWeakObject* >(this) #define UNISTRING(c) makeUniString(c) @@ -140,9 +150,12 @@ namespace beans = ::com::sun::star::beans; aAdditionalConfigRegistryServices }; - Reference< XInterface > SAL_CALL instantiateConfigRegistry(Reference< XMultiServiceFactory > const& _rServiceManager ) + Reference< XInterface > SAL_CALL instantiateConfigRegistry(CreationContext const& xContext ) { - return static_cast< ::cppu::OWeakObject* >(new OConfigurationRegistry(_rServiceManager)); + OSL_ASSERT( xContext.is() ); + Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY ); + ::cppu::OWeakObject * pNewInstance = new OConfigurationRegistry(xServiceManager); + return pNewInstance; } const ServiceRegistrationInfo* getConfigurationRegistryServiceInfo() @@ -388,9 +401,9 @@ void SAL_CALL OConfigurationRegistry::flush( ) throw(RuntimeException) // TODO : the specification of XFlushable has to be changed !!!!! OSL_ENSURE(sal_False, "OConfigurationRegistry::flush : caught an exception, could not flush the data !"); - return; + // return; - // throw RuntimeException(sMessage, THISREF()); + throw WrappedTargetRuntimeException(sMessage, THISREF(), e.TargetException); } } } @@ -402,7 +415,12 @@ void SAL_CALL OConfigurationRegistry::flush( ) throw(RuntimeException) EventObject aFlushed(THISREF()); while (aIter.hasMoreElements()) + try + { static_cast< XFlushListener* >(aIter.next())->flushed(aFlushed); + } + catch (uno::Exception & ) + {} } } diff --git a/configmgr/source/tree/cmtree.cxx b/configmgr/source/tree/cmtree.cxx index 0aec772e494f..b6092565e675 100644 --- a/configmgr/source/tree/cmtree.cxx +++ b/configmgr/source/tree/cmtree.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cmtree.cxx,v $ * - * $Revision: 1.31 $ + * $Revision: 1.32 $ * - * last change: $Author: jb $ $Date: 2002-07-14 16:49:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -137,8 +137,8 @@ namespace configmgr // ---------------------------- Node implementation ---------------------------- - INode::INode(configuration::Attributes _aAttr):m_aAttributes(_aAttr){} - INode::INode(OUString const& aName, configuration::Attributes _aAttr) + INode::INode(node::Attributes _aAttr):m_aAttributes(_aAttr){} + INode::INode(OUString const& aName, node::Attributes _aAttr) :m_aName(aName) ,m_aAttributes(_aAttr){} // CopyCTor will be create automatically @@ -174,9 +174,9 @@ namespace configmgr } // ------------------------- SearchNode implementation ------------------------- - SearchNode::SearchNode():INode(configuration::Attributes()){} + SearchNode::SearchNode():INode(node::Attributes()){} SearchNode::SearchNode(OUString const& aName) - :INode(aName, configuration::Attributes()){} + :INode(aName, node::Attributes()){} std::auto_ptr<INode> SearchNode::clone() const {return std::auto_ptr<INode>(new SearchNode(*this));} @@ -204,7 +204,7 @@ namespace configmgr static Level childLevel(Level _nLevel) { - OSL_ASSERT(0 > ITreeProvider::ALL_LEVELS); + OSL_ASSERT(0 > treeop::ALL_LEVELS); return (_nLevel > 0) ? _nLevel-1 : _nLevel; } protected: @@ -220,9 +220,9 @@ namespace configmgr //-------------------------------------------------------------------------- static inline bool adjustLevel(sal_Int16& _rLevel, sal_Int16 _nNewLevel) { - if (_rLevel == ITreeProvider::ALL_LEVELS) return false; + if (_rLevel == treeop::ALL_LEVELS) return false; if (_nNewLevel <= _rLevel && - _nNewLevel != ITreeProvider::ALL_LEVELS) return false; + _nNewLevel != treeop::ALL_LEVELS) return false; _rLevel = _nNewLevel; return true; diff --git a/configmgr/source/tree/cmtreemodel.cxx b/configmgr/source/tree/cmtreemodel.cxx index cc45a1863ed3..f02fcbe73ec2 100644 --- a/configmgr/source/tree/cmtreemodel.cxx +++ b/configmgr/source/tree/cmtreemodel.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cmtreemodel.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: jb $ $Date: 2002-10-16 07:58:27 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,17 +61,13 @@ #include <stdio.h> -#include "cmtreemodel.hxx" +#include "valuenode.hxx" +#include "change.hxx" #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif -#ifndef INCLUDED_CONFIGMGR_NAMECREATOR_HXX -#include "namecreator.hxx" -#endif -#ifndef _CONFIGMGR_STRDECL_HXX_ #include "strdecl.hxx" -#endif #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> diff --git a/configmgr/source/tree/localizedtreeactions.cxx b/configmgr/source/tree/localizedtreeactions.cxx index 2e6a3a1a3062..5355e45cb427 100644 --- a/configmgr/source/tree/localizedtreeactions.cxx +++ b/configmgr/source/tree/localizedtreeactions.cxx @@ -2,9 +2,9 @@ * * $RCSfile: localizedtreeactions.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:27:42 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -331,7 +331,7 @@ static std::auto_ptr<INode> impl_cloneExpandedForLocale(INode const* _pNode, OUS //-------------------------------------------------------------------------- // convert to the given locale format, assuming the original representation was expanded -static data::TreeSegment old_cloneExpandedForLocale(OUString const& _sName, INode const* _pNode, OUString const& _sLocale, bool bMakeWritable) +static data::TreeSegment old_cloneExpandedForLocale(OUString const& _sName, INode const* _pNode, OUString const& _sLocale) { using data::TreeSegment; @@ -345,9 +345,6 @@ static data::TreeSegment old_cloneExpandedForLocale(OUString const& _sName, INod else aResult = impl_cloneExpandedForLocale(_pNode,_sLocale); - if (bMakeWritable && aResult.get() != NULL) - forceWritable(*aResult); - return TreeSegment::createNew(_sName,aResult); } //-------------------------------------------------------------------------- @@ -360,17 +357,17 @@ data::TreeSegment cloneForLocale(INode const* _pNode, OUString const& _sLocale) "WARNING: This function doesn't work from single values to expanded sets so far"); OUString sName = _pNode ? _pNode->getName() : OUString(); - return old_cloneExpandedForLocale(sName, _pNode,_sLocale,false); + return old_cloneExpandedForLocale(sName, _pNode,_sLocale); } //-------------------------------------------------------------------------- // ----------------------------------------------------------------------------- //-------------------------------------------------------------------------- -data::TreeSegment cloneExpandedForLocale(data::TreeAccessor const & _aTree, OUString const& _sLocale, bool bMakeWritable) +data::TreeSegment cloneExpandedForLocale(data::TreeAccessor const & _aTree, OUString const& _sLocale) { std::auto_ptr<INode> aOldTree = data::convertTree(_aTree,true); - return old_cloneExpandedForLocale(_aTree.getName().toString(), aOldTree.get(),_sLocale,bMakeWritable); + return old_cloneExpandedForLocale(_aTree.getName().toString(), aOldTree.get(),_sLocale); } // ----------------------------------------------------------------------------- //-------------------------------------------------------------------------- diff --git a/configmgr/source/tree/makefile.mk b/configmgr/source/tree/makefile.mk index a5e064e88a0a..22e170a5ed46 100644 --- a/configmgr/source/tree/makefile.mk +++ b/configmgr/source/tree/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: jb $ $Date: 2002-02-11 13:47:55 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:19:38 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -88,16 +88,16 @@ SLOFILES=\ $(SLO)$/valuenodeaccess.obj \ $(SLO)$/groupnodeaccess.obj \ $(SLO)$/setnodeaccess.obj \ - $(SLO)$/localizedtreeactions.obj \ + $(SLO)$/changes.obj \ $(SLO)$/treenodefactory.obj \ $(SLO)$/treechangefactory.obj \ - $(SLO)$/changes.obj \ + $(SLO)$/localizedtreeactions.obj \ $(SLO)$/treeactions.obj \ - $(SLO)$/mergehelper.obj \ - $(SLO)$/updatehelper.obj \ - $(SLO)$/nodeconverter.obj \ $(SLO)$/cmtreemodel.obj \ $(SLO)$/cmtree.obj \ + $(SLO)$/nodeconverter.obj \ + $(SLO)$/updatehelper.obj \ + $(SLO)$/mergehelper.obj \ # --- Targets --- diff --git a/configmgr/source/tree/mergehelper.cxx b/configmgr/source/tree/mergehelper.cxx index 37c1cb7874be..a9274bc3de27 100644 --- a/configmgr/source/tree/mergehelper.cxx +++ b/configmgr/source/tree/mergehelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: mergehelper.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:55 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,9 @@ #ifndef CONFIGMGR_TREE_CHANGEFACTORY_HXX #include "treechangefactory.hxx" #endif +#ifndef CONFIGMGR_CONFIGPATH_HXX_ +#include "configpath.hxx" +#endif #ifndef _CONFIGMGR_TRACER_HXX_ #include "tracer.hxx" @@ -276,7 +279,7 @@ void OCleanupLayerAction::handle(SubtreeChange& _rChange) std::auto_ptr<ISubtree> pNode = m_aNodeConverter.createCorrespondingTree(_rChange); // mark as complete with defaults) - pNode->setLevels(ITreeProvider::ALL_LEVELS,ITreeProvider::ALL_LEVELS); + pNode->setLevels(treeop::ALL_LEVELS,treeop::ALL_LEVELS); this->addReplacedNode( base_ptr(pNode) ); } diff --git a/configmgr/source/tree/subtree.hxx b/configmgr/source/tree/subtree.hxx index 9d06f438c02a..173fc80ebdaf 100644 --- a/configmgr/source/tree/subtree.hxx +++ b/configmgr/source/tree/subtree.hxx @@ -2,9 +2,9 @@ * * $RCSfile: subtree.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:55 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,7 +113,7 @@ namespace configmgr Subtree(){} Subtree(const OUString& _rName, - const configuration::Attributes& _rAttrs) + const node::Attributes& _rAttrs) :ISubtree(_rName, _rAttrs){}; Subtree(const ISubtree& _rOther, NoChildCopy) @@ -121,7 +121,7 @@ namespace configmgr Subtree(const OUString& _rName, const OUString& _rTemplateName, const OUString& _rTemplateModule, - const configuration::Attributes& _rAttrs) + const node::Attributes& _rAttrs) :ISubtree(_rName, _rTemplateName, _rTemplateModule, _rAttrs){}; Subtree(const Subtree& _rOther, treeop::DeepChildCopy _dc) diff --git a/configmgr/source/tree/treechangefactory.cxx b/configmgr/source/tree/treechangefactory.cxx index 369c14a8e708..d18dfc81b7cb 100644 --- a/configmgr/source/tree/treechangefactory.cxx +++ b/configmgr/source/tree/treechangefactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: treechangefactory.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:55 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,6 +67,9 @@ #include "change.hxx" #endif +#ifndef CONFIGMGR_CONFIGPATH_HXX_ +#include "configpath.hxx" +#endif namespace configmgr { @@ -109,7 +112,7 @@ OTreeChangeFactory& getDefaultTreeChangeFactory() //= ValueNodes ============================================================ std::auto_ptr<ValueChange> OTreeChangeFactory::createValueChange( Name const& _aName, - configuration::Attributes _aAttrs, + node::Attributes _aAttrs, ValueChange::Mode _eMode, uno::Any const& _aNewValue, uno::Any const& _aOldValue @@ -166,14 +169,14 @@ std::auto_ptr<SubtreeChange> OTreeChangeFactory::createDummyChange( if (_aElementTypeName.isEmpty()) { - pResult.reset( new SubtreeChange(_aName.toString(),configuration::Attributes()) ); + pResult.reset( new SubtreeChange(_aName.toString(),node::Attributes()) ); } else { pResult.reset( new SubtreeChange(_aName.toString(), _aElementTypeName.toString(), getDummySetElementModule().toString(), - configuration::Attributes()) ); + node::Attributes()) ); } return pResult; } @@ -181,7 +184,7 @@ std::auto_ptr<SubtreeChange> OTreeChangeFactory::createDummyChange( //----------------------------------------------- std::auto_ptr<SubtreeChange> OTreeChangeFactory::createGroupNodeChange( Name const& _aName, - configuration::Attributes _aAttrs, + node::Attributes _aAttrs, bool _bToDefault) { return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName,_aAttrs,_bToDefault)); @@ -192,7 +195,7 @@ std::auto_ptr<SubtreeChange> OTreeChangeFactory::createSetNodeChange( Name const& _aName, Name const& _aTemplateName, Name const& _aTemplateModule, - configuration::Attributes _aAttrs, + node::Attributes _aAttrs, bool _bToDefault) { return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName, diff --git a/configmgr/source/tree/treenodefactory.cxx b/configmgr/source/tree/treenodefactory.cxx index 18e0e85dfe15..94aac74f3e6d 100644 --- a/configmgr/source/tree/treenodefactory.cxx +++ b/configmgr/source/tree/treenodefactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: treenodefactory.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2001-07-16 17:01:35 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,9 @@ #include "treechangefactory.hxx" #endif +#ifndef CONFIGMGR_CONFIGPATH_HXX_ +#include "configpath.hxx" +#endif namespace configmgr { @@ -90,7 +93,7 @@ OTreeNodeFactory& getDefaultTreeNodeFactory() std::auto_ptr<ValueNode> OTreeNodeFactory::createValueNode( rtl::OUString const& aName, uno::Any const& aValue, - configuration::Attributes _aAttrs) + node::Attributes _aAttrs) { OSL_ENSURE(aValue.hasValue(), "OTreeNodeFactory: Creating a value node having no type"); return std::auto_ptr<ValueNode>( new ValueNode(aName, aValue, _aAttrs) ); @@ -102,7 +105,7 @@ std::auto_ptr<ValueNode> OTreeNodeFactory::createValueNode( rtl::OUString const& aName, uno::Any const& aValue, uno::Any const& aDefault, - configuration::Attributes _aAttrs) + node::Attributes _aAttrs) { OSL_ENSURE(aValue.hasValue() || aDefault.hasValue(), "OTreeNodeFactory: Creating a value node having no type"); return std::auto_ptr<ValueNode>( new ValueNode(aName, aValue, aDefault, _aAttrs) ); @@ -114,7 +117,7 @@ std::auto_ptr<ValueNode> OTreeNodeFactory::createValueNode( std::auto_ptr<ValueNode> OTreeNodeFactory::createNullValueNode( rtl::OUString const& aName, uno::Type const& aType, - configuration::Attributes _aAttrs) + node::Attributes _aAttrs) { OSL_ENSURE(aType.getTypeClass() != uno::TypeClass_VOID, "OTreeNodeFactory: Creating a value node having VOID type"); return std::auto_ptr<ValueNode>( new ValueNode(aName, aType, _aAttrs) ); @@ -129,14 +132,14 @@ std::auto_ptr<ISubtree> OTreeNodeFactory::createDummyTree(Name const& _aName, Na if (_aElementTypeName.isEmpty()) { - pResult.reset( new Subtree(_aName.toString(),configuration::Attributes()) ); + pResult.reset( new Subtree(_aName.toString(),node::Attributes()) ); } else { pResult.reset( new Subtree(_aName.toString(), _aElementTypeName.toString(), getDummySetElementModule().toString(), - configuration::Attributes()) ); + node::Attributes()) ); } return pResult; } @@ -145,7 +148,7 @@ std::auto_ptr<ISubtree> OTreeNodeFactory::createDummyTree(Name const& _aName, Na std::auto_ptr<ISubtree> OTreeNodeFactory::createGroupNode( rtl::OUString const& aName, - configuration::Attributes _aAttrs) + node::Attributes _aAttrs) { return std::auto_ptr<ISubtree>( new Subtree(aName, _aAttrs) ); } @@ -157,7 +160,7 @@ std::auto_ptr<ISubtree> OTreeNodeFactory::createSetNode( rtl::OUString const& aName, rtl::OUString const& _rTemplateName, rtl::OUString const& _rTemplateModule, - configuration::Attributes _aAttrs) + node::Attributes _aAttrs) { return std::auto_ptr<ISubtree>( new Subtree(aName, _rTemplateName, _rTemplateModule, _aAttrs) ); } diff --git a/configmgr/source/tree/updatehelper.cxx b/configmgr/source/tree/updatehelper.cxx index b92e2885ef5c..c5c36ab25041 100644 --- a/configmgr/source/tree/updatehelper.cxx +++ b/configmgr/source/tree/updatehelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: updatehelper.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:26:17 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -376,7 +376,7 @@ void AdjustUpdate::handle(SubtreeChange& _rChange) OSL_ASSERT(pNode.get() != NULL); // set the level - pNode->setLevels(ITreeProvider::ALL_LEVELS,ITreeProvider::ALL_LEVELS); + pNode->setLevels(treeop::ALL_LEVELS,treeop::ALL_LEVELS); OSL_ENSURE(m_rChangeList.isSetNodeChange(), "Adding a new value to a non-set node"); OUString sTypeName = m_rChangeList.getElementTemplateName(); diff --git a/configmgr/source/treecache/cacheaccess.cxx b/configmgr/source/treecache/cacheaccess.cxx index 097700666d41..12dfc23521ec 100644 --- a/configmgr/source/treecache/cacheaccess.cxx +++ b/configmgr/source/treecache/cacheaccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cacheaccess.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:30:42 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,7 +76,7 @@ #endif #ifndef CONFIGMGR_CONFIGPATH_HXX_ -#include "configpath.hxx +#include "configpath.hxx" #endif namespace configmgr diff --git a/configmgr/source/treecache/cacheaccess.hxx b/configmgr/source/treecache/cacheaccess.hxx index acf48d3c5421..4f326d4bb399 100644 --- a/configmgr/source/treecache/cacheaccess.hxx +++ b/configmgr/source/treecache/cacheaccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cacheaccess.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:30:43 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,9 @@ #ifndef CONFIGMGR_TIMESTAMP_HXX #include "timestamp.hxx" #endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif #ifndef _OSL_MUTEX_HXX_ #include <osl/mutex.hxx> @@ -88,7 +91,7 @@ namespace configmgr //----------------------------------------------------------------------------- - class CacheClientAccess : public salhelper::SimpleReferenceObject, NotCopyable + class CacheClientAccess : public salhelper::SimpleReferenceObject, Noncopyable { public: typedef CacheData Data; @@ -149,7 +152,7 @@ namespace configmgr //////////////////////////////////////////////////////////////////////////////// - class CacheLoadingAccess : public salhelper::SimpleReferenceObject, NotCopyable + class CacheLoadingAccess : public salhelper::SimpleReferenceObject, Noncopyable { public: typedef ExtendedCacheData Data; diff --git a/configmgr/source/treecache/cachecontroller.cxx b/configmgr/source/treecache/cachecontroller.cxx index ffca5917d93c..781c7e29e130 100644 --- a/configmgr/source/treecache/cachecontroller.cxx +++ b/configmgr/source/treecache/cachecontroller.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cachecontroller.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: ssmith $ $Date: 2002-12-18 15:29:36 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -436,10 +436,10 @@ CacheLocation CacheController::loadComponent(ComponentRequest const & _aRequest) data::TreeAddress aResultAddress; data::TreeAddress aTemplateResultAdddress; + OSL_ENSURE(!_aRequest.isForcingReload(),"CacheController: No support for forced requests"); if (aCache->hasModule(_aRequest.getComponentName())) { CFG_TRACE_INFO_NI("CacheController: found node in cache"); - OSL_ENSURE(!_aRequest.getOptions().isForcingReload(),"CacheController: Found node in cache for non-cachable request"); aResultAddress = aCache->acquireModule(_aRequest.getComponentName()); } @@ -660,7 +660,7 @@ void CacheController::saveAndNotify(UpdateRequest const & _anUpdate) CFG_UNO_THR aCache->addChangesToPending(_anUpdate.getUpdate()); - if ( _anUpdate.isForcingFlush()|| m_bDisposing ) // cannot do it asynchronously + if ( _anUpdate.isSyncRequired()|| m_bDisposing ) // cannot do it asynchronously { CFG_TRACE_INFO_NI("Running synchronous write"); savePendingChanges( aCache, getComponentRequest(_anUpdate) ); @@ -741,7 +741,7 @@ ComponentResult CacheController::loadDirectly(ComponentRequest const & _aRequest NodeRequest aNodeRequest(aRequestPath, _aRequest.getOptions()); - ComponentResult aResult = m_xBackend->getNodeData(_aRequest); + ComponentResult aResult = m_xBackend->getNodeData(_aRequest, this); OSL_PRECOND(aResult.mutableInstance().mutableData().get(), "loadDirectly: Data must not be NULL"); @@ -879,10 +879,7 @@ void CacheController::freeComponent(ComponentRequest const & _aRequest) CFG_NOTH if (aCache->releaseModule(_aRequest.getComponentName()) == 0) { // start the cleanup - if (_aRequest.getOptions().isForcingReload()) // not sharable -> dispose at once - this->disposeOne(_aRequest.getOptions(),true); - else - m_pDisposer->scheduleCleanup(_aRequest.getOptions()); + m_pDisposer->scheduleCleanup(_aRequest.getOptions()); } } } diff --git a/configmgr/source/treecache/cachecontroller.hxx b/configmgr/source/treecache/cachecontroller.hxx index 332e6372e623..856dc4d12df3 100644 --- a/configmgr/source/treecache/cachecontroller.hxx +++ b/configmgr/source/treecache/cachecontroller.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cachecontroller.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: ssmith $ $Date: 2002-12-16 12:49:25 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/configmgr/source/treecache/cachedata.cxx b/configmgr/source/treecache/cachedata.cxx index 37a4db4d19a8..fec5d39a246f 100644 --- a/configmgr/source/treecache/cachedata.cxx +++ b/configmgr/source/treecache/cachedata.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cachedata.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-12-16 12:49:25 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,7 +88,7 @@ #endif #ifndef CONFIGMGR_CONFIGPATH_HXX_ -#include "configpath.hxx +#include "configpath.hxx" #endif namespace configmgr diff --git a/configmgr/source/treecache/cachedata.hxx b/configmgr/source/treecache/cachedata.hxx index 597e42f726e2..c51302f15dd2 100644 --- a/configmgr/source/treecache/cachedata.hxx +++ b/configmgr/source/treecache/cachedata.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cachedata.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-12-16 12:49:25 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/configmgr/source/treecache/cachefactory.cxx b/configmgr/source/treecache/cachefactory.cxx index 36fdb22164d2..59e660882a6c 100644 --- a/configmgr/source/treecache/cachefactory.cxx +++ b/configmgr/source/treecache/cachefactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cachefactory.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:30:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,9 +101,9 @@ namespace configmgr // ------------------------------------------------------------------------- rtl::Reference<TreeManager> - CacheFactory::createCacheManager(ConnectionSettings const & _aSettings, CreationContext const & _xContext) + CacheFactory::createCacheManager(CreationContext const & _xContext) { - MergedBackendRef xBackend = backend::BackendFactory::instance().createBackend(_aSettings,_xContext); + MergedBackendRef xBackend = backend::BackendFactory::instance(_xContext).createBackend(); return buildCacheManager(xBackend); } diff --git a/configmgr/source/treecache/cacheline.cxx b/configmgr/source/treecache/cacheline.cxx index 858c35e145e5..790baa118cc7 100644 --- a/configmgr/source/treecache/cacheline.cxx +++ b/configmgr/source/treecache/cacheline.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cacheline.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ssmith $ $Date: 2002-12-16 12:49:26 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,225 +90,6 @@ namespace configmgr { -/* using namespace configuration; - // ========================================================================= - struct ONodeIdCollector : public NodeAction - { - typedef std::set< rtl::OUString, UStringLess > NodeIdSet; - NodeIdSet ids; - - ONodeIdCollector() : ids() { } - - virtual void handle(ValueNode const& _rValueNode) { /* not interested in value nodes * / } - virtual void handle(ISubtree const& _rSubtree) { ids.insert(_rSubtree.getId()); applyToChildren(_rSubtree); } - }; - - //========================================================================== - static - inline - INode* findExistingChild(ISubtree* pCurrentParent, Path::Component const & _aName) - { - OSL_ASSERT(pCurrentParent); - - INode * pChild = pCurrentParent->getChild(_aName.getName().toString()); - - if (!pChild && !_aName.isSimpleName()) - { - pChild = pCurrentParent->getChild(_aName.toPathString()); - OSL_ENSURE(!pChild, "TreeData trouble: Existing node found only by composite name"); - } - - return pChild; - } - //========================================================================== - static - inline - INode* findExistingChild(ISubtree* pCurrentParent, OUString const & _aName) - { - OSL_ASSERT(pCurrentParent); - - INode * pChild = pCurrentParent->getChild(_aName ); - - return pChild; - } - //========================================================================== - - static sal_Int16 childLevel(sal_Int16 _nLevel) - { - OSL_ASSERT(0 > ITreeProvider::ALL_LEVELS); - return (_nLevel > 0) ? _nLevel-1 : _nLevel; - } - - //========================================================================== - static bool deeper(sal_Int16 lhs, sal_Int16 rhs) - { - if (rhs == ITreeProvider::ALL_LEVELS) return false; - if (lhs == ITreeProvider::ALL_LEVELS) return true; - return lhs > rhs; - } - */ - //========================================================================== - //= OCompleteTree - //========================================================================== - /** completes the cache with missing subelements - */ -/* class OCompleteTree : private NodeModification - { - public: - typedef sal_Int16 Level; - - static bool complete(ISubtree& _rExistingSubtree, ISubtree& _rNewSubtree, - Level _nNewDepth, Level _nDefaultDepth); - private: - OCompleteTree(ISubtree* pSubtree, Level _nParentLevel, Level _nParentDefaultLevel) - :m_pCacheSubtree(pSubtree) - ,m_nChildLevel( childLevel(_nParentLevel) ) - ,m_nDefaultLevel( childLevel(_nParentDefaultLevel) ) - { - OSL_ENSURE(m_pCacheSubtree,"OCompleteTree: Need a tree to complete"); - - OSL_ENSURE(m_pCacheSubtree->hasId(), "WARNING: Completing subtree without ID"); - } - - virtual void handle(ValueNode& _rNode); - virtual void handle(ISubtree& _rSubtree); - - private: - ISubtree* m_pCacheSubtree; - sal_Int16 m_nChildLevel; - sal_Int16 m_nDefaultLevel; - }; - //---------------------------------------------------------------------- - void OCompleteTree::handle(ValueNode& _rNode) - { - OSL_ASSERT(m_pCacheSubtree); - - OUString aNodeName = _rNode.getName(); - INode* pChild = m_pCacheSubtree->getChild(aNodeName); - // only not existing nodes are interesting other should be in the cache - if (!pChild) - { - std::auto_ptr<INode> pNewChild( _rNode.clone() ); - - pChild = m_pCacheSubtree->addChild(pNewChild); - } - else - { - OSL_ENSURE(pChild->ISA(ValueNode), "OCompleteTree: Node type mismatch"); - if (ValueNode* pValue = pChild->asValueNode()) - { - if (m_nDefaultLevel != 0) - pValue->changeDefault(_rNode.getDefault()); - - OSL_ENSURE(!m_nChildLevel || pValue->getValue() == _rNode.getValue(), - "WARNING: Cached value differs from data being spliced"); - } - } - } - //---------------------------------------------------------------------- - - void OCompleteTree::handle(ISubtree& _rSubtree) - { - OSL_ASSERT(m_pCacheSubtree); - - OUString aNodeName = _rSubtree.getName(); - INode* pChild = m_pCacheSubtree->getChild(aNodeName); - - // now we have different possibilites - // a.) the node does not exist than clone the subtree and add it to the cache tree - if (!pChild) - { - std::auto_ptr<INode> pNewChild( _rSubtree.clone() ); - - ISubtree* pChildTree = pNewChild->asISubtree(); - - OSL_ASSERT(pChildTree); - OSL_ASSERT(!pChildTree->hasId()); // should be cleared by cloning a subtree - - OSL_ENSURE(_rSubtree.hasId() || m_pCacheSubtree->hasId(), "WARNING: OCompleteTree: completing a tree without ID"); - OUString const aTreeId = _rSubtree.hasId() ? _rSubtree.getId() : m_pCacheSubtree->getId(); - - OIdPropagator::propagateIdToTree(aTreeId, *pChildTree); - - pChild = m_pCacheSubtree->addChild(pNewChild); - - OSL_ASSERT(pChild && pChild->asISubtree()); - OSL_ENSURE(pChild->asISubtree()->getId()== aTreeId, "OCompleteTree: Tree lost ID while being added"); - } - else - { - ISubtree* pSubTree = pChild->asISubtree(); - OSL_ENSURE(pSubTree, "OCompleteTree::handle : node must be a inner node!"); - - // b.) the node does exist with level all or greater level -> nothing to do - // c.) the node does exist but with smaller level - if (pSubTree) - { - complete(*pSubTree, _rSubtree, m_nChildLevel, m_nDefaultLevel); - - OSL_ENSURE(pSubTree->hasId(), "OCompleteTree: Completed Tree has no ID"); - } - // else throw something (?) - } - } - //---------------------------------------------------------------------- - bool OCompleteTree::complete(ISubtree& _rExistingSubtree, ISubtree& _rNewSubtree, - Level _nNewDepth, Level _nDefaultDepth) - { - - OSL_ENSURE(_rNewSubtree.hasId(),"WARNING: Completing subtree without providing an ID"); - - Level const nExistingLevels = _rExistingSubtree.getLevel(); - Level const nExistingDefaults = _rExistingSubtree.getDefaultsLevel(); - if (!_rExistingSubtree.hasId()) - { - // if it has levels, it surely was really loaded (and therefore has an ID) - OSL_ENSURE(nExistingLevels == 0,"ERROR: Dummy subtree has nonzero levels"); - OSL_ENSURE(nExistingDefaults == 0,"ERROR: Dummy subtree has nonzero default levels"); - OSL_ENSURE(_nNewDepth != 0,"ERROR: Merging default for data that isn't loaded"); - - // the tree wasn't loaded before - OSL_ENSURE(!_rExistingSubtree.getElementTemplateName().getLength(), - "WARNING: Dummy tree has child template"); - OSL_ENSURE(!_rExistingSubtree.getElementTemplateName().getLength() || _rNewSubtree.getElementTemplateName().getLength(), - "ERROR: Dummy tree with child template replaced by node without child template"); - OSL_ENSURE(_rExistingSubtree.getName() == _rNewSubtree.getName(), - "ERROR: Dummy tree renamed by completion (?!)"); - - // bad hack: abuse of assignment operator to update a slice of _rExistingSubtree - _rExistingSubtree = _rNewSubtree; - - // id is copied by assignment (but not by copy ctor) - OSL_ASSERT(_rExistingSubtree.getId() == _rNewSubtree.getId()); - // _rExistingSubtree.setId(_rNewSubtree.getId(); - } - else - { - OSL_ENSURE(_rExistingSubtree.getName() == _rNewSubtree.getName(), - "ERROR: Existing tree replaced by node with different name"); - - OSL_ENSURE(_rExistingSubtree.getElementTemplateName() == _rNewSubtree.getElementTemplateName(), - "ERROR: Existing tree replaced by node with different child template"); - } - - bool bAddingData = deeper(_nNewDepth,nExistingLevels); - bool bAddingDefaults = deeper(_nDefaultDepth,nExistingDefaults); - bool bAdding = bAddingData || bAddingDefaults; - - if (bAdding) - { - // now do it - OCompleteTree aCompleter(&_rExistingSubtree, _nNewDepth, _nDefaultDepth); - aCompleter.applyToChildren(_rNewSubtree); - //_rExistingSubtree.setLevel(_nNewDepth); // don't do it here, as this is recursive - } - // else nothing to do (well, we should check/refresh - at least in DEBUG) - - OSL_ENSURE(_rExistingSubtree.hasId(), "OCompleteTree: Completed Tree lost ID"); - - return bAdding; // true only if we actually did something - } -*/ // ----------------------------------------------------------------------------- static inline CacheLine::Name implExtractModuleName(CacheLine::Path const& _aConfigPath) { diff --git a/configmgr/source/treecache/cacheline.hxx b/configmgr/source/treecache/cacheline.hxx index 94e2122b1ab3..4bdedd03bf31 100644 --- a/configmgr/source/treecache/cacheline.hxx +++ b/configmgr/source/treecache/cacheline.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cacheline.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ssmith $ $Date: 2002-12-13 10:30:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,9 @@ #ifndef CONFIGMGR_BACKEND_REQUESTTYPES_HXX_ #include "requesttypes.hxx" #endif +#ifndef CONFIGMGR_UTILITY_HXX_ +#include "utility.hxx" +#endif #ifndef _OSL_INTERLOCK_H_ #include <osl/interlck.h> @@ -94,7 +97,7 @@ namespace configmgr //////////////////////////////////////////////////////////////////////////////// /** This object represents a cache line for a single configuration tree */ - class CacheLine : public salhelper::SimpleReferenceObject, NotCopyable + class CacheLine : public salhelper::SimpleReferenceObject, Noncopyable { public: typedef oslInterlockedCount RefCount; diff --git a/configmgr/source/treecache/disposetimer.hxx b/configmgr/source/treecache/disposetimer.hxx index f7852f4c9c1b..b28f80875c3c 100644 --- a/configmgr/source/treecache/disposetimer.hxx +++ b/configmgr/source/treecache/disposetimer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: disposetimer.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2002-03-28 09:08:05 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_DISPOSETIMER_HXX #define CONFIGMGR_DISPOSETIMER_HXX -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_TIMESTAMP_HXX #include "timestamp.hxx" #endif diff --git a/configmgr/source/treecache/invalidatetree.cxx b/configmgr/source/treecache/invalidatetree.cxx index 98d22e4b47b4..1aad745ccb86 100644 --- a/configmgr/source/treecache/invalidatetree.cxx +++ b/configmgr/source/treecache/invalidatetree.cxx @@ -2,9 +2,9 @@ * * $RCSfile: invalidatetree.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: ssmith $ $Date: 2002-12-16 12:49:26 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/configmgr/source/treecache/timestamp.hxx b/configmgr/source/treecache/timestamp.hxx index b6a22bcac59f..41648dc1fbb5 100644 --- a/configmgr/source/treecache/timestamp.hxx +++ b/configmgr/source/treecache/timestamp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: timestamp.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2000-12-15 16:14:03 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,7 +62,6 @@ #ifndef CONFIGMGR_TIMESTAMP_HXX #define CONFIGMGR_TIMESTAMP_HXX -#include "apitypes.hxx" #include <vos/timer.hxx> namespace configmgr diff --git a/configmgr/source/treecache/treemanager.cxx b/configmgr/source/treecache/treemanager.cxx index 3b8294dc2737..d9fe15bbd6cc 100644 --- a/configmgr/source/treecache/treemanager.cxx +++ b/configmgr/source/treecache/treemanager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: treemanager.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-10-14 14:19:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -250,10 +250,10 @@ void TreeManager::implDisposeOne(CacheRef const & _aDisposedCache, RequestOption // ConfigChangeBroadcaster // ------------------------------------------------------------------------- -ConfigChangeBroadcastHelper* TreeManager::getBroadcastHelper(vos::ORef<OOptions> const& _xOptions, bool bCreate) +ConfigChangeBroadcastHelper* TreeManager::getBroadcastHelper(RequestOptions const& _aOptions, bool bCreate) { - CacheRef aCache = bCreate ? this->getCacheAlways(_xOptions->getRequestOptions()) - : m_aCacheList.get(_xOptions->getRequestOptions()); + CacheRef aCache = bCreate ? this->getCacheAlways(_aOptions) + : m_aCacheList.get(_aOptions); return aCache.is() ? aCache->getBroadcaster() : NULL; } @@ -331,9 +331,10 @@ TreeManager::CacheRef TreeManager::getCacheAlways(RequestOptions const & _aOptio } // ------------------------------------------------------------------------- -memory::Segment* TreeManager::getDataSegment(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions) +memory::Segment* TreeManager::getDataSegment(AbsolutePath const& _rAccessor, + const RequestOptions& _aOptions) { - CacheRef aCache = m_aCacheList.get(_xOptions->getRequestOptions()); + CacheRef aCache = m_aCacheList.get(_aOptions); OSL_ENSURE(aCache.is(), "No cache data to get segment for"); @@ -346,12 +347,12 @@ memory::Segment* TreeManager::getDataSegment(AbsolutePath const& _rAccessor, con // ------------------------------------------------------------------------- data::NodeAccess TreeManager::requestSubtree(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) + const RequestOptions& _aOptions) + CFG_UNO_THROW_ALL( ) { CFG_TRACE_INFO("TreeManager: request for subtree '%s'", OUSTRING2ASCII(aSubtreePath.toString())); - CacheRef aCache = getCacheAlways(_xOptions->getRequestOptions()); + CacheRef aCache = getCacheAlways(_aOptions); OSL_ENSURE(aCache.is(),"TreeManager: Cannot create cache access for loading node"); data::Accessor aAccessor(NULL); @@ -359,7 +360,7 @@ data::NodeAccess TreeManager::requestSubtree(AbsolutePath const& aSubtreePath, if (!aCache->hasModule(aSubtreePath)) { CFG_TRACE_INFO_NI("TreeManager: cache miss. going to load the node"); - backend::ComponentRequest aQuery( aSubtreePath.getModuleName(), _xOptions->getRequestOptions() ); + backend::ComponentRequest aQuery( aSubtreePath.getModuleName(), _aOptions ); backend::CacheLocation aLoadedLocation = getCacheLoader()->loadComponent(aQuery); if (aLoadedLocation.isNull()) @@ -377,7 +378,6 @@ data::NodeAccess TreeManager::requestSubtree(AbsolutePath const& aSubtreePath, else { CFG_TRACE_INFO_NI("TreeManager: found node in cache"); - OSL_ENSURE(_xOptions->canUseCache(),"TreeManager: Found node in cache for non-cachable request"); aAccessor = data::Accessor(aCache->getDataSegment(aSubtreePath)); OSL_ENSURE(aAccessor.is(),"Cannot get accessor for existing component"); @@ -389,7 +389,7 @@ data::NodeAccess TreeManager::requestSubtree(AbsolutePath const& aSubtreePath, } // ------------------------------------------------------------------------- -void TreeManager::fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& , sal_Int16 ) CFG_NOTHROW() +void TreeManager::fetchSubtree(AbsolutePath const& aSubtreePath, const RequestOptions& ) CFG_NOTHROW() { CFG_TRACE_WARNING("TreeManager: Prefetching not implemented. (Request to prefetch component %s.", OUSTRING2ASCII(aSubtreePath.toString())); } @@ -397,12 +397,12 @@ void TreeManager::fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef // ------------------------------------------------------------------------- sal_Bool TreeManager::fetchDefaultData( memory::UpdateAccessor& _aAccessToken, AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) + const RequestOptions& _aOptions + ) CFG_UNO_THROW_ALL( ) { CFG_TRACE_INFO("tree manager: checking the cache for defaults"); - CacheRef aCache = m_aCacheList.get(_xOptions->getRequestOptions()); + CacheRef aCache = m_aCacheList.get(_aOptions); if (!aCache.is()) { @@ -418,7 +418,7 @@ sal_Bool TreeManager::fetchDefaultData( memory::UpdateAccessor& _aAccessToken, AbsolutePath aRequestPath = extractModulePath(aSubtreePath); - backend::NodeRequest aRequest(aRequestPath,_xOptions->getRequestOptions()); + backend::NodeRequest aRequest(aRequestPath,_aOptions); backend::NodeResult aDefaults = getCacheLoader()->getDirectDataProvider().getDefaultData( aRequest ); @@ -436,13 +436,13 @@ sal_Bool TreeManager::fetchDefaultData( memory::UpdateAccessor& _aAccessToken, // ------------------------------------------------------------------------- std::auto_ptr<ISubtree> TreeManager::requestDefaultData(AbsolutePath const& aSubtreePath, - const vos::ORef < OOptions >& _xOptions, - sal_Int16 nMinLevels) CFG_UNO_THROW_ALL( ) + const RequestOptions& _aOptions + ) CFG_UNO_THROW_ALL( ) { // to do: check cache for existing default data (?!) CFG_TRACE_INFO_NI("TreeManager: loading default data directly"); - backend::NodeRequest aRequest(aSubtreePath,_xOptions->getRequestOptions()); + backend::NodeRequest aRequest(aSubtreePath,_aOptions); backend::NodeResult aDefaults = getCacheLoader()->getDirectDataProvider().getDefaultData( aRequest ); @@ -530,7 +530,7 @@ void TreeManager::saveAndNotifyUpdate(data::Accessor const& _aChangedDataAccesso backend::UpdateRequest anUpdate( & aChangeTree.root, aChangeTree.getRootNodePath(), - aChangeTree.getOptions()->getRequestOptions()); + aChangeTree.getOptions()); getCacheLoader()->saveAndNotify(anUpdate); CFG_TRACE_INFO_NI("TreeManager: committing done"); @@ -552,35 +552,9 @@ void TreeManager::updateTree(memory::UpdateAccessor& _aAccessToken, TreeChangeLi { CFG_TRACE_INFO("TreeManager: updating the cache from a changes list"); - // normalize the update tree. This means that we want a tree with one root which has either more than one child -#if 0 // try without the normalization - // or exactly one non-SubtreeChange-child - // This prevents us from giving unneccessary items to the session - AbsolutePath aRootPath = aChanges.getRootNodePath(); - SubtreeChange const * pRootChanges = &aChanges.root; - - - // do the normalizing - SubtreeChange::ChildIterator aChildren = pRootChanges->begin(); - while ((pRootChanges->size() == 1) && (aChildren->ISA(SubtreeChange))) - { - aRootPath = aRootPath.compose( ONameCreator::createName(*aChildren, pRootChanges) ); - pRootChanges = static_cast<const SubtreeChange*>(&*aChildren); - aChildren = pRootChanges->begin(); - } - - OChangeActionCounter aChangeCounter; - // now count if there are any changes - aChangeCounter.handle(*pRootChanges); - CFG_TRACE_INFO_NI("cache manager: counted changes for update : additions: %i , removes: %i, value changes: %i", aChangeCounter.nAdds, aChangeCounter.nRemoves, aChangeCounter.nValues); - - if (!aChangeCounter.hasChanges()) - return; -#endif - backend::UpdateInstance anUpdate(&_aChanges.root,_aChanges.getRootNodePath()); - CacheRef aCache = m_aCacheList.get(_aChanges.getOptions()->getRequestOptions()); + CacheRef aCache = m_aCacheList.get(_aChanges.getOptions()); if (!aCache.is()) { @@ -598,11 +572,11 @@ void TreeManager::updateTree(memory::UpdateAccessor& _aAccessToken, TreeChangeLi // ----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void TreeManager::releaseSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) CFG_NOTHROW() +void TreeManager::releaseSubtree( AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions ) CFG_NOTHROW() { - CFG_TRACE_INFO("TreeManager: releasing subtree '%s' for user '%s' with locale '%s'", OUSTRING2ASCII(aSubtreePath.toString()), OUSTRING2ASCII(_xOptions->getUser()), OUSTRING2ASCII(_xOptions->getLocale()) ); + CFG_TRACE_INFO("TreeManager: releasing subtree '%s' for entity '%s' with locale '%s'", OUSTRING2ASCII(aSubtreePath.toString()), OUSTRING2ASCII(_aOptions.getEntity()), OUSTRING2ASCII(_aOptions.getLocale()) ); - CacheRef aCache = m_aCacheList.get(_xOptions->getRequestOptions()); + CacheRef aCache = m_aCacheList.get(_aOptions); OSL_ENSURE(aCache.is(),"TreeManager: No local data to release"); @@ -611,7 +585,7 @@ void TreeManager::releaseSubtree( AbsolutePath const& aSubtreePath, const vos::O CFG_TRACE_INFO_NI("TreeManager: decrementing refcount for subtree '%s'", OUSTRING2ASCII(aSubtreePath.toString()) ); if (aCache->releaseNode(aSubtreePath) == 0) { - backend::ComponentRequest aComponentDesc(aSubtreePath.getModuleName(),_xOptions->getRequestOptions()); + backend::ComponentRequest aComponentDesc(aSubtreePath.getModuleName(),_aOptions); BackendCacheRef xBackendCache = maybeGetBackendCache(); if (xBackendCache.is()) xBackendCache->freeComponent(aComponentDesc); } @@ -619,26 +593,23 @@ void TreeManager::releaseSubtree( AbsolutePath const& aSubtreePath, const vos::O } //----------------------------------------------------------------------------- -void TreeManager::disposeData(const vos::ORef < OOptions >& _xOptions) CFG_NOTHROW() +void TreeManager::disposeData(const RequestOptions& _aOptions) CFG_NOTHROW() { CFG_TRACE_INFO("TreeManager: disposing data by options"); - OSL_ENSURE(!_xOptions.isEmpty(), "TreeManager: Cannot dispose: NULL options are not permitted"); - if (_xOptions.isEmpty()) return; - - if (_xOptions->getLocale().getLength() != 0) + if (_aOptions.getLocale().getLength() != 0) { - OSL_ENSURE(_xOptions->getUser().getLength() != 0, "TreeManager: Cannot dispose locale without user"); - CFG_TRACE_INFO_NI( "TreeManager: Disposing data for options: USER='%s' and LOCALE = '%s'", - OUSTRING2ASCII(_xOptions->getUser()), OUSTRING2ASCII(_xOptions->getLocale()) ); + OSL_ENSURE(_aOptions.getEntity().getLength() != 0, "TreeManager: Cannot dispose locale without user"); + CFG_TRACE_INFO_NI( "TreeManager: Disposing data for options: ENTITY='%s' and LOCALE = '%s'", + OUSTRING2ASCII(_aOptions.getEntity()), OUSTRING2ASCII(_aOptions.getLocale()) ); - this->disposeOne( _xOptions->getRequestOptions() ); + this->disposeOne( _aOptions ); } - else if (_xOptions->getUser().getLength() != 0) + else if (_aOptions.getEntity().getLength() != 0) { - CFG_TRACE_INFO_NI( "TreeManager: Disposing data for user: '%s'", OUSTRING2ASCII(_xOptions->getUser()) ); + CFG_TRACE_INFO_NI( "TreeManager: Disposing data for user: '%s'", OUSTRING2ASCII(_aOptions.getEntity()) ); - this->disposeUser(_xOptions->getRequestOptions() ); + this->disposeUser(_aOptions ); } else { @@ -654,7 +625,7 @@ void TreeManager::nodeUpdated(TreeChangeList& _rChanges) CFG_TRACE_INFO("TreeManager: nodeUpdated"); try { - CacheRef aCache = m_aCacheList.get(_rChanges.getOptions()->getRequestOptions()); + CacheRef aCache = m_aCacheList.get(_rChanges.getOptions()); if (aCache.is()) { @@ -698,8 +669,7 @@ void TreeManager::componentCreated(backend::ComponentRequest const & ) CFG_NOTHR void TreeManager::componentChanged(backend::UpdateRequest const & _anUpdate) CFG_NOTHROW() { - vos::ORef< OOptions > xOptions( new OOptions( _anUpdate.getOptions() ) ); - TreeChangeList aChanges(xOptions, + TreeChangeList aChanges(_anUpdate.getOptions(), _anUpdate.getUpdateRoot().location(), *_anUpdate.getUpdateData(), SubtreeChange::DeepChildCopy() ); diff --git a/configmgr/source/treemgr/configdefaultprovider.cxx b/configmgr/source/treemgr/configdefaultprovider.cxx index fcc8854816e0..bd454e4aa5a2 100644 --- a/configmgr/source/treemgr/configdefaultprovider.cxx +++ b/configmgr/source/treemgr/configdefaultprovider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configdefaultprovider.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:32:24 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,7 +97,7 @@ DefaultProvider DefaultProvider::createEmpty() } //----------------------------------------------------------------------------- -DefaultProvider DefaultProvider::create(Tree const& _aRootTree, vos::ORef<OOptions> const& _xOptions, +DefaultProvider DefaultProvider::create(Tree const& _aRootTree, RequestOptions const& _aOptions, rtl::Reference< IConfigDefaultProvider > const & _xDefaultProvider, IDefaultableTreeManager* _pDefaultableTree) { @@ -108,8 +108,7 @@ DefaultProvider DefaultProvider::create(Tree const& _aRootTree, vos::ORef<OOptio if (!_aRootTree.isEmpty()) { xNewProxy = new DefaultProviderProxy(_xDefaultProvider,_pDefaultableTree, - _aRootTree.getRootPath(), _xOptions, - _aRootTree.getRootNode().getDepth() ); + _aRootTree.getRootPath(), _aOptions ); } return DefaultProvider( xNewProxy ); diff --git a/configmgr/source/treemgr/configexcept.cxx b/configmgr/source/treemgr/configexcept.cxx index c35e40cd9521..83c347e46091 100644 --- a/configmgr/source/treemgr/configexcept.cxx +++ b/configmgr/source/treemgr/configexcept.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configexcept.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: lla $ $Date: 2001-03-07 14:58:38 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -261,9 +261,9 @@ namespace configmgr } //--------------------------------------------------------------------- - void ExceptionMapper::illegalArgument(sal_Int16 nArgument) throw(css::lang::IllegalArgumentException) + void ExceptionMapper::illegalArgument(sal_Int16 nArgument) throw(lang::IllegalArgumentException) { - throw css::lang::IllegalArgumentException(message(),context(),nArgument); + throw lang::IllegalArgumentException(message(),context(),nArgument); } //--------------------------------------------------------------------- diff --git a/configmgr/source/treemgr/configset.cxx b/configmgr/source/treemgr/configset.cxx index 9ff066387901..cd35220aec0c 100644 --- a/configmgr/source/treemgr/configset.cxx +++ b/configmgr/source/treemgr/configset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configset.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: jb $ $Date: 2002-08-13 13:33:45 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -473,9 +473,9 @@ TemplateProvider SetElementFactory::findTemplateProvider(Tree const& aTree, Node // class TreeSetUpdater and ValueSetUpdater //----------------------------------------------------------------------------- -static Attributes getNewElementAttributes(bool bInserting) +static node::Attributes getNewElementAttributes(bool bInserting) { - Attributes aResult; + node::Attributes aResult; aResult.setState( node::isReplaced ); return aResult; @@ -486,7 +486,7 @@ static Attributes getNewElementAttributes(bool bInserting) ElementTreeHolder ValueSetUpdater::makeValueElement(Name const& aName, UnoAny const& aValue) { - static const Attributes aNewValueAttributes = getNewElementAttributes(false); // TODO: get real value + static const node::Attributes aNewValueAttributes = getNewElementAttributes(false); // TODO: get real value UnoType aType = m_aTemplate->getInstanceType(); @@ -755,7 +755,7 @@ UnoAny ValueSetUpdater::implValidateValue(UnoAny const& aValue) UnoAny ValueSetUpdater::implValidateValue(ElementNodeRef const& aElementTree, UnoAny const& aValue) { - Attributes aAttributes = aElementTree.getAttributes(aElementTree.getRootNode()); + node::Attributes aAttributes = aElementTree.getAttributes(aElementTree.getRootNode()); // Here we assume writable == removable/replaceable if (!aAttributes.bWritable) throw ConstraintViolation( "Set Update: Existing element is read-only !" ); diff --git a/configmgr/source/treemgr/defaultproviderproxy.cxx b/configmgr/source/treemgr/defaultproviderproxy.cxx index 4fe1f4a3cc51..943734db3725 100644 --- a/configmgr/source/treemgr/defaultproviderproxy.cxx +++ b/configmgr/source/treemgr/defaultproviderproxy.cxx @@ -2,9 +2,9 @@ * * $RCSfile: defaultproviderproxy.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:32:24 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,12 +88,10 @@ DefaultProviderProxy::DefaultProviderProxy( rtl::Reference< IConfigDefaultProvider > const & _xDefaultTreeProvider, IDefaultableTreeManager * _pDefaultTreeManager, AbsolutePath const& _aBaseLocation, - vos::ORef<OOptions> const& _xOptions, - sal_Int16 _nRequestDepth + RequestOptions const& _aOptions ) : m_aBaseLocation(_aBaseLocation) -, m_xOptions(_xOptions) -, m_nRequestDepth(_nRequestDepth) +, m_aOptions(_aOptions) , m_xDefaultTreeProvider(_xDefaultTreeProvider) , m_pDefaultTreeManager(_pDefaultTreeManager) { @@ -117,7 +115,7 @@ std::auto_ptr<ISubtree> DefaultProviderProxy::getDefaultTree( std::auto_ptr<ISubtree> aRet; if (m_xDefaultTreeProvider.is()) - aRet = m_xDefaultTreeProvider->requestDefaultData(_aLocation, m_xOptions, ITreeProvider::ALL_LEVELS); + aRet = m_xDefaultTreeProvider->requestDefaultData(_aLocation, m_aOptions); return aRet; } @@ -129,9 +127,9 @@ bool DefaultProviderProxy::fetchDefaultData() CFG_UNO_THROW_ALL() OSL_PRECOND(m_pDefaultTreeManager, "No tree to fetch defaults into"); if (!m_pDefaultTreeManager) return false; - memory::UpdateAccessor anAccessToken(m_pDefaultTreeManager->getDataSegment(m_aBaseLocation,m_xOptions)); + memory::UpdateAccessor anAccessToken(m_pDefaultTreeManager->getDataSegment(m_aBaseLocation,m_aOptions)); - return !! m_pDefaultTreeManager->fetchDefaultData(anAccessToken,m_aBaseLocation,m_xOptions, m_nRequestDepth); + return !! m_pDefaultTreeManager->fetchDefaultData(anAccessToken,m_aBaseLocation,m_aOptions); } //----------------------------------------------------------------------------- } diff --git a/configmgr/source/treemgr/defaultproviderproxy.hxx b/configmgr/source/treemgr/defaultproviderproxy.hxx index d8261a314ead..82b4e21f9e06 100644 --- a/configmgr/source/treemgr/defaultproviderproxy.hxx +++ b/configmgr/source/treemgr/defaultproviderproxy.hxx @@ -2,9 +2,9 @@ * * $RCSfile: defaultproviderproxy.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:32:24 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,14 +68,14 @@ #ifndef CONFIGMGR_UTILITY_HXX_ #include "utility.hxx" #endif +#ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_ +#include "requestoptions.hxx" +#endif #ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_ #include <salhelper/simplereferenceobject.hxx> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif #ifndef _RTL_REF_HXX_ #include <rtl/ref.hxx> #endif @@ -108,8 +108,7 @@ namespace configmgr { // the data defining a request AbsolutePath m_aBaseLocation; - vos::ORef< OOptions > m_xOptions; - sal_Int16 m_nRequestDepth; + RequestOptions m_aOptions; // the object(s) that provide the defaults rtl::Reference< IConfigDefaultProvider > m_xDefaultTreeProvider; @@ -120,8 +119,7 @@ namespace configmgr rtl::Reference< IConfigDefaultProvider > const & _xDefaultTreeProvider, IDefaultableTreeManager * _pDefaultTreeManager, AbsolutePath const& _aBaseLocation, - vos::ORef<OOptions> const& _xOptions, - sal_Int16 _nRequestDepth + RequestOptions const& _aOptions ); ~DefaultProviderProxy(); diff --git a/configmgr/source/treemgr/makefile.mk b/configmgr/source/treemgr/makefile.mk index 1a3fbbc32e24..a5bf1cccfc4e 100644 --- a/configmgr/source/treemgr/makefile.mk +++ b/configmgr/source/treemgr/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:19:46 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -94,7 +94,6 @@ SLOFILES= \ $(SLO)$/template.obj \ $(SLO)$/templateimpl.obj \ $(SLO)$/treeimpl.obj \ - $(SLO)$/treeiterators.obj \ $(SLO)$/viewaccess.obj \ $(SLO)$/viewstrategy.obj \ $(SLO)$/viewnode.obj \ diff --git a/configmgr/source/treemgr/nodechangeimpl.hxx b/configmgr/source/treemgr/nodechangeimpl.hxx index 5ca7012a6115..1596070fda67 100644 --- a/configmgr/source/treemgr/nodechangeimpl.hxx +++ b/configmgr/source/treemgr/nodechangeimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechangeimpl.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGCHANGEIMPL_HXX_ #define CONFIGMGR_CONFIGCHANGEIMPL_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGEXCEPT_HXX_ #include "configexcept.hxx" #endif diff --git a/configmgr/source/treemgr/nodeimpl.cxx b/configmgr/source/treemgr/nodeimpl.cxx index c77aaa3226b1..4e86b223f67d 100644 --- a/configmgr/source/treemgr/nodeimpl.cxx +++ b/configmgr/source/treemgr/nodeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: nodeimpl.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: jb $ $Date: 2002-03-28 08:14:40 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,10 +97,6 @@ #include "change.hxx" #endif -#ifndef CONFIGMGR_CMTREEMODEL_HXX -#include "cmtreemodel.hxx" -#endif - #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> #endif diff --git a/configmgr/source/treemgr/nodeimpl.hxx b/configmgr/source/treemgr/nodeimpl.hxx index e132f93539d5..cd45481784fa 100644 --- a/configmgr/source/treemgr/nodeimpl.hxx +++ b/configmgr/source/treemgr/nodeimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: nodeimpl.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2002-02-15 14:34:34 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGNODEBEHAVIOR_HXX_ #define CONFIGMGR_CONFIGNODEBEHAVIOR_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_ #include "attributes.hxx" #endif diff --git a/configmgr/source/treemgr/noderef.cxx b/configmgr/source/treemgr/noderef.cxx index 62077e0f2301..0175478a7016 100644 --- a/configmgr/source/treemgr/noderef.cxx +++ b/configmgr/source/treemgr/noderef.cxx @@ -2,9 +2,9 @@ * * $RCSfile: noderef.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -329,7 +329,7 @@ namespace { Tree aTree( anEntry.accessor(), pTree ); - Attributes aElementAttributes = aTree.getAttributes(aTree.getRootNode()); + node::Attributes aElementAttributes = aTree.getAttributes(aTree.getRootNode()); // a set element is considered default iff it is not replaced/added bool bDefault = !aElementAttributes.isReplacedForUser(); @@ -505,13 +505,13 @@ ElementRef Tree::getAvailableElement(NodeRef const& aNode, Name const& aName) co } //----------------------------------------------------------------------------- -Attributes Tree::getAttributes(NodeRef const& aNode) const +node::Attributes Tree::getAttributes(NodeRef const& aNode) const { OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" ); OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: NodeRef operation requires valid node" ); OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: NodeRef does not match tree" ); - if (!aNode.isValid()) return Attributes(); + if (!aNode.isValid()) return NodeAttributes(); return this->getView().getAttributes(aNode); } @@ -583,13 +583,13 @@ ValueRef::~ValueRef() //----------------------------------------------------------------------------- -Attributes Tree::getAttributes(ValueRef const& aValue) const +node::Attributes Tree::getAttributes(ValueRef const& aValue) const { OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" ); OSL_PRECOND( aValue.isValid(), "ERROR: Configuration: ValueRef operation requires valid reference" ); OSL_PRECOND( isValidNode(aValue), "ERROR: Configuration: ValueRef does not match tree" ); - if (!aValue.isValid()) return Attributes(); + if (!aValue.isValid()) return NodeAttributes(); return TreeImplHelper::member_node(*this,aValue).getAttributes(); } @@ -727,13 +727,13 @@ ValueRef AnyNodeRef::toValue() const } //----------------------------------------------------------------------------- -Attributes Tree::getAttributes(AnyNodeRef const& aNode) const +node::Attributes Tree::getAttributes(AnyNodeRef const& aNode) const { OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" ); OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: NodeRef operation requires valid node" ); OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: NodeRef does not match tree" ); - if (!aNode.isValid()) return Attributes(); + if (!aNode.isValid()) return NodeAttributes(); if (aNode.isNode()) return this->getView().getAttributes(aNode.toNode()); diff --git a/configmgr/source/treemgr/roottree.cxx b/configmgr/source/treemgr/roottree.cxx index ffe2f5093afd..4ab0e0be6b7b 100644 --- a/configmgr/source/treemgr/roottree.cxx +++ b/configmgr/source/treemgr/roottree.cxx @@ -2,9 +2,9 @@ * * $RCSfile: roottree.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,8 +81,9 @@ #ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_ #include "nodechangeinfo.hxx" #endif -#ifndef CONFIGMGR_CMTREEMODEL_HXX -#include "cmtreemodel.hxx" + +#ifndef CONFIGMGR_TREECHANGELIST_HXX +#include "treechangelist.hxx" #endif namespace configmgr diff --git a/configmgr/source/treemgr/setnodeimpl.cxx b/configmgr/source/treemgr/setnodeimpl.cxx index 8413b1f22af6..9169d7f6ec80 100644 --- a/configmgr/source/treemgr/setnodeimpl.cxx +++ b/configmgr/source/treemgr/setnodeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: setnodeimpl.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -174,7 +174,7 @@ namespace return collection.back(); } - typedef vector<Element> Collection; + typedef std::vector<Element> Collection; Collection collection; private: Result handle(TreeAccessor const& _aElement); diff --git a/configmgr/source/treemgr/template.cxx b/configmgr/source/treemgr/template.cxx index 4fb7b69f1a89..749ca37f943a 100644 --- a/configmgr/source/treemgr/template.cxx +++ b/configmgr/source/treemgr/template.cxx @@ -2,9 +2,9 @@ * * $RCSfile: template.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:32:24 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,9 @@ #ifndef CONFIGMGR_SETNODEACCESS_HXX #include "setnodeaccess.hxx" #endif +#ifndef CONFIGMGR_API_APITYPES_HXX_ +#include "apitypes.hxx" +#endif namespace configmgr { @@ -81,8 +84,8 @@ TemplateProvider::TemplateProvider() } //----------------------------------------------------------------------------- -TemplateProvider::TemplateProvider(TemplateManagerRef const & xProvider, vos::ORef< OOptions > const& xOptions) -: m_aImpl( new TemplateProvider_Impl(xProvider,xOptions) ) +TemplateProvider::TemplateProvider(TemplateManagerRef const & xProvider, RequestOptions const& aOptions) +: m_aImpl( new TemplateProvider_Impl(xProvider,aOptions) ) { } diff --git a/configmgr/source/treemgr/templateimpl.cxx b/configmgr/source/treemgr/templateimpl.cxx index 0bfed7da9290..5907124d8ce9 100644 --- a/configmgr/source/treemgr/templateimpl.cxx +++ b/configmgr/source/treemgr/templateimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: templateimpl.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:32:25 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -94,6 +94,9 @@ #ifndef _CONFIGMGR_TREEACTIONS_HXX_ #include "treeactions.hxx" #endif +#ifndef CONFIGMGR_API_APITYPES_HXX_ +#include "apitypes.hxx" +#endif #ifndef INCLUDED_MAP #include <map> @@ -234,9 +237,9 @@ TemplateHolder SpecialTemplateProvider_Impl::makeTemplate (TemplateName const& a // class TemplateProvider_Impl //----------------------------------------------------------------------------- -TemplateProvider_Impl::TemplateProvider_Impl(TemplateManagerRef const & xProvider, vos::ORef< OOptions > const& xOptions) +TemplateProvider_Impl::TemplateProvider_Impl(TemplateManagerRef const & xProvider, RequestOptions const& aOptions) : m_xProvider(xProvider) -, m_xOptions(xOptions) +, m_aOptions(aOptions) , m_aRepository() { } @@ -249,11 +252,7 @@ data::TreeSegment TemplateProvider_Impl::instantiate(data::Accessor const& _aSou { data::TreeAccessor aTemplateData = m_xProvider->requestTemplate(_aSourceAccessor, aTemplate->getName(), aTemplate->getModule()); - // #86095# we sometimes wrongly are passed NULL options - using default instead - OSL_ENSURE( m_xOptions.isValid(), "ERROR: Requesting template instance without options" ); - - bool bForceWritable = m_xOptions->isForcingWritable(); - pRet = cloneExpandedForLocale(aTemplateData, m_xOptions->getLocale(), bForceWritable); + pRet = cloneExpandedForLocale(aTemplateData, m_aOptions.getLocale()); } return pRet; } diff --git a/configmgr/source/treemgr/templateimpl.hxx b/configmgr/source/treemgr/templateimpl.hxx index d56fcbd85d7a..32f9f12626a1 100644 --- a/configmgr/source/treemgr/templateimpl.hxx +++ b/configmgr/source/treemgr/templateimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: templateimpl.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2002-10-10 09:32:25 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,17 +62,14 @@ #ifndef CONFIGMGR_TEMPLATEIMPL_HXX_ #define CONFIGMGR_TEMPLATEIMPL_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CONFIGTEMPLATE_HXX_ #include "template.hxx" #endif #ifndef CONFIGMGR_CONFIGPATH_HXX_ #include "configpath.hxx" #endif -#ifndef CONFIGMGR_MISC_OPTIONS_HXX_ -#include "options.hxx" +#ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_ +#include "requestoptions.hxx" #endif #ifndef _RTL_USTRBUF_HXX_ @@ -85,10 +82,6 @@ #include <salhelper/simplereferenceobject.hxx> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif - #ifndef INCLUDED_MAP #include <map> #define INCLUDED_MAP @@ -244,14 +237,14 @@ namespace configmgr { typedef TemplateProvider::TemplateManagerRef TemplateManagerRef; - TemplateProvider_Impl(TemplateManagerRef const & xProvider, vos::ORef< OOptions > const& xOptions); + TemplateProvider_Impl(TemplateManagerRef const & xProvider, RequestOptions const& aOptions); data::TreeSegment instantiate(memory::Accessor const& _aSourceAccessor, TemplateHolder const& aTemplate); TemplateHolder makeElementTemplateWithType(TemplateName const& _aNames, data::SetNodeAccess const& _aSet); private: TemplateManagerRef m_xProvider; - vos::ORef< OOptions > m_xOptions; + RequestOptions m_aOptions; TemplateRepository m_aRepository; }; diff --git a/configmgr/source/treemgr/treeimpl.hxx b/configmgr/source/treemgr/treeimpl.hxx index e3bf89470ae7..a2da5df579dc 100644 --- a/configmgr/source/treemgr/treeimpl.hxx +++ b/configmgr/source/treemgr/treeimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treeimpl.hxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: jb $ $Date: 2002-02-15 14:34:35 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,9 +62,6 @@ #ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_ #define CONFIGMGR_CONFIGNODEIMPL_HXX_ -#ifndef CONFIGMGR_API_APITYPES_HXX_ -#include "apitypes.hxx" -#endif #ifndef CONFIGMGR_CHANGE_HXX #include "change.hxx" #endif @@ -77,9 +74,6 @@ #ifndef CONFIGMGR_CONFIGTEMPLATE_HXX_ #include "template.hxx" #endif -#ifndef CONFIGMGR_RWLOCK_HXX_ -#include "rwlock.hxx" -#endif #ifndef CONFIGMGR_TREEACCESSOR_HXX #include "treeaccessor.hxx" #endif @@ -117,16 +111,13 @@ namespace configmgr class SubtreeChange; namespace view { class ViewStrategy; class ViewTreeAccess; } - + namespace node { struct Attributes; } namespace configuration { //----------------------------------------------------------------------------- typedef com::sun::star::uno::Any UnoAny; //----------------------------------------------------------------------------- - struct Attributes; - -//----------------------------------------------------------------------------- class TreeImpl; class TemplateProvider; //----------------------------------------------------------------------------- diff --git a/configmgr/source/treemgr/valuemembernode.cxx b/configmgr/source/treemgr/valuemembernode.cxx index a19bf3159d50..4e77299f275f 100644 --- a/configmgr/source/treemgr/valuemembernode.cxx +++ b/configmgr/source/treemgr/valuemembernode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: valuemembernode.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -191,7 +191,7 @@ Name ValueMemberNode::getNodeName() const } //----------------------------------------------------------------------------- -Attributes ValueMemberNode::getAttributes() const +node::Attributes ValueMemberNode::getAttributes() const { return m_aNodeRef.getAttributes(); } diff --git a/configmgr/source/treemgr/valuemembernode.hxx b/configmgr/source/treemgr/valuemembernode.hxx index 53ac6d02280a..4ef876ed8fad 100644 --- a/configmgr/source/treemgr/valuemembernode.hxx +++ b/configmgr/source/treemgr/valuemembernode.hxx @@ -2,9 +2,9 @@ * * $RCSfile: valuemembernode.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-02-11 13:47:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:19:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,7 +109,7 @@ namespace configmgr /// retrieve the name of the underlying node Name getNodeName() const; /// retrieve the attributes - Attributes getAttributes() const; + node::Attributes getAttributes() const; /// Does this node assume its default value bool isDefault() const; diff --git a/configmgr/source/xml/layerwriter.cxx b/configmgr/source/xml/layerwriter.cxx index cdec72b07272..225aa4c81806 100644 --- a/configmgr/source/xml/layerwriter.cxx +++ b/configmgr/source/xml/layerwriter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: layerwriter.cxx,v $ * -* $Revision: 1.7 $ +* $Revision: 1.8 $ * -* last change: $Author: ssmith $ $Date: 2002-11-08 14:43:44 $ +* last change: $Author: hr $ $Date: 2003-03-19 16:19:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,9 +81,9 @@ namespace configmgr // ----------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL instantiateLayerWriter - ( CreationContext const& rServiceManager ) + ( CreationContext const& xContext ) { - return * new LayerWriter(rServiceManager); + return * new LayerWriter(xContext); } // ----------------------------------------------------------------------------- @@ -110,9 +110,9 @@ namespace configmgr } // ----------------------------------------------------------------------------- - LayerWriter::LayerWriter(ServiceFactory const & _xSvcFactory) - : LayerWriterService_Base(_xSvcFactory) - , m_xTCV( createTCV(_xSvcFactory) ) + LayerWriter::LayerWriter(CreationArg _xContext) + : LayerWriterService_Base(_xContext) + , m_xTCV( createTCV( LayerWriterService_Base::getServiceFactory() ) ) , m_bInProperty(false) , m_bStartedDocument(false) { diff --git a/configmgr/source/xml/layerwriter.hxx b/configmgr/source/xml/layerwriter.hxx index e1f1a3cb3e30..c03e3b73afbe 100644 --- a/configmgr/source/xml/layerwriter.hxx +++ b/configmgr/source/xml/layerwriter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: layerwriter.hxx,v $ * -* $Revision: 1.7 $ +* $Revision: 1.8 $ * -* last change: $Author: ssmith $ $Date: 2002-11-08 14:43:45 $ +* last change: $Author: hr $ $Date: 2003-03-19 16:19:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,7 +97,7 @@ namespace configmgr { public: explicit - LayerWriter(ServiceFactory const & _xSvcFactory); + LayerWriter(CreationArg _xContext); virtual ~LayerWriter(); // XLayerHandler diff --git a/configmgr/source/xml/makefile.mk b/configmgr/source/xml/makefile.mk index 5738643d97e4..0a1d7f0eee02 100644 --- a/configmgr/source/xml/makefile.mk +++ b/configmgr/source/xml/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.19 $ +# $Revision: 1.20 $ # -# last change: $Author: mh $ $Date: 2002-10-02 11:34:58 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:20:01 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -75,30 +75,10 @@ ENABLE_EXCEPTIONS=TRUE SLOFILES=\ - $(SLO)$/lookupcontext.obj \ - $(SLO)$/attributeparser.obj \ - $(SLO)$/valuenodebuilder.obj \ - $(SLO)$/localizednodebuilder.obj \ - $(SLO)$/valueconverter.obj \ $(SLO)$/matchlocale.obj \ - $(SLO)$/treebuildercallback.obj \ - $(SLO)$/notifycallback.obj \ - $(SLO)$/valuehandler.obj \ $(SLO)$/typeconverter.obj \ - $(SLO)$/xmltreebuilder.obj \ - $(SLO)$/xmlformater.obj \ - $(SLO)$/localsession.obj \ - $(SLO)$/saxadapter.obj \ - $(SLO)$/updatehandler.obj \ - $(SLO)$/namehelper.obj \ - $(SLO)$/binarywritehandler.obj \ - $(SLO)$/writesubtreeasbinaryhandler.obj \ - $(SLO)$/binarywriter.obj \ - $(SLO)$/binaryreader.obj \ $(SLO)$/simpletypehelper.obj \ - $(SLO)$/binarydecide.obj \ - $(SLO)$/binarybasereader.obj \ - $(SLO)$/generatecache.obj \ + $(SLO)$/valueconverter.obj \ $(SLO)$/elementparser.obj \ $(SLO)$/elementformatter.obj \ $(SLO)$/basicparser.obj \ @@ -110,12 +90,6 @@ SLOFILES=\ $(SLO)$/valueformatter.obj \ $(SLO)$/xmlstrings.obj \ - -.IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCPOWERPC" -NOOPTFILES= $(SLO)$/localsession.obj -.ENDIF - - # --- Targets --- .INCLUDE : target.mk diff --git a/configmgr/source/xml/parsersvc.cxx b/configmgr/source/xml/parsersvc.cxx index caffa6b2c38b..42aa2e216b2e 100644 --- a/configmgr/source/xml/parsersvc.cxx +++ b/configmgr/source/xml/parsersvc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: parsersvc.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-12-06 13:08:35 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,13 +104,13 @@ static inline void clear(OUString & _rs) { _rs = OUString(); } // ----------------------------------------------------------------------------- template <class BackendInterface> -ParserService<BackendInterface>::ParserService(CreationArg _xServiceFactory) -: m_xServiceFactory(_xServiceFactory) +ParserService<BackendInterface>::ParserService(CreationArg _xContext) +: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY) , m_aInputSource() { if (!m_xServiceFactory.is()) { - OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration Parser: Unexpected NULL context")); + OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration Parser: Context has no service factory")); throw uno::RuntimeException(sMessage,NULL); } } @@ -304,8 +304,8 @@ class SchemaParserService : public SchemaParserService_Base public: typedef SchemaParser::HandlerRef HandlerArg; - SchemaParserService(CreationArg _xServiceFactory) - : SchemaParserService_Base(_xServiceFactory) + SchemaParserService(CreationArg _xContext) + : SchemaParserService_Base(_xContext) { } @@ -327,8 +327,8 @@ class LayerParserService : public LayerParserService_Base public: typedef LayerParser::HandlerRef HandlerArg; - LayerParserService(CreationArg _xServiceFactory) - : LayerParserService_Base(_xServiceFactory) + LayerParserService(CreationArg _xContext) + : LayerParserService_Base(_xContext) { } @@ -338,13 +338,13 @@ public: // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- -uno::Reference< uno::XInterface > SAL_CALL instantiateSchemaParser( CreationContext const& rServiceManager ) +uno::Reference< uno::XInterface > SAL_CALL instantiateSchemaParser( CreationContext const& xContext ) { - return * new SchemaParserService(rServiceManager); + return * new SchemaParserService(xContext); } -uno::Reference< uno::XInterface > SAL_CALL instantiateLayerParser( CreationContext const& rServiceManager ) +uno::Reference< uno::XInterface > SAL_CALL instantiateLayerParser( CreationContext const& xContext ) { - return * new LayerParserService(rServiceManager); + return * new LayerParserService(xContext); } // ----------------------------------------------------------------------------- const ServiceRegistrationInfo* getSchemaParserServiceInfo() diff --git a/configmgr/source/xml/parsersvc.hxx b/configmgr/source/xml/parsersvc.hxx index 28a898fa10a3..f6934469ceac 100644 --- a/configmgr/source/xml/parsersvc.hxx +++ b/configmgr/source/xml/parsersvc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: parsersvc.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-05-22 09:21:01 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,9 @@ #include <cppuhelper/implbase4.hxx> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -108,10 +111,10 @@ namespace configmgr > { public: - typedef uno::Reference< lang::XMultiServiceFactory > const & CreationArg; + typedef uno::Reference< uno::XComponentContext > const & CreationArg; explicit - ParserService(CreationArg _xServiceFactory); + ParserService(CreationArg _xContext); // XInitialization virtual void SAL_CALL diff --git a/configmgr/source/xml/typeconverter.cxx b/configmgr/source/xml/typeconverter.cxx index d8e11f214ea1..60ebc697b63f 100644 --- a/configmgr/source/xml/typeconverter.cxx +++ b/configmgr/source/xml/typeconverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: typeconverter.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: jb $ $Date: 2002-05-10 08:48:59 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -228,7 +228,6 @@ namespace configmgr case uno::TypeClass_STRING: aRet = TYPE_STRING; break; case uno::TypeClass_SEQUENCE: aRet = TYPE_BINARY; break; case uno::TypeClass_ANY: aRet = TYPE_ANY; break; - case uno::TypeClass_BYTE: aRet = TYPE_BYTE; break; default: { ::rtl::OString aStr("Wrong typeclass! "); diff --git a/configmgr/source/xml/valueconverter.cxx b/configmgr/source/xml/valueconverter.cxx index 9f72489f735d..19d207039a35 100644 --- a/configmgr/source/xml/valueconverter.cxx +++ b/configmgr/source/xml/valueconverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: valueconverter.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: jb $ $Date: 2002-05-28 15:59:44 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,11 +60,7 @@ ************************************************************************/ #include "valuetypeconverter.hxx" -#include "valueconverter.hxx" -#ifndef _CONFIGMGR_STRDECL_HXX_ -#include "strdecl.hxx" -#endif #ifndef CONFIGMGR_TYPECONVERTER_HXX #include "typeconverter.hxx" #endif @@ -74,13 +70,13 @@ inline sal_Bool rtl_ascii_isWhitespace( sal_Unicode ch ) return ch <= 0x20 && ch; } -// #define ASCII(x) OUString::createFromAscii(x) namespace configmgr { using rtl::OUString; using namespace com::sun::star::uno; using namespace std; - +// ----------------------------------------------------------------------------- + typedef ValueConverter::StringList StringList; // ----------------------------------------------------------------------------- static void throwConversionError(sal_Char const* pErrorMsg) CFG_THROW1( script::CannotConvertException ) @@ -161,250 +157,6 @@ void parseHexBinary(OUString const& aHexString_, uno::Sequence<sal_Int8>& rBinar } // ----------------------------------------------------------------------------- - -namespace Encoding { - enum Type { unknown, hex, base64, DEFAULT = hex }; - - static - inline - Type parse(OUString const& sEncoding) - { - Type eEncoding; - - if (sEncoding.getLength() == 0) - { - eEncoding = Encoding::DEFAULT; - } - - else if (sEncoding.equalsIgnoreAsciiCase(ENCODING_HEX)) - { - eEncoding = Encoding::hex; - } - - else if (sEncoding.equalsIgnoreAsciiCase(ENCODING_BASE64)) - { - eEncoding = Encoding::base64; - } - - else - { - eEncoding = Encoding::unknown; - } - - return eEncoding; - } -} - -// ----------------------------------------------------------------------------- -uno::Sequence<sal_Int8> OValueConverter::parseBinary(OUString const& aBinaryString_) const - CFG_UNO_THROW1 ( script::CannotConvertException) -{ - uno::Sequence<sal_Int8> aResultSeq; - - switch (Encoding::parse(m_aValueDesc.sEncoding)) - { - case Encoding::hex: - parseHexBinary(aBinaryString_,aResultSeq); - break; - - case Encoding::base64: - OSL_ENSURE(false, "Base64 encoding for binary value is currently not supported"); - break; - - case Encoding::unknown: - OSL_ENSURE(false, "Unknown encoding found for binary value"); - break; - - default: - OSL_ASSERT(false);// Unreachable code - break; - } - - return aResultSeq; -} - -// ----------------------------------------------------------------------------- - -uno::Type OValueConverter::getType() const -{ - if (m_aValueDesc.sType.getLength() == 0) - return getVoidCppuType(); - - return toType(m_aValueDesc.sType, m_aValueDesc.isList); -} -// ----------------------------------------------------------------------------- -bool OValueConverter::convertToAny(OUString const& aContent, uno::Any& rValue) const - CFG_UNO_THROW1( script::CannotConvertException) -{ - // PRE: filled content and ValueInfo and an existing Any Object - // POST: Any contain the Data from the content - - if (m_aValueDesc.isNull) - { - OSL_ENSURE(aContent.trim().getLength() == 0, "OValueConverter: Non-empty Null Value - ignoring content"); - rValue.clear(); - return false; - } - - else if (m_aValueDesc.isList) - { - StringList aContentList; - splitListData(aContent, aContentList); - return convertListToAny(aContentList, rValue); - } - - else - { - return convertScalarToAny(aContent, rValue); - } -} - -// ----------------------------------------------------------------------------- -bool OValueConverter::convertScalarToAny(OUString const& aContent, uno::Any& rValue) const - CFG_UNO_THROW1 ( script::CannotConvertException ) -{ - OSL_PRECOND(!m_aValueDesc.isNull,"OValueConverter::convertScalarToAny - check for NULL before calling"); - OSL_ENSURE(!m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_ANY),"'Any' values must be NULL"); - - // check for Binary - if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_BINARY)) - { - Sequence<sal_Int8> aBinarySeq = parseBinary(aContent); - rValue <<= aBinarySeq; - } - - else - { - rValue = toAny(m_xTypeConverter, aContent, toTypeClass(m_aValueDesc.sType)); - } - - if (!rValue.hasValue()) - { - OSL_ENSURE(aContent.getLength() == 0, "ValueConverter: Converted non-empty data as NULL ?!"); - OSL_TRACE("Warning: ValueConverter: Empty data without 'null' attribute treated as NULL !"); - - // m_aValueDesc.isNull = true; // violates const - } - - return !! rValue.hasValue(); -} - -// ----------------------------------------------------------------------------- -template <class T> -bool convertListToSequence(StringList const& aStringList, uno::Sequence< T >& rSequence, OValueConverter const& rConverter) - CFG_UNO_THROW1 ( script::CannotConvertException ) -{ - uno::TypeClass const aElementTypeClass = ::getCppuType(static_cast<T const*>(0)).getTypeClass(); - - rSequence.realloc(aStringList.size()); - - sal_uInt32 nPos = 0; - - for(StringList::const_iterator it = aStringList.begin(); - it != aStringList.end(); - ++it) - { - uno::Any aValueAny = toAny(rConverter.getTypeConverter(), *it, aElementTypeClass); - - if (aValueAny >>= rSequence[nPos]) - ++nPos; - - else if (!aValueAny.hasValue()) - OSL_ENSURE(false,"UNEXPECTED: Found NULL value in List - ignoring value !"); - - else - OSL_ENSURE(false,"ERROR: Cannot extract converted value into List - skipping value !"); - } - - bool bOK = (nPos == aStringList.size()); - - if (!bOK) - { - OSL_ASSERT(nPos < aStringList.size()); - rSequence.realloc(nPos); - } - return bOK; -} - -// ----------------------------------------------------------------------------- -// special overload for binary sequence - -// template<> // use an explicit specialization -bool convertListToSequence(StringList const& aStringList, uno::Sequence< uno::Sequence<sal_Int8> >& rSequence, OValueConverter const& rParser ) - CFG_UNO_THROW1 ( script::CannotConvertException ) -{ - rSequence.realloc(aStringList.size()); - - sal_uInt32 nPos = 0; - - for(StringList::const_iterator it = aStringList.begin(); - it != aStringList.end(); - ++it) - { - rSequence[nPos++] = rParser.parseBinary(*it); - } - return true; -} - -// ----------------------------------------------------------------------------- - -bool OValueConverter::convertListToAny(StringList const& aContentList, uno::Any& rValue) const - CFG_UNO_THROW1 ( script::CannotConvertException ) -{ - OSL_PRECOND(!m_aValueDesc.isNull,"OValueConverter::convertListToAny - check for NULL before calling"); - OSL_ENSURE(!m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_ANY),"'Any' not allowed for lists"); - - if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_STRING)) - { - Sequence< OUString > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_BOOLEAN)) - { - Sequence< sal_Bool > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_SHORT)) - { - Sequence< sal_Int16 > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_INT)) - { - Sequence< sal_Int32 > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_LONG)) - { - Sequence< sal_Int64 > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_DOUBLE)) - { - Sequence< double > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else if (m_aValueDesc.sType.equalsIgnoreAsciiCase(TYPE_BINARY)) - { - Sequence< Sequence<sal_Int8> > aSequence; - convertListToSequence(aContentList,aSequence,*this); - rValue <<= aSequence; - } - else - { - OSL_ENSURE(false, "Unknown element type in list"); - throwConversionError("Invalid value-type found in list value"); - } - return !! rValue.hasValue(); -} - -// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- uno::Sequence<sal_Int8> ValueConverter::parseBinary(OUString const& aBinaryString_) const CFG_UNO_THROW1 ( script::CannotConvertException) @@ -462,7 +214,7 @@ uno::Any ValueConverter::convertToAny(OUString const& aContent) const bool ValueConverter::convertScalarToAny(OUString const& aContent, uno::Any& rValue) const CFG_UNO_THROW1 ( script::CannotConvertException ) { - OSL_PRECOND(!this->isNull(),"OValueConverter::convertScalarToAny - check for NULL before calling"); + OSL_PRECOND(!this->isNull(),"ValueConverter::convertScalarToAny - check for NULL before calling"); OSL_ENSURE(m_aType.getTypeClass() != uno::TypeClass_ANY,"'Any' values must be NULL"); // check for Binary @@ -610,7 +362,7 @@ bool convertListToSequence(StringList const& aStringList, uno::Sequence< OUStrin bool ValueConverter::convertListToAny(StringList const& aContentList, uno::Any& rValue) const CFG_UNO_THROW1 ( script::CannotConvertException ) { - OSL_PRECOND(!this->isNull(),"OValueConverter::convertListToAny - check for NULL before calling"); + OSL_PRECOND(!this->isNull(),"ValueConverter::convertListToAny - check for NULL before calling"); OSL_ENSURE(m_aType.getTypeClass() == uno::TypeClass_SEQUENCE,"'Any' not allowed for lists"); uno::Type aElementType = getSequenceElementType(m_aType); @@ -759,45 +511,21 @@ namespace // ----------------------------------------------------------------------------- } // ----------------------------------------------------------------------------- -void OValueConverter::splitListData(OUString const& aContent, StringList& rContentList) const - CFG_NOTHROW( ) -{ - OUString sSeparator = m_aValueDesc.sSeparator; - - bool bSeparateByWhitespace = (sSeparator.trim().getLength() == 0); - - OSL_ENSURE( bSeparateByWhitespace == (!sSeparator.getLength() || sSeparator.equals(DEFAULT_SEPARATOR)), - "Unexpected whitespace-only separator"); - - if (bSeparateByWhitespace) - { - OSL_ENSURE( sSeparator.getLength()==0 || sSeparator.equals(DEFAULT_SEPARATOR), - "Unexpected whitespace-only separator"); - - tokenizeListData( OTokenizeByWhitespace(), aContent, rContentList ); - } - else - { - OSL_ENSURE( sSeparator.trim()==sSeparator, - "Unexpected whitespace in separator"); - - tokenizeListData( OTokenizeBySeparator(sSeparator), aContent, rContentList ); - } -} -// ----------------------------------------------------------------------------- void ValueConverter::splitListData(OUString const& aContent, StringList& rContentList) const CFG_NOTHROW( ) { + static const char SEPARATOR_WHITESPACE[] = " "; + OUString sSeparator = m_sSeparator; bool bSeparateByWhitespace = (sSeparator.trim().getLength() == 0); - OSL_ENSURE( bSeparateByWhitespace == (!sSeparator.getLength() || sSeparator.equals(DEFAULT_SEPARATOR)), + OSL_ENSURE( bSeparateByWhitespace == (!sSeparator.getLength() || sSeparator.equalsAscii(SEPARATOR_WHITESPACE)), "Unexpected whitespace-only separator"); if (bSeparateByWhitespace) { - OSL_ENSURE( sSeparator.getLength()==0 || sSeparator.equals(DEFAULT_SEPARATOR), + OSL_ENSURE( sSeparator.getLength()==0 || sSeparator.equalsAscii(SEPARATOR_WHITESPACE), "Unexpected whitespace-only separator"); tokenizeListData( OTokenizeByWhitespace(), aContent, rContentList ); diff --git a/configmgr/source/xml/valueformatter.cxx b/configmgr/source/xml/valueformatter.cxx index b1eaab25ce8d..9dcb664d02ec 100644 --- a/configmgr/source/xml/valueformatter.cxx +++ b/configmgr/source/xml/valueformatter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: valueformatter.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2002-07-11 17:23:02 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -476,12 +476,14 @@ void ValueFormatter::makeSeparator() Separator aSeparator = createSeparator(m_aValue); m_sSeparator = aSeparator.value(); + m_bUseSeparator = !aSeparator.isDefault(); OSL_POSTCOND( this->isList() , "ValueFormatter: Could not mark as list"); } else { m_sSeparator = OUString(); + m_bUseSeparator = false; OSL_POSTCOND( !this->isList(), "ValueFormatter: Could not mark as non-list"); } @@ -522,8 +524,9 @@ bool ValueFormatter::addValueAttributes(ElementFormatter & _rFormatter) const } // create a sequence separator - if (this->isList()) + if (m_bUseSeparator) { + OSL_ASSERT(this->isList()); _rFormatter.addSeparator(m_sSeparator); } diff --git a/configmgr/source/xml/valueformatter.hxx b/configmgr/source/xml/valueformatter.hxx index 6348365c3984..0602d28d9b61 100644 --- a/configmgr/source/xml/valueformatter.hxx +++ b/configmgr/source/xml/valueformatter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: valueformatter.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jb $ $Date: 2002-05-28 15:42:24 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,12 +88,6 @@ namespace configmgr typedef uno::Reference< script::XTypeConverter > TypeConverter; public: - ValueFormatter() - : m_aValue() - , m_sSeparator() - { - } - explicit ValueFormatter(uno::Any const & _aValue) : m_aValue(_aValue) @@ -116,6 +110,7 @@ namespace configmgr uno::Any m_aValue; OUString m_sSeparator; + bool m_bUseSeparator; }; // ----------------------------------------------------------------------------- diff --git a/configmgr/source/xml/writersvc.cxx b/configmgr/source/xml/writersvc.cxx index 1fcd0210aba8..d53e0eb95901 100644 --- a/configmgr/source/xml/writersvc.cxx +++ b/configmgr/source/xml/writersvc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: writersvc.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: obo $ $Date: 2002-12-10 12:13:08 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,13 +90,13 @@ static inline void clear(OUString & _rs) { _rs = OUString(); } // ----------------------------------------------------------------------------- template <class BackendInterface> -WriterService<BackendInterface>::WriterService(CreationArg _xServiceFactory) -: m_xServiceFactory(_xServiceFactory) +WriterService<BackendInterface>::WriterService(CreationArg _xContext) +: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY) , m_xWriter() { if (!m_xServiceFactory.is()) { - OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration XML Writer: Unexpected NULL context")); + OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration XML Writer: Context has no service manager")); throw uno::RuntimeException(sMessage,NULL); } } diff --git a/configmgr/source/xml/writersvc.hxx b/configmgr/source/xml/writersvc.hxx index b8b72a7d4b42..9aa58f75bc8a 100644 --- a/configmgr/source/xml/writersvc.hxx +++ b/configmgr/source/xml/writersvc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: writersvc.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2002-05-28 15:42:54 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,9 @@ #include <cppuhelper/implbase4.hxx> #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -113,11 +116,11 @@ namespace configmgr > { public: - typedef uno::Reference< lang::XMultiServiceFactory > const & CreationArg; - typedef uno::Reference< lang::XMultiServiceFactory > ServiceFactory; + typedef uno::Reference< uno::XComponentContext > const & CreationArg; + typedef uno::Reference< lang::XMultiServiceFactory > ServiceFactory; explicit - WriterService(CreationArg _xServiceFactory); + WriterService(CreationArg _xContext); // XInitialization virtual void SAL_CALL diff --git a/configmgr/source/xml/xmlstrings.hxx b/configmgr/source/xml/xmlstrings.hxx index 813e68c57e53..521ac2179632 100644 --- a/configmgr/source/xml/xmlstrings.hxx +++ b/configmgr/source/xml/xmlstrings.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlstrings.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2002-07-14 16:49:53 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -134,7 +134,6 @@ namespace configmgr // simple types names DECLARE_CONSTASCII_USTRING(VALUETYPE_BOOLEAN); - DECLARE_CONSTASCII_USTRING(VALUETYPE_BYTE); DECLARE_CONSTASCII_USTRING(VALUETYPE_SHORT); DECLARE_CONSTASCII_USTRING(VALUETYPE_INT); DECLARE_CONSTASCII_USTRING(VALUETYPE_LONG); diff --git a/configmgr/util/makefile.mk b/configmgr/util/makefile.mk index f99cbc17ea6e..fcedb0fbc73c 100644 --- a/configmgr/util/makefile.mk +++ b/configmgr/util/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.16 $ +# $Revision: 1.17 $ # -# last change: $Author: cyrillem $ $Date: 2002-06-17 14:35:03 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:20:17 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -96,7 +96,6 @@ SHL1DEPN= SHL1IMPLIB= i$(SHL1TARGET) SHL1LIBS= $(SLB)$/registry.lib \ $(SLB)$/treecache.lib \ - $(SLB)$/session.lib \ $(SLB)$/misc.lib \ $(SLB)$/backend.lib \ $(SLB)$/localbe.lib \ @@ -138,7 +137,6 @@ SHL2DEPN= SHL2IMPLIB= i$(SHL2TARGET) SHL2LIBS= $(SLB)$/registry.lib \ $(SLB)$/treecache.lib \ - $(SLB)$/sxl_session.lib \ $(SLB)$/misc.lib \ $(SLB)$/xml.lib \ $(SLB)$/treemgr.lib \ diff --git a/configmgr/workben/apitest/cfgadduser.cxx b/configmgr/workben/apitest/cfgadduser.cxx index 122963a5364d..6946b010a4d5 100644 --- a/configmgr/workben/apitest/cfgadduser.cxx +++ b/configmgr/workben/apitest/cfgadduser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cfgadduser.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2001-09-28 13:32:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,9 +96,6 @@ #include <cppuhelper/servicefactory.hxx> #endif -#include <iostream> -using std::cout; - using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; diff --git a/configmgr/workben/apitest/cfgadmin.cxx b/configmgr/workben/apitest/cfgadmin.cxx index f40a5eaf6d98..c7e6d7d06fd5 100644 --- a/configmgr/workben/apitest/cfgadmin.cxx +++ b/configmgr/workben/apitest/cfgadmin.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cfgadmin.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2001-09-28 13:32:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -477,7 +477,7 @@ int _cdecl main( int argc, char * argv[] ) ); if (!xORB.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the service factory !\n\n"; return 1; } @@ -493,7 +493,7 @@ int _cdecl main( int argc, char * argv[] ) if (!xCfgProvider.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the configuration provider !\n\n"; return 3; } @@ -543,7 +543,7 @@ int _cdecl main( int argc, char * argv[] ) } catch (Exception& e) { - cout.flush(); + ::flush(cout); cerr << "Caught exception: " << e.Message << endl; return 1; } diff --git a/configmgr/workben/apitest/cfgapi.cxx b/configmgr/workben/apitest/cfgapi.cxx index bf27d2ae7a84..ec4086c83bae 100644 --- a/configmgr/workben/apitest/cfgapi.cxx +++ b/configmgr/workben/apitest/cfgapi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cfgapi.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: jb $ $Date: 2002-10-28 14:18:34 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,7 +64,6 @@ using namespace std; #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/Type.hxx> #include <com/sun/star/uno/TypeClass.hpp> @@ -73,10 +72,8 @@ using namespace std; #include <com/sun/star/container/XHierarchicalName.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> #ifndef _COM_SUN_STAR_UTIL_XCHANGESBATCH_HPP_ #include <com/sun/star/util/XChangesBatch.hpp> #endif @@ -85,7 +82,9 @@ using namespace std; #include <rtl/ustring.hxx> #include <rtl/string.hxx> -#include <cppuhelper/bootstrap.hxx> +#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_ +#include <cppuhelper/servicefactory.hxx> +#endif #ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ #include <com/sun/star/uno/Sequence.h> @@ -174,7 +173,7 @@ inline void operator <<= (Any& _rUnoValue, const ::rtl::OString& _rAsciiString) } //============================================================================= -bool test_cfg_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF); +void test_read_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF); //============================================================================= struct prompt_and_wait { @@ -203,10 +202,111 @@ void commit() } // ----------------------------------------------------------------------------- -static const sal_Char* const s_pProviderService = "com.sun.star.configuration.ConfigurationProvider"; -static const sal_Char* const s_pAccessService = "com.sun.star.configuration.ConfigurationUpdateAccess"; -static const sal_Char* const s_pRootNode = "org.openoffice.Office.Common"; -static const sal_Char* const s_pLocale = "en-US"; +static sal_Bool s_bInitialized = sal_False; +#ifdef LLA_PRIVAT_DEBUG +static const sal_Char* s_pSourcePath = "l:/src625/configmgr/workben/local_io/share"; +static const sal_Char* s_pUpdatePath = "l:/src625/configmgr/workben/local_io/user"; +static const sal_Char* s_pRootNode = "org.openoffice.ucb.Hierarchy"; // "org.openoffice.test"; +static const sal_Char* s_pServerType = "local"; +static const sal_Char* s_pLocale = "de-DE"; +static const sal_Char* s_pServer = ""; +static const sal_Char* s_pUser = ""; +static const sal_Char* s_pPassword = ""; +#else +static const sal_Char* s_pSourcePath = "g:/src/configmgr/workben/local_io/share"; +static const sal_Char* s_pUpdatePath = "g:/src/configmgr/workben/local_io/user"; +static const sal_Char* s_pRootNode = "org.openoffice.Office.TypeDetection"; +static const sal_Char* s_pServerType = "setup"; +static const sal_Char* s_pLocale = "de-DE"; +static const sal_Char* s_pServer = "lautrec-3108:19205"; +static const sal_Char* s_pUser = "lars"; +static const sal_Char* s_pPassword = ""; +#endif + + +// ----------------------------------------------------------------------------- +static void loadDefaults() +{ + if (s_bInitialized) + return; + + s_bInitialized = sal_True; + + try + { + // the executable file name + ::rtl::OUString sExecutable; + osl_getExecutableFile(&sExecutable.pData); + // cut the name, add a cfgapi.ini to the path + sal_Int32 nLastSep = sExecutable.lastIndexOf('/'); + if (-1 != nLastSep) + sExecutable = sExecutable.copy(0, nLastSep + 1); +#ifdef UNX + sExecutable += ::rtl::OUString::createFromAscii("cfgapirc"); +#else + sExecutable += ::rtl::OUString::createFromAscii("cfgapi.ini"); +#endif + ::rtl::OUString sNormalized; + sNormalized = sExecutable; + if (1) + { + ::osl::Profile aProfile(sNormalized); + + static ::rtl::OString sSection("defaults"); + static ::rtl::OString sSourcePath("sourcepath"); + static ::rtl::OString sUpdatePath("updatepath"); + static ::rtl::OString sRootNode("rootnode"); + static ::rtl::OString sServerType("servertype"); + static ::rtl::OString sLocale("Locale"); + static ::rtl::OString sServer("Server"); + static ::rtl::OString sUser("User"); + static ::rtl::OString sPassword("Password"); + + // read some strings. + // Do this static because we want to redirect the global static character pointers to the buffers. + static ::rtl::OString s_sSourcePath = aProfile.readString(sSection, sSourcePath, s_pSourcePath); + static ::rtl::OString s_sUpdatePath = aProfile.readString(sSection, sUpdatePath, s_pUpdatePath); + static ::rtl::OString s_sRootNode = aProfile.readString(sSection, sRootNode, s_pRootNode); + static ::rtl::OString s_sServerType = aProfile.readString(sSection, sServerType, s_pServerType); + static ::rtl::OString s_sLocale = aProfile.readString(sSection, sLocale, s_pLocale); + static ::rtl::OString s_sServer = aProfile.readString(sSection, sServer, s_pServer); + static ::rtl::OString s_sUser = aProfile.readString(sSection, sUser, s_pUser); + static ::rtl::OString s_sPassword = aProfile.readString(sSection, sPassword, s_pPassword); + + // do this redirection + s_pSourcePath = s_sSourcePath.getStr(); + s_pUpdatePath = s_sUpdatePath.getStr(); + s_pRootNode = s_sRootNode.getStr(); + s_pServerType = s_sServerType.getStr(); + s_pLocale = s_sLocale.getStr(); + s_pServer = s_sServer.getStr(); + s_pUser = s_sUser.getStr(); + s_pPassword = s_sPassword.getStr(); + } + } + catch(std::exception& e) + { + e.what(); // silence warnings + } +} + +// ----------------------------------------------------------------------------- +Sequence<Any> createSequence(const OUString &sUser, const OUString &sPasswd) +{ + Sequence< Any > aCPArgs; + + if (sUser.getLength() > 0) + { + aCPArgs.realloc(1); + aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); + } + if (sPasswd.getLength() > 0) + { + aCPArgs.realloc(2); + aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd); + } + return aCPArgs; +} //============================================================================= #include <string.h> @@ -305,33 +405,91 @@ int _cdecl main( int argc, char * argv[] ) aTimeout.Seconds = 5; aTimeout.Nanosec = 0; + // cout << " Please insert Text: "; + // cout.flush(); + // OString aTxt = input("Der Text", 0); + // cout << endl << "You inserted: " << aTxt.getStr() << endl; + // + // cout << "Please insert Password: "; + // cout.flush(); + // OString aPasswd = input("", '*'); + // cout << endl << "You inserted: " << aPasswd.getStr() << endl; + + loadDefaults(); + try { - Reference< XComponentContext > xUnoContext = defaultBootstrap_InitialComponentContext(); - if (!xUnoContext.is()) - { - cout.flush(); - cerr << "Could not create the UNO context !\n\n"; - return 1; - } - - Reference< XMultiServiceFactory > xORB( xUnoContext->getServiceManager(), UNO_QUERY ); + OUString const sServiceRegistry = OUString::createFromAscii( argc > 1 ? argv[1] : "applicat.rdb" ); + Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory( + sServiceRegistry, + ::rtl::OUString() + ); if (!xORB.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the service factory !\n\n"; - return 2; + return 1; } cout << "Service factory created !\n---------------------------------------------------------------" << endl; + Sequence< Any > aCPArgs; - OUString sProviderService = enterValue("Use provider service: ", s_pProviderService, false); + OUString sServerType = enterValue("servertype: ", s_pServerType, false); cout << endl; - Reference< XMultiServiceFactory > xCfgProvider( xORB->createInstance(sProviderService), UNO_QUERY); + + rtl::OUString sUser; + + bool bLocal = sServerType.equalsIgnoreAsciiCase(ASCII("local")) || sServerType.equalsIgnoreAsciiCase(ASCII("setup")); + if (!bLocal) + { + rtl::OUString sServer; + sServer = enterValue("server : ", s_pServer,false); + cout << endl; + + sUser = enterValue("user : ", s_pUser, false); + cout << endl; + + OUString sPasswd = enterValue("password: ", s_pPassword, true); + cout << endl; + + aCPArgs = createSequence(sUser, sPasswd); + + aCPArgs.realloc(aCPArgs.getLength() + 1); + aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("server"), sServer); + + OUString sTimeout = ASCII("10000"); + aCPArgs.realloc(aCPArgs.getLength() + 1); + aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("timeout"), sTimeout); + + } + else + { + rtl::OUString sSharePath, sUserPath; + sSharePath = enterValue("share path: ", s_pSourcePath, false); + cout << endl; + sUserPath = enterValue("user path : ", s_pUpdatePath, false); + cout << endl; + + aCPArgs.realloc(aCPArgs.getLength() + 1); + sal_Int32 nCount = aCPArgs.getLength() - 1; + Any *pAny = &aCPArgs[nCount]; + *pAny <<= configmgr::createPropertyValue(ASCII("sourcepath"), sSharePath); + aCPArgs.realloc(aCPArgs.getLength() + 1); + aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("updatepath"), sUserPath); + } + + aCPArgs.realloc(aCPArgs.getLength() + 1); + aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("servertype"), sServerType); + + Reference< XMultiServiceFactory > xCfgProvider( + xORB->createInstanceWithArguments( + ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), + aCPArgs), + UNO_QUERY); if (!xCfgProvider.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the configuration provider !\n\n"; return 3; } @@ -342,43 +500,49 @@ int _cdecl main( int argc, char * argv[] ) char aPath[300] = "/"; int nStart = sizeof( "/" ) - 1; - cout << "---------------------------------------------------------------\n Configuration Provider created !"; - - bool bQuit = true; - do - { - cout << "\n---------------------------------------------------------------" << endl; - - OUString sViewService = enterValue("Use view/access service: ", s_pAccessService, false); - cout << endl; + cout << "---------------------------------------------------------------\n Configuration Provider created !\n---------------------------------------------------------------" << endl; - Sequence< Any > aArgs(2); + Sequence< Any > aArgs; + aArgs = createSequence(sUser, ASCII("")); - OUString sPath = enterValue("nodepath: ", s_pRootNode, false); - cout << endl; + OUString sPath = enterValue("nodepath: ", s_pRootNode, false); + cout << endl; - aArgs[0] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath); + aArgs.realloc(aArgs.getLength() + 1); + aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath); + if (!bLocal) + { OUString sLocale = enterValue("locale : ", s_pLocale, false); cout << endl; + aArgs.realloc(aArgs.getLength() + 1); + aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("locale"), sLocale); + } +/* +#else + OUString aStr = ASCII("String"); + sal_Int32 nDepth = 10; + Sequence< Any > aArgs(2); - aArgs[1] <<= configmgr::createPropertyValue(ASCII("locale"), sLocale); - - Reference< XInterface > xIFace = xCfgProvider->createInstanceWithArguments(sViewService,aArgs); - cout << "---------------------------------------------------------------\n Configuration Read/Write Access created !\n---------------------------------------------------------------" << endl; + aArgs[0] <<= aStr; + aArgs[1] <<= nDepth; +#endif +*/ + Reference< XInterface > xIFace = xCfgProvider->createInstanceWithArguments( + OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), + aArgs); + cout << "---------------------------------------------------------------\n Configuration Read/Write Access created !\n---------------------------------------------------------------" << endl; - xChangesBatch = Reference< XChangesBatch >(xIFace, UNO_QUERY); + xChangesBatch = Reference< XChangesBatch >(xIFace, UNO_QUERY); - Sequence<OUString> aSeq = xCfgProvider->getAvailableServiceNames(); - showSequence(aSeq); + Sequence<OUString> aSeq = xCfgProvider->getAvailableServiceNames(); + showSequence(aSeq); - bQuit = test_cfg_access(xIFace, xCfgProvider); - } - while (!bQuit); + test_read_access(xIFace, xCfgProvider); } catch (Exception& e) { - cout.flush(); + ::flush(cout); cerr << "Caught exception: " << e.Message << endl; } /* @@ -430,17 +594,15 @@ void write(Reference< XChild >& xChild) if (xChild.is()) cout << "\n[ P ] -\tParent"; else - cout << "\n ROOT -\tParent not available "; + cout << "BUG: Parent not available (no XChild)"; cout << endl; } /////////////////////////////////////////////////////////////////////////////////////////// -bool ask(Reference< XInterface >& xIface, Reference<XMultiServiceFactory> &, bool&); +bool ask(Reference< XInterface >& xIface, Reference<XMultiServiceFactory> &); -bool test_cfg_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF) +void test_read_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF) { - bool bQuit = true; - using com::sun::star::uno::UNO_QUERY; do { @@ -456,139 +618,79 @@ bool test_cfg_access(Reference< XInterface >& xIface, Reference< XMultiServiceFa write(xAccess); write(xChild); } - while (ask(xIface, xMSF, bQuit)); - - return bQuit; + while (ask(xIface, xMSF)); } -bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF, bool& rbQuit) +bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF) { - cout << "\n[ S ] -> <SetValue> "; - cout << "\n[ Z ] -> <SetToNull> "; - cout << "\n[ D ] -> <SetToDefault> "; - cout << "\n[ I ] -> <InsertElement> "; - cout << "\n[ R ] -> <RemoveElement> "; - cout << "\n[ N ] -> <New Access>"; cout << "\n[ Q ] -> <Quit>"; + cout << "\n[ S ] -> <SetValue> "; cout << endl; cout << "\n:> " << flush; - char buf[200] = ""; + char buf[200] = {0}; try { - - enum { nop, show, insert, replace, remove, reset, nullify }; - - int eToDo = nop; - bool bNeedValue = false; + bool bHandled = false; + bool bInserted = false; if (cin.getline(buf,sizeof buf)) { - Reference< XInterface > xNext = xIface; + Reference< XInterface > xNext; if ((buf[0] == 'q' || buf[0] == 'Q') && (0 == buf[1])) { - rbQuit = true; - return false; - } - else if ((buf[0] == 'n' || buf[0] == 'N') && (0 == buf[1])) - { - rbQuit = false; return false; } else if (buf[0] == 0) { return true; } - else if( (buf[0] == 's' || buf[0] == 'S') && (0 == buf[1])) + else if((buf[0] == 0 || buf[0] == 'o' || buf[0] == 'O') && (0 == buf[1])) { - // Replace a Value - Reference< XNameReplace > xAccess(xIface, UNO_QUERY); - - if (xAccess.is()) - { - cout << "Select a Value" << endl; - if (cin.getline(buf,sizeof buf)) - eToDo = replace; - - bNeedValue = true; - } - } - else if( (buf[0] == 'z' || buf[0] == 'Z') && (0 == buf[1])) - { - // Replace a Value - Reference< XNameReplace > xAccess(xIface, UNO_QUERY); - - if (xAccess.is()) - { - cout << "Select a Value" << endl; - if (cin.getline(buf,sizeof buf)) - eToDo = nullify; - } +/* + cout << "work Offline" << endl; + Reference<com::sun::star::configuration::XConfigurationSync> xSync(xMSF, UNO_QUERY); + + Sequence< Any > aArgs2(5); + sal_Int32 n=0; + aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Setup")); + // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Common")); + // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Java")); + // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Writer")); + // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.ucb.Hierarchy")); + xSync->offline(aArgs2); + bHandled = true; +*/ } - else if( (buf[0] == 'd' || buf[0] == 'D') && (0 == buf[1])) + else if((buf[0] == 0 || buf[0] == 's' || buf[0] == 'S') && (0 == buf[1])) { // Replace a Value - Reference< XPropertyState > xAccess(xIface, UNO_QUERY); - - if (xAccess.is()) - { - cout << "Select a Value" << endl; - if (cin.getline(buf,sizeof buf)) - eToDo = reset; - } - } - else if( (buf[0] == 'r' || buf[0] == 'R') && (0 == buf[1])) - { - // Insert an Element - Reference< XNameContainer > xAccess(xIface, UNO_QUERY); + Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - if (xAccess.is()) - { - cout << "Select an Element" << endl; - if (cin.getline(buf,sizeof buf)) - eToDo = remove; - } + cout << "SetMode, insert a Number" << endl; + cin.getline(buf,sizeof buf); + bInserted = true; } - else if( (buf[0] == 'i' || buf[0] == 'I') && (0 == buf[1])) - { - // Insert an Element - Reference< XNameContainer > xAccess(xIface, UNO_QUERY); - - if (xAccess.is()) - { - cout << "Enter a New Element-Name" << endl; - if (cin.getline(buf,sizeof buf)) - eToDo = insert; - bNeedValue = ! Reference< XSingleServiceFactory >::query(xAccess).is(); - } - } else if ((buf[0] == 'p' || buf[0] == 'P') && (0 == buf[1])) { Reference< XChild > xChild(xIface, UNO_QUERY); if (xChild.is()) xNext = xChild->getParent(); - eToDo = nop; + bHandled = true; } - else - eToDo = show; - if (nop != eToDo) + if (bHandled == false) { Reference< XNameAccess > xAccess(xIface, UNO_QUERY); Reference< XHierarchicalNameAccess > xDeepAccess(xIface, UNO_QUERY); + Reference< XExactName > xExactName(xIface, UNO_QUERY); - OUString aName; - OUString aInput = OUString::createFromAscii(buf); - bool bNested = false; - - if (insert == eToDo) + if (xAccess.is() || xDeepAccess.is()) { - aName = aInput; - } - else if (xAccess.is() || xDeepAccess.is()) - { - Reference< XExactName > xExactName(xIface, UNO_QUERY); + OUString aName; + OUString aInput = OUString::createFromAscii(buf); + if (xExactName.is()) { ::rtl::OUString sTemp = xExactName->getExactName(aInput); @@ -603,33 +705,33 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS else if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(aInput)) { aName = aInput; - bNested = true; } else if ('0' <= buf[0] && buf[0] <= '9' && xAccess.is()) { - int n = (atoi(buf)); + unsigned int n = unsigned(atoi(buf)); Sequence<OUString> aNames = xAccess->getElementNames(); - if (0 <= n && n < aNames.getLength()) + if (n < aNames.getLength()) aName = aNames[n]; } - } - if (aName.getLength()) - { - bool bValueOk = true; - Any aElement; - if (insert != eToDo) + if (aName.getLength()) { - aElement = bNested ? xDeepAccess->getByHierarchicalName(aName) : - xAccess.is() ? xAccess-> getByName(aName) : Any(); + bool bNest = aInput.indexOf(sal_Unicode('/')) >= 0; - switch (aElement.getValueTypeClass() ) + Any aElement = bNest ? ( xDeepAccess.is() ? xDeepAccess->getByHierarchicalName(aName) : Any()) + : ( xAccess. is() ? xAccess-> getByName(aName) : Any() ); + + while (aElement.getValueTypeClass() == TypeClass_ANY) { - case TypeClass_INTERFACE: - bNeedValue = false; - cout << "ELEMENT '" << aName << "' is an INNER NODE " << endl; - break; + Any aWrap(aElement); + aWrap >>= aElement; + } + sal_Bool bValue = true; + sal_Bool bValueOk = false; + switch (aElement.getValueTypeClass() ) + { + case TypeClass_INTERFACE: bValue = false; break; case TypeClass_BOOLEAN: { sal_Bool* pVal = (sal_Bool*)aElement.getValue(); @@ -650,7 +752,7 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS { sal_Int16 aValue; cout << "VALUE '" << aName << "' is a SHORT (16 bit) = "; - if (bValueOk = !!(aElement >>= aValue)) + if (bValueOk = (aElement >>= aValue)) cout << aValue; else cout << "ERROR RETRIEVING VALUE"; @@ -662,7 +764,7 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS sal_Int32 aValue; cout << "VALUE '" << aName << "' is a INT (32 bit) = "; - if (bValueOk = !!(aElement >>= aValue)) + if (bValueOk = (aElement >>= aValue)) cout << aValue; else cout << "ERROR RETRIEVING VALUE"; @@ -673,7 +775,7 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS { sal_Int64 aValue; cout << "VALUE '" << aName << "' is a LONG (64 bit) = "; - if (bValueOk = !!(aElement >>= aValue)) + if (bValueOk = (aElement >>= aValue)) cout << double(aValue); else cout << "ERROR RETRIEVING VALUE"; @@ -684,7 +786,7 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS { double aValue; cout << "VALUE '" << aName << "' is a DOUBLE = "; - if (bValueOk = !!(aElement >>= aValue)) + if (bValueOk = (aElement >>= aValue)) cout << aValue; else cout << "ERROR RETRIEVING VALUE"; @@ -695,7 +797,7 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS { OUString aValue; cout << "VALUE '" << aName << "' is a STRING = "; - if (bValueOk = !!(aElement >>= aValue)) + if (bValueOk = (aElement >>= aValue)) cout << "\"" << aValue << "\""; else cout << "ERROR RETRIEVING VALUE"; @@ -717,121 +819,69 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS bValueOk = true; break; default: - bValueOk = false; - cout << "Error: ELEMENT '" << aName << "' is of unknown or unrecognized type" << endl; + cout << "Error: ELEMENT '" << aName << "' is of unknown or unrecognized type" << endl; break; } - } - else - bValueOk = true; - - Any aValue; - if (bNeedValue) - { - if (aElement.getValueTypeClass() == TypeClass_BOOLEAN ) - { - cout << "Set Value (boolean) to :"; - cout.flush(); - cin.getline(buf,sizeof buf); - OUString aInput = OUString::createFromAscii(buf); - - sal_Bool bBoolValue = false; - if (aInput.equalsIgnoreAsciiCase(ASCII("true"))) - bBoolValue = true; - - else if (!aInput.equalsIgnoreAsciiCase(ASCII("false"))) - cout << "Warning: Not a valid bool value - setting to false" << endl; - - aValue <<= bBoolValue; - } - else - { - if ( aElement.getValueTypeClass() == TypeClass_VOID ) - cout << "Warning: Cannot determine value type (value is NULL)" << endl; - - else if ( aElement.getValueTypeClass() != TypeClass_STRING) - cout << "Warning: No explict support for value type found" << endl; - - cout << "Set value to : "; - cout.flush(); - cin.getline(buf,sizeof buf); - - aValue <<= buf; - } - } - else if (insert == eToDo || replace == eToDo) - { - Reference<XSingleServiceFactory> xFactory(xIface, UNO_QUERY); - - OSL_ASSERT(xFactory.is()); - if (xFactory.is()) + if (bValue) { - xNext = xFactory->createInstance(); - aValue <<= xNext; - } - } - - switch (eToDo) - { - case nullify: - OSL_ASSERT(!aValue.hasValue()); // nullify is replace with NULL value - // fall thru - - case replace: - { - Reference< XNameReplace > xNameReplace(xIface, UNO_QUERY); - if (xNameReplace.is()) - xNameReplace->replaceByName(aName, aValue); - } break; - - case reset: - { - Reference< XPropertyState > xReset(xIface, UNO_QUERY); - OSL_ASSERT(xReset.is()); - if (xReset.is()) - { - xReset->setPropertyToDefault(aName); - } - } break; - - case insert: - { - Reference< XNameContainer> xNameContainer(xIface, UNO_QUERY); - OSL_ASSERT(xNameContainer.is()); - if (xNameContainer.is()) + if (bInserted) { - xNameContainer->insertByName(aName, aValue); - aElement = aValue; - } - } break; - - case remove: - { - Reference< XNameContainer> xNameContainer(xIface, UNO_QUERY); - OSL_ASSERT(xNameContainer.is()); - if (xNameContainer.is()) - { - xNameContainer->removeByName(aName); - aElement = aValue; + if (aElement.getValueTypeClass() == TypeClass_BOOLEAN || + aElement.getValueTypeClass() == TypeClass_VOID) + { + cout << "Set Value (Type=BOOL) to :"; + cout.flush(); + cin.getline(buf,sizeof buf); + OUString aInput = OUString::createFromAscii(buf); + sal_Bool bValue = false; + if (aInput.equalsIgnoreAsciiCase(ASCII("true"))) + bValue = true; + + OUString aStr = ASCII("false"); + Any aValueAny; + aValueAny <<= bValue; + + Reference< XNameReplace > xNameReplace(xAccess, UNO_QUERY); + if (xNameReplace.is()) + { + xNameReplace->replaceByName(aName, aValueAny); + commit(); + } + bInserted = false; + } + else if (aElement.getValueTypeClass() == TypeClass_STRING) + { + cout << "set value (type = string) to : "; + cout.flush(); + cin.getline(buf,sizeof buf); + Any aValue; + aValue <<= buf; + + Reference< XNameReplace > xNameReplace(xAccess, UNO_QUERY); + if (xNameReplace.is()) + { + xNameReplace->replaceByName(aName, aValue); + commit(); + } + bInserted = false; + } + else + { + cout << "Sorry, only BOOLEAN Values can changed today." << endl; + } } - } break; - - case show: - { - if (aElement >>= xNext) - cout << "Got an Interface for '" << aName << "'" << endl; + prompt_and_wait(); + return bValueOk ? true : false; + } - else if (!aElement.hasValue()) - cout << "Error: Cannot get a Value or Interface for '" << aName << "'" << endl; - } break; + if (aElement >>= xNext) + cout << "Got an Interface for '" << aName << "'" << endl; + else + cout << "Error: Cannot get an Interface for '" << aName << "'" << endl; } - if (show != eToDo) - commit(); - - if (bNeedValue) + else { - prompt_and_wait(); - return bValueOk; + cout << "Error: No element \"" << aInput << "\" found." <<endl; } } @@ -846,7 +896,7 @@ bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMS else { cout << "Input Error " << endl; - return false; + return true; } } catch (Exception& e) diff --git a/configmgr/workben/apitest/cfgapi_timetest.cxx b/configmgr/workben/apitest/cfgapi_timetest.cxx index 73c2c78ec50b..bc5931a221b0 100644 --- a/configmgr/workben/apitest/cfgapi_timetest.cxx +++ b/configmgr/workben/apitest/cfgapi_timetest.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cfgapi_timetest.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2001-09-28 13:32:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -461,7 +461,7 @@ int _cdecl main( int argc, char * argv[] ) ); if (!xORB.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the service factory !\n\n"; return 1; } @@ -527,7 +527,7 @@ int _cdecl main( int argc, char * argv[] ) UNO_QUERY); if (!xCfgProvider.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the configuration provider !\n\n"; return 3; } @@ -566,7 +566,7 @@ int _cdecl main( int argc, char * argv[] ) } catch (Exception& e) { - cout.flush(); + ::flush(cout); cerr << "Caught exception: " << e.Message << endl; return 1; } @@ -606,7 +606,7 @@ void ask_for_a_node_and_test_it(const Reference< XMultiServiceFactory > &xCfgPro } catch (Exception& e) { - cout.flush(); + ::flush(cout); cerr << "Caught exception: " << e.Message << endl; } } @@ -774,9 +774,9 @@ bool ask(Reference< XInterface >& xIface, const Reference< XMultiServiceFactory } else if ('0' <= buf[0] && buf[0] <= '9' && xAccess.is()) { - int n = atoi(buf); + unsigned int n = unsigned(atoi(buf)); Sequence<OUString> aNames = xAccess->getElementNames(); - if (0 <= n && n < aNames.getLength()) + if (n < aNames.getLength()) aName = aNames[n]; } diff --git a/configmgr/workben/apitest/cfgupdate.cxx b/configmgr/workben/apitest/cfgupdate.cxx index 06f7dcd23453..8ba6222a6559 100644 --- a/configmgr/workben/apitest/cfgupdate.cxx +++ b/configmgr/workben/apitest/cfgupdate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cfgupdate.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2001-09-28 13:32:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -361,7 +361,7 @@ void displayTree(Reference< XNameAccess > xIFace, sal_Int32 nLevel) cout << "<" << aNames[i] << "/>"; } - cout.flush(); + ::flush(cout); } // ----------------------------------------------------------------------------- @@ -397,7 +397,7 @@ int _cdecl main( int argc, char * argv[] ) ); if (!xORB.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the service factory !\n\n"; return 1; } @@ -428,7 +428,7 @@ int _cdecl main( int argc, char * argv[] ) UNO_QUERY); if (!xCfgProvider.is()) { - cout.flush(); + ::flush(cout); cerr << "Could not create the configuration provider !\n\n"; return 3; } @@ -461,7 +461,7 @@ int _cdecl main( int argc, char * argv[] ) } catch (Exception& e) { - cout.flush(); + ::flush(cout); cerr << "Caught exception: " << e.Message << endl; } /* diff --git a/configmgr/workben/apitest/makefile.mk b/configmgr/workben/apitest/makefile.mk index 6936559446f4..b7a33c5092e9 100644 --- a/configmgr/workben/apitest/makefile.mk +++ b/configmgr/workben/apitest/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: jb $ $Date: 2001-09-28 13:32:56 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:20:18 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -84,10 +84,6 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\" -.IF "$(COM)"=="MSC" -CFLAGS += -Ob0 -.ENDIF - # ... common for all test executables .............................. APPSTDLIBS=\ $(SALLIB) \ diff --git a/configmgr/workben/apitest/sregistry b/configmgr/workben/apitest/sregistry new file mode 100644 index 000000000000..f4f353181f25 --- /dev/null +++ b/configmgr/workben/apitest/sregistry @@ -0,0 +1,8 @@ +[configuration] +servertype=remote +[RemoteRegistry] +Server=munch-11072:100 +Timeout=2500 +[LocalRegistry] +rootpath="G:\Configuration" + diff --git a/configmgr/workben/local_io/makefile.mk b/configmgr/workben/local_io/makefile.mk index a4c42fdb3ee0..902cb1d63cda 100644 --- a/configmgr/workben/local_io/makefile.mk +++ b/configmgr/workben/local_io/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: lla $ $Date: 2001-07-26 07:10:28 $ +# last change: $Author: hr $ $Date: 2003-03-19 16:20:19 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -108,7 +108,6 @@ APP1OBJS= \ $(SLO)$/simpletest.obj \ $(SLO)$/strimpl.obj \ $(SLO)$/confname.obj \ - $(SLO)$/trivialbufferedfile.obj \ # $(SLO)$/xmlexport.obj \ # $(SLO)$/xmlimport.obj \ diff --git a/configmgr/workben/local_io/simpletest.cxx b/configmgr/workben/local_io/simpletest.cxx index d03df5155ef2..5782a2d2e7a4 100644 --- a/configmgr/workben/local_io/simpletest.cxx +++ b/configmgr/workben/local_io/simpletest.cxx @@ -2,9 +2,9 @@ * * $RCSfile: simpletest.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: lla $ $Date: 2001-07-26 07:10:28 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:20:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,6 @@ #include <memory> #include <vector> #include <stack> -#include <map> -#include <hash_map> #ifndef _OSL_FILE_HXX_ #include<osl/file.hxx> @@ -167,7 +165,7 @@ #include "xmltreebuilder.hxx" -// #include "dataimport.hxx" +#include "dataimport.hxx" #include "createpropertyvalue.hxx" @@ -196,7 +194,7 @@ using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::io; using namespace rtl; using namespace osl; -using namespace std; + // ----------------------------------------------------------------------------- // ---------------------------------- defines ---------------------------------- // ----------------------------------------------------------------------------- @@ -298,7 +296,6 @@ namespace configmgr #define ASCII_STRING(rtlOUString) rtl::OUStringToOString(rtlOUString, RTL_TEXTENCODING_ASCII_US).getStr() static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb"); -/* void simpleTest() { uno::Reference< lang::XMultiServiceFactory > xMSF; @@ -383,7 +380,7 @@ namespace configmgr nRet = 5; } } -*/ + #include <osl/time.h> #include <rtl/string.hxx> @@ -825,12 +822,6 @@ void oslTest() } - OUString aDirectory3(FileHelper::convertFilenameToFileURL(ASCII("F:/Tst/StarOffice6.0/share/config"))); - - OUString aDirectory4(ASCII("file:///F:/T%EF%BF%A4st/StarOffice6.0/share/config")); - osl::FileBase::RC eError = osl::Directory::create(aDirectory4); - - /* OUString aDirectory(FileHelper::convertFilenameToFileURL(ASCII("c:/temp/dies"))); osl::FileBase::RC eError = osl::Directory::create(aDirectory); |