summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/prj/d.lst9
-rw-r--r--configmgr/source/api/confeventhelpers.cxx484
-rw-r--r--configmgr/source/api/confeventhelpers.hxx248
-rw-r--r--configmgr/source/api/confevents.cxx410
-rw-r--r--configmgr/source/api/confsvccomponent.cxx181
-rw-r--r--configmgr/source/api/makefile.mk102
-rw-r--r--configmgr/source/cmdtools/makefile.mk121
-rw-r--r--configmgr/source/inc/attributes.hxx116
-rw-r--r--configmgr/source/inc/bootstrap.hxx111
-rw-r--r--configmgr/source/inc/commontypes.hxx129
-rw-r--r--configmgr/source/inc/confapifactory.hxx105
-rw-r--r--configmgr/source/inc/confevents.hxx211
-rw-r--r--configmgr/source/inc/confsvccomponent.hxx139
-rw-r--r--configmgr/source/inc/filehelper.hxx84
-rw-r--r--configmgr/source/inc/oslstream.hxx149
-rw-r--r--configmgr/source/inc/strdecl.hxx113
-rw-r--r--configmgr/source/inc/strings.hxx112
-rw-r--r--configmgr/source/inc/tracer.hxx180
-rw-r--r--configmgr/source/inc/treeactions.hxx111
-rw-r--r--configmgr/source/inc/typeconverter.hxx112
-rw-r--r--configmgr/source/misc/configunoreg.cxx490
-rw-r--r--configmgr/source/misc/filehelper.cxx320
-rw-r--r--configmgr/source/misc/makefile.mk100
-rw-r--r--configmgr/source/misc/oslstream.cxx239
-rw-r--r--configmgr/source/misc/strimpl.cxx124
-rw-r--r--configmgr/source/misc/tracer.cxx396
-rw-r--r--configmgr/source/registry/cfgregistrykey.cxx783
-rw-r--r--configmgr/source/registry/cfgregistrykey.hxx256
-rw-r--r--configmgr/source/registry/configregistry.cxx344
-rw-r--r--configmgr/source/registry/configregistry.hxx175
-rw-r--r--configmgr/source/registry/makefile.mk82
-rw-r--r--configmgr/source/tree/changes.cxx194
-rw-r--r--configmgr/source/tree/cmtree.cxx719
-rw-r--r--configmgr/source/tree/cmtreemodel.cxx323
-rw-r--r--configmgr/source/tree/makefile.mk89
-rw-r--r--configmgr/source/treecache/makefile.mk83
-rw-r--r--configmgr/source/xml/makefile.mk92
-rw-r--r--configmgr/source/xml/typeconverter.cxx362
-rw-r--r--configmgr/util/exports.dxp3
-rw-r--r--configmgr/util/makefile.mk106
-rw-r--r--configmgr/version.mk81
-rw-r--r--configmgr/workben/apitest/cfgadduser.cxx409
-rw-r--r--configmgr/workben/apitest/cfgapi.cxx496
-rw-r--r--configmgr/workben/apitest/cfgregistry.cxx226
-rw-r--r--configmgr/workben/apitest/makefile.mk133
-rw-r--r--configmgr/workben/apitest/sregistry8
-rw-r--r--configmgr/workben/local_io/cfgfile.cxx111
-rw-r--r--configmgr/workben/local_io/cfglocal.cxx666
-rw-r--r--configmgr/workben/local_io/com.sun.star.office.Setup.xml29
-rw-r--r--configmgr/workben/local_io/filetest.cxx127
-rw-r--r--configmgr/workben/local_io/makefile.mk154
-rw-r--r--configmgr/workben/local_io/simpletest.cxx537
-rw-r--r--configmgr/workben/local_io/xmlexport.cxx302
-rw-r--r--configmgr/workben/local_io/xmlimport.cxx545
54 files changed, 12331 insertions, 0 deletions
diff --git a/configmgr/prj/d.lst b/configmgr/prj/d.lst
new file mode 100644
index 000000000000..cde324ffe1b7
--- /dev/null
+++ b/configmgr/prj/d.lst
@@ -0,0 +1,9 @@
+mkdir: %_DEST%\inc%_EXT%\configmgr
+:wq..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*.so
+..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res
+..\%__SRC%\bin\*.exe %_DEST%\bin%_EXT%\*.exe
+..\%__SRC%\bin\*.bin %_DEST%\bin%_EXT%\*.bin
+
+
diff --git a/configmgr/source/api/confeventhelpers.cxx b/configmgr/source/api/confeventhelpers.cxx
new file mode 100644
index 000000000000..ef2ea4ee13a3
--- /dev/null
+++ b/configmgr/source/api/confeventhelpers.cxx
@@ -0,0 +1,484 @@
+/*************************************************************************
+ *
+ * $RCSfile: confeventhelpers.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include "confeventhelpers.hxx"
+
+#ifndef CONFIGMGR_CONFNAME_HXX_
+#include "confname.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+namespace configmgr
+{
+ namespace internal
+ {
+
+ void throwDispatchIllegalSequenceException()
+ {
+ OSL_ENSHURE( 0, "Illegal Call to brodcaster while dispatching" );
+ }
+
+////////////////////////////////////////////////////////////////////////
+/* template <class Listener>
+ class BroadcastImplHelper
+ {
+ public:
+ osl::Mutex m_aMutex;
+
+ BroadcastImplHelper() {}
+ ~BroadcastImplHelper() {}
+
+ typedef std::set<Listener*> Interfaces;
+ typedef Interfaces::const_iterator Iterator;
+
+ void addInterface(Listener* aListener) { m_aInterfaces.insert(aListener); }
+ void removeInterface(Listener* aListener) { m_aInterfaces.erase(aListener); }
+
+ void disposing(ConfigChangeBroadcaster* pSource);
+
+ Iterator begin() const { return m_aInterfaces.begin(); }
+ Iterator end() const { return m_aInterfaces.end(); }
+ private:
+ Interfaces m_aInterfaces;
+
+ // no implementation - not copyable
+ BroadcastImplHelper(BroadcastImplHelper&);
+ void operator=(BroadcastImplHelper&);
+ };
+*/
+
+/////////////////////////////////////////////////////////////////////////
+/*
+ struct NodeListenerInfo
+ {
+ INodeListener* m_pListener;
+ OUString m_path;
+
+ // fake a pointer for generic clients
+ INodeListener* operator->() const { return m_pListener; }
+ INodeListener& operator*() const { return *m_pListener; }
+
+ bool operator < (NodeListenerInfo const& aInfo) const;
+ };
+*/
+/////////////////////////////////////////////////////////////////////////
+
+/*
+ class ConfigChangesBroadcasterImpl
+ {
+ private:
+ typedef BroadcastImplHelper<NodeListenerInfo> Listeners;
+ Listeners m_aListeners;
+ std::map<OUString, Listeners::Iterator> m_aDispatchInfos;
+ };
+*/
+/////////////////////////////////////////////////////////////////////////
+ConfigChangesBroadcasterImpl::ConfigChangesBroadcasterImpl()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////
+ConfigChangesBroadcasterImpl::~ConfigChangesBroadcasterImpl()
+{
+ OSL_ENSURE(m_aListeners.begin() == m_aListeners.end(), "Remaining listeners found - forgot to dispose ?");
+ OSL_ENSURE(m_aPathMap.empty(), "Spurious mappings found");
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigChangesBroadcasterImpl::add(OUString const& aName, INodeListener* pListener)
+{
+ OSL_ASSERT( ! ConfigurationName(aName).isRelative() );
+
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ InfoRef aAdded = m_aListeners.addListener(NodeListenerInfo(pListener));
+ aAdded->addPath(aName);
+ m_aPathMap.insert(PathMap::value_type(aName,aAdded));
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigChangesBroadcasterImpl::remove(INodeListener* pListener)
+{
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ Listeners::Iterator const iter = m_aListeners.find(pListener);
+ if (iter != m_aListeners.end())
+ {
+ typedef NodeListenerInfo::Pathes Pathes;
+ Pathes const& pathes = iter->pathList();
+
+ // first clear the Path Map
+ for(Pathes::iterator itPath = pathes.begin(); itPath != pathes.end(); ++itPath)
+ {
+ typedef PathMap::iterator PMIter;
+ typedef std::pair<PMIter, PMIter> PMRange;
+
+ PMRange aRange = m_aPathMap.equal_range(*itPath);
+ while (aRange.first != aRange.second)
+ {
+ PMIter cur = aRange.first++;
+ if (cur->second == iter)
+ m_aPathMap.erase(cur);
+ }
+ }
+
+ // the remove the broadcast helper entry
+ m_aListeners.removeListener(pListener);
+ }
+}
+
+void ConfigChangesBroadcasterImpl::removed(OUString const& aBasePath, bool bRemovedFromModel, IConfigBroadcaster* pSource)
+{
+ OSL_ASSERT( ! ConfigurationName(aBasePath).isRelative() );
+
+ // Dispatch 'deleted' to descendants of the changed path
+
+ for( PathMap::const_iterator it = m_aPathMap.lower_bound(aBasePath);
+ it != m_aPathMap.end() && 0 == aBasePath.compareTo(it->first, aBasePath.getLength());
+ )
+ {
+ OSL_ASSERT( m_aListeners.find(it->second->get()) != m_aListeners.end() );
+
+ OUString aDispatchPath = it->first;
+ OSL_ASSERT( ! ConfigurationName(aDispatchPath).isRelative() );
+
+ INodeListener* pTarget = it->second->get();
+ ++it;
+
+ // we allow a listener to remove itself from within the callback
+ // the simple increment above wont work, if the following listener is the same listener
+ // (which really shouldn't happen)
+ PathMap::const_iterator next = it;
+ while (next != m_aPathMap.end() && next->second->get() == pTarget)
+ ++next;
+
+ pTarget->nodeDeleted(aBasePath, pSource);
+
+ // if a listener removes itself from within the callback, it will be missing by now
+ // so we check whether our listener is still there and if necessary patch our position
+ if (m_aListeners.find(pTarget) == m_aListeners.end())
+ it = next;
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////////////
+// This should actually be available from the TreeChangeList
+/////////////////////////////////////////////////////////////////////////
+
+static Change const* resolvePath(Change const* pChange, ConfigurationName& aRelativePath, RemoveNode const*& pRemoveNode)
+{
+ OSL_ASSERT(aRelativePath.isRelative());
+ OSL_ASSERT(pRemoveNode == 0);
+ pRemoveNode = 0;
+
+ ConfigurationName::Iterator aIter(aRelativePath.begin());
+ ConfigurationName::Iterator const aEnd(aRelativePath.end());
+
+ OSL_ASSERT(pChange);
+ OSL_ASSERT(aIter != aEnd);
+
+ while (pChange)
+ {
+ if (pChange->ISA(RemoveNode))
+ pRemoveNode = static_cast<RemoveNode const*>(pChange);
+
+ OSL_ASSERT(*aIter == pChange->getNodeName());
+ if (++aIter == aEnd)
+ break; // found it
+
+ pChange = pChange->getSubChange(*aIter);
+
+ OSL_ASSERT(pRemoveNode == NULL || pChange == NULL);
+ }
+ if (pRemoveNode)
+ {
+ aRelativePath = ConfigurationName(aRelativePath.begin(),aIter);
+ OSL_ASSERT( aRelativePath.localName() == pRemoveNode->getNodeName());
+ }
+ else
+ OSL_ASSERT(pChange == 0 || aRelativePath == ConfigurationName(aRelativePath.begin(),aIter));
+
+ return pChange;
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigChangesBroadcasterImpl::dispatchInner
+(
+ INodeListener* pTarget,
+ OUString const& sTargetPath,
+ Change const& rBaseChange,
+ OUString const& sChangeContext,
+ sal_Bool , //_bError,
+ IConfigBroadcaster* pSource
+)
+{
+ ConfigurationName aContext(sChangeContext);
+
+ OSL_ASSERT(pTarget);
+ OSL_ASSERT( ConfigurationName(sTargetPath).isNestedIn( aContext ) );
+
+ ConfigurationName aLocalPath = ConfigurationName(sTargetPath).relativeTo( aContext );
+ RemoveNode const* pRemoved = 0;
+ Change const* pTargetChange = resolvePath(&rBaseChange, aLocalPath, pRemoved );
+
+ if (pRemoved)
+ {
+ pTarget->nodeDeleted(aContext.composeWith(aLocalPath).fullName(), pSource);
+ }
+ else if (pTargetChange)
+ {
+ OSL_ASSERT(aContext.composeWith(aLocalPath) == sTargetPath);
+ pTarget->nodeChanged(*pTargetChange, sTargetPath, pSource);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigChangesBroadcasterImpl::dispatchOuter
+(
+ INodeListener* pTarget,
+ OUString const& sTargetPath,
+ Change const& rBaseChange,
+ OUString const& sChangeContext,
+ sal_Bool , //_bError,
+ IConfigBroadcaster* pSource
+)
+{
+ ConfigurationName sChangesRoot(sChangeContext,rBaseChange.getNodeName());
+
+ OSL_ASSERT(pTarget);
+ OSL_ASSERT( sChangesRoot.isNestedIn( sTargetPath ) );
+
+ pTarget->nodeChanged(rBaseChange, sChangesRoot.fullName(), pSource);
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigChangesBroadcasterImpl::dispatch(TreeChangeList const& rList_, sal_Bool _bError, IConfigBroadcaster* pSource)
+{
+ dispatch(rList_.root, rList_.pathToRoot,_bError, pSource);
+}
+void ConfigChangesBroadcasterImpl::dispatch
+(
+ Change const& rBaseChange,
+ OUString const& sChangeContext,
+ sal_Bool _bError,
+ IConfigBroadcaster* pSource
+)
+{
+ // listeners registered under multiple sub-pathes will be called multiple times !
+
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ ConfigurationName aRootName(sChangeContext);
+ OSL_ASSERT(!aRootName.isRelative());
+
+ ConfigurationName aNodeName(aRootName, rBaseChange.getNodeName());
+ OUString aBasePath( aNodeName.fullName() );
+ OSL_ASSERT(!aNodeName.isRelative());
+
+ OSL_ASSERT(aNodeName.getParentName() == aRootName);
+
+ // Dispatch listeners to ancestors of the change root
+ PathMap::const_iterator const endOuter = m_aPathMap.upper_bound(aRootName.fullName());
+
+ // TODO: Both loops are so similar - they should be a single function
+ for ( PathMap::const_iterator itOuter = m_aPathMap.lower_bound( ConfigurationName::rootname() += aRootName.moduleName() );
+ itOuter != endOuter;
+ )
+ {
+ OSL_ASSERT( m_aListeners.find(itOuter->second->get()) != m_aListeners.end() );
+
+ OUString aDispatchPath = itOuter->first;
+ OSL_ASSERT( ! ConfigurationName(aDispatchPath).isRelative() );
+
+ INodeListener* pTarget = itOuter->second->get();
+
+ // incrementing here usually is enough
+ ++itOuter;
+
+ // check whether this should be dispatched at all
+ if (aBasePath == aDispatchPath || aNodeName.isNestedIn(aDispatchPath))
+ {
+ // we allow a listener to remove itself from within the callback
+ // the simple increment above wont work, if the following listener is the same listener
+ // (which really shouldn't happen)
+ PathMap::const_iterator next = itOuter;
+ while (next != m_aPathMap.end() && next->second->get() == pTarget)
+ ++next;
+
+ this->dispatchOuter(pTarget, aDispatchPath, rBaseChange, sChangeContext, _bError, pSource);
+
+ // if a listener removes itself from within the callback, it will be missing by now
+ // so we check whether our listener is still there and if necessary patch our position
+ if (m_aListeners.find(pTarget) == m_aListeners.end())
+ itOuter = next;
+ }
+ }
+
+
+ // Dispatch listeners to descendants of the change root
+ for( PathMap::const_iterator itInner = m_aPathMap.lower_bound(aBasePath);
+ itInner != m_aPathMap.end() && 0 == aBasePath.compareTo(itInner->first, aBasePath.getLength());
+ )
+ {
+ OSL_ASSERT( m_aListeners.find(itInner->second->get()) != m_aListeners.end() );
+
+ OUString aDispatchPath = itInner->first;
+ OSL_ASSERT( ! ConfigurationName(aDispatchPath).isRelative() );
+
+ INodeListener* pTarget = itInner->second->get();
+ ++itInner;
+
+ // check whether this should be dispatched at all
+ if (aBasePath == aDispatchPath || ConfigurationName(aDispatchPath).isNestedIn(aRootName))
+ {
+ // we allow a listener to remove itself from within the callback
+ // the simple increment above wont work, if the following listener is the same listener
+ // (which really shouldn't happen)
+ PathMap::const_iterator next = itInner;
+ while (next != m_aPathMap.end() && next->second->get() == pTarget)
+ ++next;
+
+ this->dispatchInner(pTarget, aDispatchPath, rBaseChange, sChangeContext, _bError, pSource);
+
+ // if a listener removes itself from within the callback, it will be missing by now
+ // so we check whether our listener is still there and if necessary patch our position
+ if (m_aListeners.find(pTarget) == m_aListeners.end())
+ itInner = next;
+ }
+
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigChangesBroadcasterImpl::disposing(IConfigBroadcaster* pSource)
+{
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ m_aPathMap.clear();
+ m_aListeners.disposing(pSource);
+}
+
+/////////////////////////////////////////////////////////////////////////
+/* class ConfigMessageBroadcasterImpl
+ {
+ public:
+ private:
+ typedef BroadcastImplHelper<INodeListener*> Listeners;
+ Listeners m_aListeners;
+ };
+*/
+/////////////////////////////////////////////////////////////////////////
+void ConfigMessageBroadcasterImpl::add(IMessageHandler* pListener)
+{
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ m_aListeners.addListener(pListener);
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigMessageBroadcasterImpl::remove(IMessageHandler* pListener)
+{
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ m_aListeners.removeListener(pListener);
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigMessageBroadcasterImpl::dispatch(OUString const& _rNotifyReason, sal_Int32 _nNotificationId, IConfigBroadcaster* pSource)
+{
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ for (Listeners::Iterator it = m_aListeners.begin(); it != m_aListeners.end(); )
+ {
+ // incrementing here allows a listener to remove itself from within the callback
+
+ // it is illegal to cause removal of another listener from the callback
+ // if this occurs (dereferencing, incrementing or comparing 'it' fails)
+ // we need to explicitly guard against that (which is really too expensive)
+
+ IMessageHandler* pHandler = *it;
+ ++it;
+
+ if (pHandler)
+ pHandler->message(_rNotifyReason,_nNotificationId,pSource);
+ }
+
+}
+
+/////////////////////////////////////////////////////////////////////////
+void ConfigMessageBroadcasterImpl::disposing(IConfigBroadcaster* pSource)
+{
+ osl::MutexGuard aGuard(m_aListeners.mutex);
+
+ m_aListeners.disposing(pSource);
+}
+
+/////////////////////////////////////////////////////////////////////////
+ } // namespace
+} // namespace
+
+
+
diff --git a/configmgr/source/api/confeventhelpers.hxx b/configmgr/source/api/confeventhelpers.hxx
new file mode 100644
index 000000000000..1b3b45898377
--- /dev/null
+++ b/configmgr/source/api/confeventhelpers.hxx
@@ -0,0 +1,248 @@
+/*************************************************************************
+ *
+ * $RCSfile: confeventhelpers.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CONFIGMGR_API_EVENTHELPERS_HXX_
+#define CONFIGMGR_API_EVENTHELPERS_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
+#include <com/sun/star/uno/RuntimeException.hpp>
+#endif
+
+#ifndef CONFIGMGR_API_EVENTS_HXX_
+#include "confevents.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef __SGI_STL_MAP
+#include <stl/map>
+#endif
+#ifndef __SGI_STL_SET
+#include <stl/set>
+#endif
+
+namespace configmgr
+{
+ namespace internal
+ {
+
+
+ ////////////////////////////////////////////////////////////////////////
+ template <class ListenerRef>
+ class BroadcastImplHelper
+ {
+ public:
+ osl::Mutex mutex;
+
+ public:
+ BroadcastImplHelper()
+ {}
+
+ ~BroadcastImplHelper()
+ {
+ OSL_ENSHURE(m_aInterfaces.empty(), "Configuration Broadcaster was not disposed properly");
+ }
+
+ public:
+ typedef std::set<ListenerRef> Interfaces;
+ typedef typename Interfaces::iterator FullIterator;
+ typedef typename Interfaces::const_iterator Iterator;
+
+ public:
+ FullIterator addListener(ListenerRef aListener)
+ {
+ return m_aInterfaces.insert(aListener).first;
+ }
+ void removeListener(ListenerRef aListener)
+ {
+ m_aInterfaces.erase(aListener);
+ }
+
+ void disposing(IConfigBroadcaster* pSource);
+
+ public:
+ Iterator begin() const { return m_aInterfaces.begin(); }
+ Iterator end() const { return m_aInterfaces.end(); }
+
+ Iterator find(ListenerRef aListener) const { return m_aInterfaces.find(aListener); }
+ FullIterator findFull(ListenerRef aListener) { return m_aInterfaces.find(aListener); }
+ private:
+ Interfaces m_aInterfaces;
+
+ // no implementation - not copyable
+ BroadcastImplHelper(BroadcastImplHelper&);
+ void operator=(BroadcastImplHelper&);
+ };
+
+ ////////////////////////////////////////////////////////////////////////
+ template <class Listener>
+ void BroadcastImplHelper<Listener>::disposing(IConfigBroadcaster* pSource)
+ {
+ osl::MutexGuard aGuard(this->mutex); // ensure that no notifications are running
+
+ for(FullIterator it = m_aInterfaces.begin(); it != m_aInterfaces.end(); )
+ {
+ FullIterator cur = it++;
+ if (*cur)
+ (*cur)->disposing(pSource);
+ m_aInterfaces.erase(cur);
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+
+ class NodeListenerInfo
+ {
+ public:
+ typedef std::set<OUString> Pathes;
+
+ public:
+ NodeListenerInfo(INodeListener* pListener)
+ : m_pListener(pListener)
+ {
+ }
+
+ // path handling
+ Pathes const& pathList() const { return m_aPathes; }
+
+ void addPath(OUString const& sPath) const { m_aPathes.insert(sPath); }
+ void removePath(OUString const& sPath) const { m_aPathes.erase(sPath); }
+ //void removeChildPathes(OUString const& sPath);
+
+ // behave as pointer for use as a 'reference' class
+ INodeListener* get() const { return m_pListener; }
+ INodeListener* operator->() const { return get(); }
+ INodeListener& operator*() const { return *get(); }
+ // needed to allow if (info) ...
+ struct HasListener;
+ operator HasListener const*() const { return reinterpret_cast<HasListener*>(m_pListener); }
+
+ bool operator < (NodeListenerInfo const& aInfo) const
+ { return std::less<INodeListener*>()(m_pListener, aInfo.m_pListener); }
+
+ bool operator == (NodeListenerInfo const& aInfo) const
+ { return m_pListener == aInfo.m_pListener; }
+
+ bool operator > (NodeListenerInfo const& aInfo) const
+ { return aInfo.operator < (*this); }
+ bool operator >= (NodeListenerInfo const& aInfo) const
+ { return !operator<(aInfo); }
+ bool operator <= (NodeListenerInfo const& aInfo) const
+ { return !operator>(aInfo); }
+
+ bool operator != (NodeListenerInfo const& aInfo) const
+ { return !operator==(aInfo); }
+
+ private:
+ INodeListener* m_pListener;
+ mutable Pathes m_aPathes; // hack to be mutable as set element
+ };
+ class ConfigChangesBroadcasterImpl
+ {
+ public:
+ ConfigChangesBroadcasterImpl();
+ ~ConfigChangesBroadcasterImpl();
+
+ void add(OUString const& aName, INodeListener* pListener);
+ void remove(INodeListener* pListener);
+
+ void removed(OUString const& aPath, bool bRemovedFromModel, IConfigBroadcaster* pSource);
+
+ void dispatch(Change const& rBaseChange, OUString const& sChangeContext, sal_Bool _bError, IConfigBroadcaster* pSource);
+ void dispatch(TreeChangeList const& rList_, sal_Bool _bError, IConfigBroadcaster* pSource);
+ void disposing(IConfigBroadcaster* pSource);
+ private:
+ typedef BroadcastImplHelper<NodeListenerInfo> Listeners;
+ typedef Listeners::FullIterator InfoRef;
+ typedef std::multimap<OUString, InfoRef> PathMap;
+ Listeners m_aListeners;
+ PathMap m_aPathMap;
+ private:
+ void dispatchInner(INodeListener* pTarget, OUString const& sTargetPath, Change const& rBaseChange, OUString const& sChangeContext, sal_Bool _bError, IConfigBroadcaster* pSource);
+ void dispatchOuter(INodeListener* pTarget, OUString const& sTargetPath, Change const& rBaseChange, OUString const& sChangeContext, sal_Bool _bError, IConfigBroadcaster* pSource);
+ };
+
+ /////////////////////////////////////////////////////////////////////////
+ class ConfigMessageBroadcasterImpl
+ {
+ public:
+ void add(IMessageHandler* pListener);
+ void remove(IMessageHandler* pListener);
+
+ void dispatch(OUString const& _rNotifyReason, sal_Int32 _nNotificationId, IConfigBroadcaster* pSource);
+ void disposing(IConfigBroadcaster* pSource);
+ private:
+ typedef BroadcastImplHelper<IMessageHandler*> Listeners;
+ Listeners m_aListeners;
+ };
+
+ /////////////////////////////////////////////////////////////////////////
+ } // namespace
+} // namespace
+
+#endif // CONFIGMGR_API_EVENTHELPERS_HXX_
+
+
diff --git a/configmgr/source/api/confevents.cxx b/configmgr/source/api/confevents.cxx
new file mode 100644
index 000000000000..19dd9d8e4a7c
--- /dev/null
+++ b/configmgr/source/api/confevents.cxx
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * $RCSfile: confevents.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include "confevents.hxx"
+
+#ifndef CONFIGMGR_API_EVENTHELPERS_HXX_
+#include "confeventhelpers.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+namespace configmgr
+{
+ // class is still abstract, ITreeListener methods are still unimplemented
+ TreeListenerImpl::TreeListenerImpl(ITreeNotifier* aSource)
+ : mySource(aSource)
+ {
+ if (mySource) mySource->setListener(this);
+ }
+ TreeListenerImpl::~TreeListenerImpl()
+ {
+ if (mySource) mySource->setListener(0);
+ }
+
+ void TreeListenerImpl::disposing(ITreeNotifier* pSource)
+ {
+ OSL_ASSERT(pSource && pSource == mySource);
+ if (pSource == mySource)
+ mySource = 0;
+ }
+
+ ITreeNotifier* TreeListenerImpl::rebind(ITreeNotifier* aSource)
+ {
+ ITreeNotifier* aOldSource = mySource;
+ if (aSource != aOldSource)
+ {
+ if (mySource) mySource->setListener(0);
+ mySource = aSource;
+ if (mySource) mySource->setListener(this);
+ }
+ return aOldSource;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ using internal::ConfigChangesBroadcasterImpl;
+ using internal::ConfigMessageBroadcasterImpl;
+
+ /////////////////////////////////////////////////////////////////////////
+ class ConfigChangeBroadcaster::Impl
+ {
+ public:
+ Impl() : m_changes(), m_messages() {}
+
+ ConfigChangesBroadcasterImpl m_changes;
+ ConfigMessageBroadcasterImpl m_messages;
+ };
+
+ /////////////////////////////////////////////////////////////////////////
+ ConfigChangeBroadcaster::ConfigChangeBroadcaster(ITreeNotifier* aSource)
+ : TreeListenerImpl(aSource)
+ , pImpl(new Impl())
+ {
+ }
+
+ ConfigChangeBroadcaster::~ConfigChangeBroadcaster()
+ {
+ dispose();
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeBroadcaster::dispose()
+ {
+ unbind();
+
+ if (!pImpl) return;
+ pImpl->m_changes.disposing(this);
+ pImpl->m_messages.disposing(this);
+ delete pImpl, pImpl = 0;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // IConfigBroadcaster implementation
+ void ConfigChangeBroadcaster::addListener(OUString const& aName, INodeListener* pHandler)
+ { pImpl->m_changes.add(aName, pHandler); }
+
+ void ConfigChangeBroadcaster::removeListener(INodeListener* pHandler)
+ { pImpl->m_changes.remove(pHandler); }
+
+ void ConfigChangeBroadcaster::removeNode(OUString const& aPath, bool bRemovedFromModel)
+ { pImpl->m_changes.removed(aPath,bRemovedFromModel,this); }
+
+ void ConfigChangeBroadcaster::addHandler(IMessageHandler* pHandler)
+ { pImpl->m_messages.add(pHandler); }
+
+ void ConfigChangeBroadcaster::removeHandler(IMessageHandler* pHandler)
+ { pImpl->m_messages.remove(pHandler); }
+
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeBroadcaster::broadcast(TreeChangeList const& anUpdate, sal_Bool bError)
+ {
+ pImpl->m_changes.dispatch(anUpdate, bError, this);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // ITreeListener implementation
+ void ConfigChangeBroadcaster::changes(TreeChangeList const& rList_, sal_Bool bError_)
+ {
+ broadcast(rList_, bError_);;
+ }
+
+ void ConfigChangeBroadcaster::changes(sal_Int32 _nNotificationId,const OUString& _rNotifyReason)
+ {
+ pImpl->m_messages.dispatch(_rNotifyReason, _nNotificationId, this);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ class ConfigChangeMultiplexer::Impl
+ {
+ public:
+
+ Impl(OUString const& sBasePath_) : sBasePath(sBasePath_), m_changes(), m_messages() {}
+
+ OUString const sBasePath;
+ ConfigChangesBroadcasterImpl m_changes;
+ ConfigMessageBroadcasterImpl m_messages;
+ };
+
+ /////////////////////////////////////////////////////////////////////////
+ ConfigChangeMultiplexer::ConfigChangeMultiplexer(IConfigBroadcaster* pSource)
+ : m_pSource(pSource)
+ , pImpl(0)
+ {
+ if (m_pSource) m_pSource->addHandler(this);
+ }
+
+ ConfigChangeMultiplexer::ConfigChangeMultiplexer(OUString const& aBasePath, IConfigBroadcaster* pSource)
+ : m_pSource(pSource)
+ , pImpl(0)
+ {
+ bind(aBasePath,pSource);
+ }
+
+ ConfigChangeMultiplexer::~ConfigChangeMultiplexer()
+ {
+ dispose();
+ }
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::bind(OUString const& sNewPath, IConfigBroadcaster* pSource)
+ {
+ if (pImpl)
+ {
+ OSL_ASSERT(sNewPath == pImpl->sBasePath);
+ rebind(pSource);
+ }
+ else
+ {
+ pImpl = new Impl(sNewPath);
+ if (pSource)
+ m_pSource = pSource;
+ m_pSource->addListener(pImpl->sBasePath, this);
+ m_pSource->addHandler(this);
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::rebind(IConfigBroadcaster* pSource)
+ {
+ if (pSource != m_pSource)
+ {
+ unbind();
+ m_pSource = pSource;
+ if (m_pSource)
+ {
+ if (pImpl) m_pSource->addListener(pImpl->sBasePath, this);
+ m_pSource->addHandler(this);
+ }
+ }
+ }
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::unbind()
+ {
+ if (m_pSource)
+ {
+ if (pImpl) m_pSource->removeListener(this);
+ m_pSource->removeHandler(this);
+ }
+ m_pSource = 0;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ bool ConfigChangeMultiplexer::normalizePath(OUString& aName)
+ {
+ if (!pImpl) return false;
+
+ ConfigurationName aMyPath(pImpl->sBasePath);
+ ConfigurationName aPath(aName);
+ if (aPath.isRelative())
+ {
+ aName = aMyPath.composeWith(aPath).fullName();
+ return true;
+ }
+ else
+ {
+ bool ok = (aMyPath == aPath) || aPath.isNestedIn(aMyPath);
+
+ return ok;
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::broadcast(Change const& anUpdate, OUString const& aRelativePath, sal_Bool bError)
+ {
+ OSL_ENSURE(pImpl!=0, "Trying to broadcast on disconnected Notification Multiplexer");
+
+ OUString aContext( aRelativePath );
+ if (!normalizePath(aContext))
+ OSL_TRACE("Invalid path. Multiplexer may not walk subtrees correctly\n\r");
+
+ if (pImpl)
+ {
+ pImpl->m_changes.dispatch(anUpdate, aContext, bError, this);
+ }
+ }
+
+ void ConfigChangeMultiplexer::broadcast(Change const& anUpdate)
+ {
+ // do we need to append the local name ??
+ if (pImpl)
+ pImpl->m_changes.dispatch(anUpdate, pImpl->sBasePath, false, this);
+ }
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::dispose()
+ {
+ unbind();
+
+ if (!pImpl) return;
+ pImpl->m_changes.disposing(this);
+ pImpl->m_messages.disposing(this);
+ delete pImpl, pImpl = 0;
+ }
+
+ // IConfigListener implementation
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::disposing(IConfigBroadcaster* pSource)
+ {
+ OSL_ASSERT(pSource == m_pSource);
+ if (pSource == m_pSource)
+ unbind();
+ }
+
+ // INodeListener implementation
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource)
+ {
+ OSL_ASSERT(pImpl != 0);
+ OSL_VERIFY(pSource == m_pSource);
+ broadcast(aChange, aPath);
+ }
+ void ConfigChangeMultiplexer::nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource)
+ {
+ OSL_ASSERT(pImpl != 0);
+
+ if (pImpl)
+ {
+ OUString aContext( aPath );
+
+ // must be this base path or a child of it
+ OSL_ASSERT(!ConfigurationName(aPath).isRelative() || aPath.getLength() == 0);
+ OSL_ASSERT(aPath.getLength() == 0 ||
+ pImpl->sBasePath == aPath ||
+ ConfigurationName(pImpl->sBasePath).isNestedIn(aPath));
+ pImpl->m_changes.removed(aContext,true,this);
+ }
+ }
+
+ // IMessageHandler implementation
+ /////////////////////////////////////////////////////////////////////////
+ void ConfigChangeMultiplexer::message(const OUString& rNotifyReason, sal_Int32 nNotificationId, IConfigBroadcaster* pSource)
+ {
+ OSL_VERIFY(pSource == m_pSource);
+ if (pImpl)
+ pImpl->m_messages.dispatch(rNotifyReason, nNotificationId, this);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // IConfigBroadcaster implementation
+
+ void ConfigChangeMultiplexer::addListener(OUString const& aName, INodeListener* pHandler)
+ { pImpl->m_changes.add(aName, pHandler); }
+
+ void ConfigChangeMultiplexer::removeListener(INodeListener* pHandler)
+ { pImpl->m_changes.remove(pHandler); }
+
+ void ConfigChangeMultiplexer::removeNode(OUString const& aPath, bool bRemovedFromModel)
+ { pImpl->m_changes.removed(aPath,bRemovedFromModel,this); }
+
+ void ConfigChangeMultiplexer::addHandler(IMessageHandler* pHandler)
+ { pImpl->m_messages.add(pHandler); }
+
+ void ConfigChangeMultiplexer::removeHandler(IMessageHandler* pHandler)
+ { pImpl->m_messages.remove(pHandler); }
+
+ /////////////////////////////////////////////////////////////////////////
+ // ScreenedChangeMultiplexer
+ ScreenedChangeMultiplexer:: ScreenedChangeMultiplexer(IConfigBroadcaster* aSource)
+ : ConfigChangeMultiplexer()
+ , m_pScreeningChanges(0)
+ {
+ }
+
+ ScreenedChangeMultiplexer:: ScreenedChangeMultiplexer(TreeChangeList& aScreeningTree, IConfigBroadcaster* aSource)
+ : ConfigChangeMultiplexer(aScreeningTree.pathToRoot, aSource)
+ , m_pScreeningChanges(&aScreeningTree.root)
+ {
+ }
+
+ ScreenedChangeMultiplexer:: ScreenedChangeMultiplexer(ScreeningChange* aScreening, OUString const& aBasePath, IConfigBroadcaster* aSource)
+ : ConfigChangeMultiplexer(aBasePath, aSource)
+ , m_pScreeningChanges(aScreening)
+ {
+ }
+
+ void ScreenedChangeMultiplexer:: bind(TreeChangeList& aScreeningTree, IConfigBroadcaster* aSource)
+ {
+ bind(&aScreeningTree.root, aScreeningTree.pathToRoot, aSource);
+ }
+
+ void ScreenedChangeMultiplexer:: bind(ScreeningChange* aScreening, OUString const& aBasePath, IConfigBroadcaster* aSource)
+ {
+ unbind();
+ m_pScreeningChanges = aScreening;
+ ConfigChangeMultiplexer::bind(aBasePath, aSource);
+ }
+
+ void ScreenedChangeMultiplexer:: nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource)
+ {
+ // To do: filter with local changes herehere
+ if (&aChange != m_pScreeningChanges)
+ ConfigChangeMultiplexer::nodeChanged(aChange,aPath,pSource);
+ }
+
+ void ScreenedChangeMultiplexer:: nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource)
+ {
+ // To do: filter here
+ ConfigChangeMultiplexer::nodeDeleted(aPath,pSource);
+ }
+
+} // namespace
+
+
+
diff --git a/configmgr/source/api/confsvccomponent.cxx b/configmgr/source/api/confsvccomponent.cxx
new file mode 100644
index 000000000000..1eba8c196734
--- /dev/null
+++ b/configmgr/source/api/confsvccomponent.cxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * $RCSfile: confsvccomponent.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "confsvccomponent.hxx"
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef __SGI_STL_MAP
+#include <stl/map>
+#endif
+
+namespace configmgr {
+
+
+ ServiceComponentImpl::ServiceComponentImpl(ServiceInfo const* aInfo)
+ : ServiceImplBase(m_aMutex)
+ , m_aMutex()
+ , m_info(aInfo)
+ {
+ }
+
+ void ServiceComponentImpl::disposing()
+ {
+ ServiceImplBase::disposing();
+ }
+ void ServiceComponentImpl::checkAlive() throw (uno::RuntimeException)
+ {
+ checkAlive("Object was disposed");
+ }
+ void ServiceComponentImpl::checkAlive(OUString const& sMessage) throw (uno::RuntimeException)
+ {
+ if (rBHelper.bDisposed)
+ throw lang::DisposedException(sMessage, *this);
+ }
+
+ sal_Int32 ServiceComponentImpl::countServices(ServiceInfo const* aInfo)
+ {
+ AsciiServiceName const* p= aInfo ? aInfo->serviceNames : 0;
+ if (p == 0)
+ return 0;
+
+ sal_Int32 nCount = 0;
+ while (*p != 0)
+ {
+ ++nCount;
+ ++p;
+ }
+
+ return nCount;
+ }
+
+ // XTypeProvider
+ uno::Sequence<sal_Int8> ServiceComponentImpl::getStaticImplementationId(ServiceInfo const* pServiceInfo)
+ throw(uno::RuntimeException)
+ {
+ static osl::Mutex aMapMutex;
+ static std::map<ServiceInfo const*, ::cppu::OImplementationId> aIdMap;
+
+ osl::MutexGuard aMapGuard(aMapMutex);
+ return aIdMap[pServiceInfo].getImplementationId();
+ }
+
+ uno::Sequence<sal_Int8> SAL_CALL ServiceComponentImpl::getImplementationId()
+ throw(uno::RuntimeException)
+ {
+ return getStaticImplementationId(m_info);
+ }
+
+ // XServiceInfo
+ OUString SAL_CALL ServiceComponentImpl::getImplementationName( ) throw(uno::RuntimeException)
+ {
+ AsciiServiceName p= m_info ? m_info->implementationName : 0;
+
+ return p ? OUString::createFromAscii(p) : OUString();
+ }
+
+ sal_Bool SAL_CALL ServiceComponentImpl::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
+ {
+ AsciiServiceName const* p= m_info ? m_info->serviceNames : 0;
+ if (p == 0)
+ return false;
+
+ while (*p != 0)
+ {
+ if (0 == ServiceName.compareToAscii(*p))
+ return true;
+ ++p;
+ }
+
+ return false;
+ }
+
+ uno::Sequence< OUString > ServiceComponentImpl::getServiceNames(ServiceInfo const* pInfo ) throw(uno::RuntimeException)
+ {
+ sal_Int32 const nCount = countServices(pInfo);
+
+ uno::Sequence< OUString > aServices( nCount );
+
+ for(sal_Int32 i= 0; i < nCount; ++i)
+ aServices[i] = OUString::createFromAscii(pInfo->serviceNames[i]);
+
+ return aServices;
+ }
+
+ uno::Sequence< OUString > SAL_CALL ServiceComponentImpl::getSupportedServiceNames( ) throw(uno::RuntimeException)
+ {
+ return getServiceNames( m_info );
+ }
+
+ //ServiceComponentImpl::
+
+} // namespace configmgr
+
+
diff --git a/configmgr/source/api/makefile.mk b/configmgr/source/api/makefile.mk
new file mode 100644
index 000000000000..5703b6b3c4a9
--- /dev/null
+++ b/configmgr/source/api/makefile.mk
@@ -0,0 +1,102 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source$/inc
+PRJNAME=configmgr
+TARGET=api
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/encodename.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)$/confevents.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/cmdtools/makefile.mk b/configmgr/source/cmdtools/makefile.mk
new file mode 100644
index 000000000000..cf830dbe237e
--- /dev/null
+++ b/configmgr/source/cmdtools/makefile.mk
@@ -0,0 +1,121 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source
+
+PRJNAME=configmgr
+
+TARGET=configshutdown
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\"
+
+APPSTDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+
+APP1STDLIBS = $(APPSTDLIBS)
+
+.IF "$(GUI)"=="UNX"
+APP1TARGET= $(TARGET).bin
+.ELSE
+APP1TARGET= $(TARGET)
+.ENDIF
+
+APP1OBJS= \
+ $(SLO)$/configshutdown.obj
+
+.INCLUDE : target.mk
+
+#**************************************************************************
+# history:
+# $Log: not supported by cvs2svn $
+# 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/attributes.hxx b/configmgr/source/inc/attributes.hxx
new file mode 100644
index 000000000000..ffd7835d81e4
--- /dev/null
+++ b/configmgr/source/inc/attributes.hxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: attributes.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+#define _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+
+#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+/*----------------------------------------
+*
+* Attributlist implementation
+*
+*----------------------------------------*/
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+struct AttributeListImpl_impl;
+class AttributeListImpl : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList >
+{
+protected:
+ ~AttributeListImpl();
+
+public:
+ AttributeListImpl();
+ AttributeListImpl( const AttributeListImpl & );
+
+public:
+ virtual sal_Int16 SAL_CALL getLength(void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameByIndex(sal_Int16 i) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTypeByIndex(sal_Int16 i) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTypeByName(const ::rtl::OUString& aName) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValueByIndex(sal_Int16 i) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValueByName(const ::rtl::OUString& aName) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ void addAttribute( const ::rtl::OUString &sName , const ::rtl::OUString &sType , const ::rtl::OUString &sValue );
+ void clear();
+
+private:
+ struct AttributeListImpl_impl *m_pImpl;
+};
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+#endif // _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+
+
diff --git a/configmgr/source/inc/bootstrap.hxx b/configmgr/source/inc/bootstrap.hxx
new file mode 100644
index 000000000000..0273f79fd9a0
--- /dev/null
+++ b/configmgr/source/inc/bootstrap.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: bootstrap.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CONFIGMGR_BOOTSTRAP_HXX_
+#define CONFIGMGR_BOOTSTRAP_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+
+#ifndef _CONFIGMGR_COMMONTYPES_HXX_
+#include "commontypes.hxx"
+#endif
+
+namespace com { namespace sun { namespace star {
+
+ namespace uno { template <class> class Reference; }
+ namespace lang { class XMultiServiceFactory; }
+
+} } }
+
+#include <rtl/ustring.hxx>
+
+namespace configmgr
+{
+ namespace css = ::com::sun::star;
+ namespace uno = css::uno;
+ namespace lang = css::lang;
+ using ::rtl::OUString;
+
+ class IConfigSession;
+
+ class ConnectionSettings
+ {
+ OUString m_sSettingsFile;
+ public:
+ ConnectionSettings();
+ explicit
+ ConnectionSettings(OUString const& aSettingsFile);
+
+
+ /** create a connection with the current settings. If the user name provided in _rSecurityOverride
+ is not empty, the security override will be used (if applicable), else it will be ignored
+ */
+ IConfigSession* createConnection(uno::Reference<lang::XMultiServiceFactory> const& aServiceMgr,
+ const SettingsOverride& _rSettings) const;
+ };
+
+}
+
+#endif // CONFIGMGR_BOOTSTRAP_HXX_
+
+
diff --git a/configmgr/source/inc/commontypes.hxx b/configmgr/source/inc/commontypes.hxx
new file mode 100644
index 000000000000..ff89fc214c20
--- /dev/null
+++ b/configmgr/source/inc/commontypes.hxx
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * $RCSfile: commontypes.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_COMMONTYPES_HXX_
+#define _CONFIGMGR_COMMONTYPES_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+//==========================================================================
+//= IInterface
+//==========================================================================
+/** abstract base class for objects which may be aquired by ORef's
+ (in opposite to the IReference, classes deriving from this IInterface can be
+ derived from XInterface, too)
+*/
+class IInterface
+{
+public:
+ virtual void SAL_CALL acquire( ) throw () = 0;
+ virtual void SAL_CALL release( ) throw () = 0;
+};
+
+//==========================================================================
+//= SettingsOverride
+//==========================================================================
+DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Any, SettingsOverride );
+
+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())
+ {
+ }
+};
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+#endif // _CONFIGMGR_COMMONTYPES_HXX_
+
+
diff --git a/configmgr/source/inc/confapifactory.hxx b/configmgr/source/inc/confapifactory.hxx
new file mode 100644
index 000000000000..067634cca328
--- /dev/null
+++ b/configmgr/source/inc/confapifactory.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: confapifactory.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CONFIGMGR_API_FACTORY_HXX_
+#define CONFIGMGR_API_FACTORY_HXX_
+
+namespace com { namespace sun { namespace star {
+ namespace uno
+ {
+ class XInterface;
+ template <class> class Reference;
+ }
+ namespace lang
+ {
+ class XMultiServiceFactory;
+ }
+} } }
+
+namespace configmgr
+{
+ namespace css = ::com::sun::star;
+ namespace uno = css::uno;
+ namespace lang = css::lang;
+ struct ServiceInfo;
+
+ // instantiation
+ uno::Reference< uno::XInterface > SAL_CALL instantiateProvider(uno::Reference< lang::XMultiServiceFactory > const& rServiceManager );
+ uno::Reference< uno::XInterface > SAL_CALL instantiateReadAccess(uno::Reference< lang::XMultiServiceFactory > const& rServiceManager );
+ uno::Reference< uno::XInterface > SAL_CALL instantiateUpdateAccess(uno::Reference< lang::XMultiServiceFactory > const& rServiceManager );
+
+ uno::Reference< uno::XInterface > SAL_CALL instantiateConfigRegistry(uno::Reference< lang::XMultiServiceFactory > const& rServiceManager );
+
+ // Import / export
+ uno::Reference< uno::XInterface > SAL_CALL instantiateDataExport(uno::Reference< lang::XMultiServiceFactory > const& rServiceManager );
+ const ServiceInfo* getDataExportServiceInfo();
+
+ uno::Reference< uno::XInterface > SAL_CALL instantiateDataImport(uno::Reference< lang::XMultiServiceFactory > const& rServiceManager );
+ const ServiceInfo* getDataImportServiceInfo();
+
+ // service infos
+ const ServiceInfo* getConfigurationRegistryServiceInfo();
+
+} // namespace configmgr
+
+#endif // CONFIGMGR_API_FACTORY_HXX_
+
+
diff --git a/configmgr/source/inc/confevents.hxx b/configmgr/source/inc/confevents.hxx
new file mode 100644
index 000000000000..44deb33fd0b3
--- /dev/null
+++ b/configmgr/source/inc/confevents.hxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: confevents.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CONFIGMGR_API_EVENTS_HXX_
+#define CONFIGMGR_API_EVENTS_HXX_
+
+#include "cmtreemodel.hxx"
+namespace rtl { class OUString; }
+
+namespace configmgr
+{
+ using ::rtl::OUString;
+
+ // class is still abstract, ITreeListener methods are still unimplemented
+ class TreeListenerImpl : private ITreeListener
+ {
+ ITreeNotifier* mySource;
+ public:
+ explicit TreeListenerImpl(ITreeNotifier* aSource = 0);
+ virtual ~TreeListenerImpl();
+
+ ITreeNotifier* rebind(ITreeNotifier* aSource);
+ ITreeNotifier* unbind() { return rebind(0); }
+ protected:
+ virtual void disposing(ITreeNotifier* pSource);
+ private:
+ TreeListenerImpl(TreeListenerImpl&);
+ void operator=(TreeListenerImpl&);
+ };
+
+ struct IConfigBroadcaster;
+ struct IConfigListener
+ {
+ virtual void disposing(IConfigBroadcaster* pSource) = 0;
+ };
+ struct INodeListener : IConfigListener
+ {
+ virtual void nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource) = 0;
+ virtual void nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource) = 0;
+ };
+ struct IMessageHandler: IConfigListener
+ {
+ virtual void message(const OUString& rNotifyReason, sal_Int32 nNotificationId, IConfigBroadcaster* pSource) = 0;
+ };
+
+ struct IConfigBroadcaster
+ {
+ protected:
+ IConfigBroadcaster() {}
+ ~IConfigBroadcaster() {}
+ public:
+ virtual void addListener(OUString const& aName, INodeListener* pListener) = 0;
+ virtual void removeListener(INodeListener* pListener) = 0;
+
+ virtual void removeNode(OUString const& aPath, bool bRemovedFromModel = false) = 0;
+
+ virtual void addHandler(IMessageHandler* pHandler) = 0;
+ virtual void removeHandler(IMessageHandler* pHandler) = 0;
+ };
+
+ class ConfigChangeBroadcaster : public TreeListenerImpl, public IConfigBroadcaster
+ {
+ class Impl;
+ Impl* pImpl;
+ public:
+ ConfigChangeBroadcaster(ITreeNotifier* aSource = 0);
+ virtual ~ConfigChangeBroadcaster();
+
+ void rebind(ITreeNotifier* aSource);
+
+ void broadcast(TreeChangeList const& anUpdate, sal_Bool bError = false);
+
+ public:
+ // IConfigBroadcaster implementation
+ void addListener(OUString const& aName, INodeListener* );
+ void removeListener(INodeListener*);
+
+ void removeNode(OUString const& aPath, bool bRemovedFromModel = false);
+
+ void addHandler(IMessageHandler* );
+ void removeHandler(IMessageHandler* );
+
+ void dispose();
+ protected:
+ // ITreeListener implementation
+ virtual void changes(TreeChangeList const& , sal_Bool _bError);
+ virtual void changes(sal_Int32 _nNotificationId,const ::rtl::OUString& _rNotifyReason);
+ };
+
+ class ConfigChangeMultiplexer : public IConfigBroadcaster, private INodeListener, private IMessageHandler
+ {
+ class Impl;
+ Impl* pImpl;
+ IConfigBroadcaster* m_pSource;
+ public:
+ ConfigChangeMultiplexer(IConfigBroadcaster* aSource = 0);
+ ConfigChangeMultiplexer(OUString const& aBasePath, IConfigBroadcaster* aSource);
+ virtual ~ConfigChangeMultiplexer();
+
+ void bind(OUString const& aBasePath, IConfigBroadcaster* aSource = 0);
+ void rebind(IConfigBroadcaster* aSource);
+ void unbind();
+
+ void broadcast(Change const& anUpdate, OUString const& aRelativePath, sal_Bool bError = false);
+ void broadcast(Change const& anUpdate);
+
+ public:
+ // IConfigBroadcaster implementation
+ void addListener(OUString const& aName, INodeListener* );
+ void removeListener(INodeListener*);
+
+ void removeNode(OUString const& aPath, bool bRemovedFromModel = false);
+
+ void addHandler(IMessageHandler* );
+ void removeHandler(IMessageHandler* );
+
+ void dispose();
+ protected:
+ bool normalizePath(OUString& aPath);
+
+ // IConfigListener implementation
+ virtual void disposing(IConfigBroadcaster* pSource);
+
+ // INodeListener implementation
+ virtual void nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource);
+ virtual void nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource);
+
+ // IMessageHandler implementation
+ virtual void message(const OUString& rNotifyReason, sal_Int32 nNotificationId, IConfigBroadcaster* pSource);
+ };
+
+ class ScreenedChangeMultiplexer : public ConfigChangeMultiplexer
+ {
+ typedef SubtreeChange ScreeningChange;
+ ScreeningChange* m_pScreeningChanges;
+ public:
+ ScreenedChangeMultiplexer(IConfigBroadcaster* aSource = 0);
+ ScreenedChangeMultiplexer(TreeChangeList& aScreeningTree, IConfigBroadcaster* aSource);
+ ScreenedChangeMultiplexer(ScreeningChange* aScreening, OUString const& aBasePath, IConfigBroadcaster* aSource);
+
+ void bind(TreeChangeList& aScreeningTree, IConfigBroadcaster* aSource = 0);
+ void bind(ScreeningChange* aScreening, OUString const& aBasePath, IConfigBroadcaster* aSource = 0);
+
+ protected:
+ virtual void nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource);
+ virtual void nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource);
+ };
+} // namespace
+
+#endif // CONFIGMGR_API_EVENTS_HXX_
+
+
+
diff --git a/configmgr/source/inc/confsvccomponent.hxx b/configmgr/source/inc/confsvccomponent.hxx
new file mode 100644
index 000000000000..218ddb94c7f1
--- /dev/null
+++ b/configmgr/source/inc/confsvccomponent.hxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * $RCSfile: confsvccomponent.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:40 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CONFIGMGR_API_SVCCOMPONENT_HXX_
+#define CONFIGMGR_API_SVCCOMPONENT_HXX_
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/Mutex.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+namespace configmgr {
+
+ namespace css = ::com::sun::star;
+ namespace uno = css::uno;
+ namespace lang = css::lang;
+ using ::rtl::OUString;
+
+ typedef sal_Char const * AsciiServiceName;
+ struct ServiceInfo
+ {
+ AsciiServiceName implementationName;
+ AsciiServiceName const * serviceNames;
+ };
+
+ typedef ::cppu::WeakComponentImplHelper1< lang::XServiceInfo > ServiceImplBase;
+
+ class ServiceComponentImpl
+ : public ServiceImplBase
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+ ServiceInfo const* const m_info;
+ public:
+ ServiceComponentImpl(ServiceInfo const* aInfo);
+
+ // XTypeProvider
+ virtual uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(uno::RuntimeException);
+ //virtual uno::Sequence<uno::Type> SAL_CALL getTypes( ) throw(uno::RuntimeException) = 0;
+
+ // 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);
+
+ // Component Helper - force override
+ virtual void SAL_CALL disposing() = 0;
+ // Component Helper - check object state
+ virtual void checkAlive() throw (uno::RuntimeException);
+ void checkAlive(char const* message) throw (uno::RuntimeException)
+ { checkAlive( OUString::createFromAscii(message) ); }
+ void checkAlive(OUString const& message) throw (uno::RuntimeException);
+
+ // Extra helpers
+ static sal_Int32 countServices(ServiceInfo const* aInfo);
+ static uno::Sequence< OUString > getServiceNames(ServiceInfo const* aInfo) throw(uno::RuntimeException);
+ static uno::Sequence<sal_Int8> getStaticImplementationId(ServiceInfo const* pServiceInfo) throw(uno::RuntimeException);
+
+ private: // no implementation
+ ServiceComponentImpl(ServiceComponentImpl&);
+ void operator=(ServiceComponentImpl&);
+ };
+
+} // namespace configmgr
+
+#endif // CONFIGMGR_API_SVCCOMPONENT_HXX_
+
+
diff --git a/configmgr/source/inc/filehelper.hxx b/configmgr/source/inc/filehelper.hxx
new file mode 100644
index 000000000000..fb9d6f3282a1
--- /dev/null
+++ b/configmgr/source/inc/filehelper.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $RCSfile: filehelper.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_FILEHELPER_HXX_
+#define _CONFIGMGR_FILEHELPER_HXX_
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+
+namespace configmgr
+{
+ class FileHelper
+ {
+ public:
+
+ static sal_Int32 createBackupRemoveAndRename(
+ const rtl::OUString& _aFromURL, const rtl::OUString &_aToURL);
+
+ static sal_Int32 tryToRemoveFile(const rtl::OUString& _aURL);
+
+ static rtl::OUString createOSLErrorString(osl::FileBase::RC eError);
+ };
+} // namespace configmgr
+
+#endif
diff --git a/configmgr/source/inc/oslstream.hxx b/configmgr/source/inc/oslstream.hxx
new file mode 100644
index 000000000000..939227665245
--- /dev/null
+++ b/configmgr/source/inc/oslstream.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * $RCSfile: oslstream.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_OSLSTREAM_HXX_
+#define _CONFIGMGR_OSLSTREAM_HXX_
+
+#ifndef _OSL_MUTEX_HXX_ //autogen wg. ::osl::Mutex
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#ifndef _UTL_UNO3_HXX_
+#include <unotools/uno3.hxx>
+#endif
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+
+
+namespace configmgr
+{
+ namespace stario = ::com::sun::star::io;
+ namespace staruno = ::com::sun::star::uno;
+
+//==================================================================
+// FmUnoIOStream,
+// stream zum schreiben un lesen von Daten, basieren auf File
+//==================================================================
+ typedef ::cppu::WeakImplHelper1<stario::XInputStream> InputStreamWrapper_Base;
+ // needed for some compilers
+class OSLInputStreamWrapper : public InputStreamWrapper_Base
+{
+ ::osl::Mutex m_aMutex;
+ ::osl::File* m_pFile;
+ sal_Bool m_bFileOwner : 1;
+
+public:
+ OSLInputStreamWrapper(::osl::File& _rStream);
+ OSLInputStreamWrapper(::osl::File* pStream, sal_Bool bOwner=sal_False);
+ virtual ~OSLInputStreamWrapper();
+
+// UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OSLInputStreamWrapper, InputStreamWrapper_Base);
+
+// stario::XInputStream
+ virtual sal_Int32 SAL_CALL readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
+ virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available() throw(stario::NotConnectedException, staruno::RuntimeException);
+ virtual void SAL_CALL closeInput() throw(stario::NotConnectedException, staruno::RuntimeException);
+};
+
+//==================================================================
+// FmUnoOutStream,
+// Datensenke fuer Files
+//==================================================================
+typedef ::cppu::WeakImplHelper1<stario::XOutputStream> OutputStreamWrapper_Base;
+ // needed for some compilers
+class OSLOutputStreamWrapper : public OutputStreamWrapper_Base
+{
+ ::osl::File& rFile;
+
+public:
+ OSLOutputStreamWrapper(::osl::File& _rFile) :rFile(_rFile) { }
+
+// UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OSLOutputStreamWrapper, OutputStreamWrapper_Base);
+
+// stario::XOutputStream
+ virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
+ virtual void SAL_CALL flush() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
+ virtual void SAL_CALL closeOutput() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
+};
+
+} // namespace configmgr
+
+#endif // _CONFIGMGR_OSLSTREAM_HXX_
+
+
+
diff --git a/configmgr/source/inc/strdecl.hxx b/configmgr/source/inc/strdecl.hxx
new file mode 100644
index 000000000000..154d11f631f3
--- /dev/null
+++ b/configmgr/source/inc/strdecl.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * $RCSfile: strdecl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CONFIGMGR_STRDECL_HXX_
+#define _CONFIGMGR_STRDECL_HXX_
+
+#ifndef _CONFIGMGR_STRINGS_HXX_
+#include "strings.hxx"
+#endif
+
+//.........................................................................
+namespace configmgr
+{
+//.........................................................................
+
+// extern declaration for predefined strings, uncompleted
+ DECLARE_CONSTASCII_USTRING(TAG_VALUE);
+ DECLARE_CONSTASCII_USTRING(TAG_USERVALUE);
+ DECLARE_CONSTASCII_USTRING(TAG_VALUE_ITEM);
+ DECLARE_CONSTASCII_USTRING(TAG_DEFAULT_ITEM);
+ DECLARE_CONSTASCII_USTRING(TAG_NODEFAULT);
+ DECLARE_CONSTASCII_USTRING(TAG_DEFAULT);
+ DECLARE_CONSTASCII_USTRING(TAG_DEFAULTVALUE);
+ DECLARE_CONSTASCII_USTRING(TAG_DATA);
+
+ DECLARE_CONSTASCII_USTRING(TYPE_BOOLEAN);
+ DECLARE_CONSTASCII_USTRING(TYPE_SHORT);
+ DECLARE_CONSTASCII_USTRING(TYPE_INT);
+ DECLARE_CONSTASCII_USTRING(TYPE_LONG);
+ DECLARE_CONSTASCII_USTRING(TYPE_DOUBLE);
+ DECLARE_CONSTASCII_USTRING(TYPE_STRING);
+ DECLARE_CONSTASCII_USTRING(TYPE_BINARY);
+ DECLARE_CONSTASCII_USTRING(TYPE_SET);
+ DECLARE_CONSTASCII_USTRING(TYPE_GROUP);
+
+ DECLARE_CONSTASCII_USTRING(ATTR_ENCODING_HEX);
+ DECLARE_CONSTASCII_USTRING(ATTR_NAME);
+ DECLARE_CONSTASCII_USTRING(ATTR_TYPE);
+ DECLARE_CONSTASCII_USTRING(ATTR_GROUP);
+ DECLARE_CONSTASCII_USTRING(ATTR_DERIVED);
+ DECLARE_CONSTASCII_USTRING(ATTR_INSTANCE);
+ DECLARE_CONSTASCII_USTRING(ATTR_ENCODING);
+ DECLARE_CONSTASCII_USTRING(ATTR_MODE);
+ DECLARE_CONSTASCII_USTRING(ATTR_PATH);
+ DECLARE_CONSTASCII_USTRING(ATTR_DERIVED_LIST);
+ DECLARE_CONSTASCII_USTRING(ATTR_VALUE_ADD);
+ DECLARE_CONSTASCII_USTRING(ATTR_VALUE_REMOVE);
+
+ DECLARE_CONSTASCII_USTRING(PARAM_OBJECT);
+ DECLARE_CONSTASCII_USTRING(PARAM_NAME);
+ DECLARE_CONSTASCII_USTRING(PARAM_ISNEWOBJECT);
+
+ DECLARE_CONSTASCII_USTRING(XML_CDATA);
+} // namespace configmgr
+#endif
+
diff --git a/configmgr/source/inc/strings.hxx b/configmgr/source/inc/strings.hxx
new file mode 100644
index 000000000000..9921b2efc597
--- /dev/null
+++ b/configmgr/source/inc/strings.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_STRINGS_HXX_
+#define _CONFIGMGR_STRINGS_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+
+//.........................................................................
+namespace configmgr
+{
+//.........................................................................
+
+struct UStringDescription
+{
+ const sal_Char* m_pZeroTerminatedName;
+ sal_Int32 m_nLen;
+ rtl_TextEncoding m_encoding;
+
+ UStringDescription(const sal_Char* _pName, sal_Int32 _nLen, rtl_TextEncoding _encoding)
+ {
+ m_pZeroTerminatedName = _pName;
+ m_nLen = _nLen;
+ m_encoding = _encoding;
+ m_aString = ::rtl::OUString(_pName, _nLen, _encoding);
+ }
+ operator ::rtl::OUString() const {
+ return m_aString;
+ }
+
+private:
+ rtl::OUString m_aString;
+ UStringDescription();
+};
+
+#define DECLARE_CONSTASCII_USTRING(name) \
+ extern ::configmgr::UStringDescription name
+
+#define IMPLEMENT_CONSTASCII_USTRING(name, asciivalue) \
+ ::configmgr::UStringDescription name(RTL_CONSTASCII_USTRINGPARAM(asciivalue))
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif _CONFIGMGR_STRINGS_HXX_
+
diff --git a/configmgr/source/inc/tracer.hxx b/configmgr/source/inc/tracer.hxx
new file mode 100644
index 000000000000..27eba4317f86
--- /dev/null
+++ b/configmgr/source/inc/tracer.hxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * $RCSfile: tracer.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_TRACER_HXX_
+#define _CONFIGMGR_TRACER_HXX_
+
+#if defined(DEBUG) || defined(_DEBUG)
+#define CFG_ENABLE_TRACING
+#endif
+
+#ifdef CFG_ENABLE_TRACING
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#include <rtl/string.hxx>
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#define OUSTRING2ASCII(rtlOUString) ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ASCII_US).getStr()
+
+#define CFG_TRACE_INFO OTraceIndent aIndent; OConfigTracer::traceInfo
+#define CFG_TRACE_WARNING OTraceIndent aIndent; OConfigTracer::traceWarning
+#define CFG_TRACE_ERROR OTraceIndent aIndent; OConfigTracer::traceError
+#define CFG_TRACE_INFO_NI OConfigTracer::traceInfo
+#define CFG_TRACE_WARNING_NI OConfigTracer::traceWarning
+#define CFG_TRACE_ERROR_NI OConfigTracer::traceError
+
+#define CFG_TRACE_TO_DEVICE OConfigTracer::traceToVirtualDevice
+
+namespace configmgr
+{
+
+struct OTracerSetup;
+class OConfigTracer
+{
+ friend class OTraceIndent;
+
+protected:
+ static ::osl::Mutex s_aMutex;
+ static OTracerSetup* s_pImpl;
+
+private:
+ OConfigTracer(); // never implemented, no instantiation of this class allowed, only static members
+
+public:
+ static void traceInfo(const sal_Char* _pFormat, ...);
+ static void traceWarning(const sal_Char* _pFormat, ...);
+ static void traceError(const sal_Char* _pFormat, ...);
+
+ static void traceToVirtualDevice(const sal_Char* _pDeviceName, const sal_Char* _pFormat, ...);
+
+ static ::rtl::OString getTimeStamp();
+
+protected:
+ static void implTrace(const sal_Char* _pType, const sal_Char* _pFormat, va_list args);
+
+ static void inc();
+ static void dec();
+
+ static void indent();
+
+ static void ensureData();
+ static void ensureInitalized();
+};
+
+class OTraceIndent
+{
+public:
+ OTraceIndent() { OConfigTracer::inc(); }
+ ~OTraceIndent() { OConfigTracer::dec(); }
+};
+
+} // namespace configmgr
+
+#else // !(defined(DEBUG) || defined(_DEBUG))
+
+#include <stdio.h>
+
+#define OUSTRING2ASCII(rtlOUString) "nothing"
+
+#define CFG_TRACE_INFO 1 ? (0) : printf
+#define CFG_TRACE_WARNING 1 ? (0) : printf
+#define CFG_TRACE_ERROR 1 ? (0) : printf
+#define CFG_TRACE_INFO_NI 1 ? (0) : printf
+#define CFG_TRACE_WARNING_NI 1 ? (0) : printf
+#define CFG_TRACE_ERROR_NI 1 ? (0) : printf
+#define CFG_TRACE_TO_DEVICE 1 ? (0) : printf
+
+#endif // (defined(DEBUG) || defined(_DEBUG))
+
+#endif // _CONFIGMGR_TRACER_HXX_
+
+//**************************************************************************
+// history:
+// $Log: not supported by cvs2svn $
+// 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
new file mode 100644
index 000000000000..70b21d21b23e
--- /dev/null
+++ b/configmgr/source/inc/treeactions.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: treeactions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_TREEACTIONS_HXX_
+#define _CONFIGMGR_TREEACTIONS_HXX_
+
+#ifndef CONFIGMGR_CMTREEMODEL_HXX
+#include "cmtreemodel.hxx"
+#endif
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+//==========================================================================
+//= OChangeActionCounter
+//==========================================================================
+/** collects meta data about a changes tree
+*/
+struct OChangeActionCounter : public ChangeTreeAction
+{
+ sal_Int32 nValues, nAdds, nAddUsers, nRemoves;
+ sal_Bool bDifferentSetActionLevels;
+
+ OChangeActionCounter() :nValues(0), nAdds(0), nAddUsers(0), nRemoves(0), bDifferentSetActionLevels(sal_False) { }
+
+ virtual void handle(ValueChange const& aValueNode) { ++nValues; }
+ virtual void handle(AddNode const& aAddNode); // moved to
+ virtual void handle(RemoveNode const& aRemoveNode) { ++nRemoves; }
+ virtual void handle(SubtreeChange const& aSubtree)
+ {
+ sal_Int32 nOldAdds(nAdds), nOldRemoves(nRemoves);
+ applyToChildren(aSubtree);
+ if ( ( nOldAdds
+ && (nAdds > nOldAdds)
+ )
+ || ( nOldRemoves
+ && (nRemoves > nOldRemoves)
+ )
+ )
+ bDifferentSetActionLevels = sal_True;
+ }
+};
+
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+#endif // _CONFIGMGR_TREEACTIONS_HXX_
+
+
diff --git a/configmgr/source/inc/typeconverter.hxx b/configmgr/source/inc/typeconverter.hxx
new file mode 100644
index 000000000000..7c72df9c2587
--- /dev/null
+++ b/configmgr/source/inc/typeconverter.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeconverter.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CONFIGMGR_TYPECONVERTER_HXX
+#define CONFIGMGR_TYPECONVERTER_HXX
+
+#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
+#include <com/sun/star/script/XTypeConverter.hpp>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+namespace configmgr
+{
+ namespace staruno = ::com::sun::star::uno;
+ namespace starscript = ::com::sun::star::script;
+
+ // UNO Type handling
+ staruno::Type getSequenceElementType(staruno::Type const& rSequenceType);
+
+ staruno::Type getBasicType(staruno::Type const& rType, bool& bSequence);
+ inline
+ staruno::Type getBasicType(staruno::Type const& rType)
+ { bool dummy; return getBasicType(rType,dummy); }
+
+ // Any Conversion
+ staruno::Any toAny(const staruno::Reference< starscript::XTypeConverter >& xTypeConverter, const ::rtl::OUString& _rValue,const staruno::TypeClass& _rTypeClass) throw( starscript::CannotConvertException );
+ rtl::OUString toString(const staruno::Reference< starscript::XTypeConverter >& xTypeConverter, const staruno::Any& rValue) throw( starscript::CannotConvertException );
+
+ // Type conversion
+ staruno::TypeClass toTypeClass(const ::rtl::OUString& _rType);
+ ::rtl::OUString toTypeName(const staruno::TypeClass& _rTypeClass);
+
+ staruno::Type toType(const ::rtl::OUString& _rsType);
+ staruno::Type toListType(const ::rtl::OUString& _rsElementType);
+ ::rtl::OUString toTypeName(const staruno::Type& _rType);
+
+ inline
+ staruno::Type toType(const ::rtl::OUString& _rsSimpleType, bool isList)
+ {
+ return isList ? toListType(_rsSimpleType) : toType(_rsSimpleType);
+ }
+
+ inline staruno::Type getBinaryType() { return ::getCppuType(static_cast<staruno::Sequence<sal_Int8> const*>(0)); }
+
+
+} // namespace configmgr
+
+#endif /* CONFIGMGR_TYPECONVERTER_HXX */
diff --git a/configmgr/source/misc/configunoreg.cxx b/configmgr/source/misc/configunoreg.cxx
new file mode 100644
index 000000000000..ad01d187abd9
--- /dev/null
+++ b/configmgr/source/misc/configunoreg.cxx
@@ -0,0 +1,490 @@
+/*************************************************************************
+ *
+ * $RCSfile: configunoreg.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _UNO_LBNAMES_H_
+#include <uno/lbnames.h>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef CONFIGMGR_API_FACTORY_HXX_
+#include "confapifactory.hxx"
+#endif
+
+#ifndef CONFIGMGR_API_SVCCOMPONENT_HXX_
+#include "confsvccomponent.hxx"
+#endif
+#ifndef CONFIGMGR_API_PROVIDER_HXX_
+#include "confprovider.hxx"
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+
+/********************************************************************************************/
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using configmgr::ServiceInfo;
+using configmgr::AsciiServiceName;
+
+#define THISREF() static_cast< ::cppu::OWeakObject* >(this)
+
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL * createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames
+ );
+
+// ***************************************************************************************
+
+namespace configmgr
+{
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::cppu;
+ using namespace ::osl;
+
+//=======================================================================================
+//= OProviderFactory
+//=======================================================================================
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XSingleServiceFactory > OProviderFactory_Base;
+ /** a special factory for the configuration provider, which implements some kind of
+ "shared multiple instances" factory.
+ */
+ class OProviderFactory : public OProviderFactory_Base
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+ ::cppu::ComponentInstantiation m_pObjectCreator;
+ Reference< XMultiServiceFactory > m_xORB;
+ Reference< XInterface > m_xDefaultProvider;
+
+ typedef ::com::sun::star::uno::WeakReference< XInterface > ProviderReference;
+ DECLARE_STL_USTRINGACCESS_MAP(ProviderReference, UserSpecificProvider);
+ UserSpecificProvider m_aUserProvider;
+
+ public:
+ OProviderFactory(
+ const Reference< XMultiServiceFactory >& _rxORB,
+ ::cppu::ComponentInstantiation _pObjectCreator);
+
+ virtual Reference< XInterface > SAL_CALL createInstance( ) throw(Exception, RuntimeException);
+ virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
+
+ Reference< XInterface > createProvider();
+ Reference< XInterface > createProviderWithArguments(const Sequence< Any >& _rArguments);
+
+ protected:
+ void ensureDefaultProvider();
+ };
+
+ //=======================================================================================
+ //= OProviderFactory
+ //=======================================================================================
+ //---------------------------------------------------------------------------------------
+ OProviderFactory::OProviderFactory(const Reference< XMultiServiceFactory >& _rxORB, ::cppu::ComponentInstantiation _pObjectCreator)
+ :m_pObjectCreator(_pObjectCreator)
+ ,m_xORB(_rxORB)
+ {
+ }
+
+ //---------------------------------------------------------------------------------------
+ void OProviderFactory::ensureDefaultProvider()
+ {
+ MutexGuard aGuard(m_aMutex);
+ if (m_xDefaultProvider.is())
+ return;
+ m_xDefaultProvider = (*m_pObjectCreator)(m_xORB);
+
+ // initialize it with an empty sequence, thus we ensure the provider establishes it's connection
+ Reference< XInitialization > xProvInit(m_xDefaultProvider, UNO_QUERY);
+ if (xProvInit.is())
+ xProvInit->initialize(Sequence< Any >());
+
+ // TODO : we need direct access to the provider implementation. This way we won't need the XInitialization
+ // interface, and we don't need this weird behaviour of initializing with an empty argument sequence
+ }
+
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > OProviderFactory::createProvider()
+ {
+ MutexGuard aGuard(m_aMutex);
+ ensureDefaultProvider();
+ return m_xDefaultProvider;
+ }
+
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > OProviderFactory::createProviderWithArguments(const Sequence< Any >& _rArguments)
+ {
+ MutexGuard aGuard(m_aMutex);
+ ::rtl::OUString sUser;
+ // #78409
+ // if a provider is queried with a password, we always create a new instance for him,
+ // as don't wan't to the passwords for the user.
+ ::rtl::OUString sPassword;
+ bool bPasswordUsed = false;
+
+ const Any* pArguments = _rArguments.getConstArray();
+ PropertyValue aCurrentArg;
+ for (sal_Int32 i=0; i<_rArguments.getLength(); ++i, ++pArguments)
+ {
+ if (!((*pArguments) >>= aCurrentArg))
+ throw IllegalArgumentException(::rtl::OUString::createFromAscii("Arguments have to be com.sun.star.beans.PropertyValue's."), NULL, i);
+ if (0 == aCurrentArg.Name.compareToAscii("user"))
+ {
+ if (!(aCurrentArg.Value >>= sUser) || !sUser.getLength())
+ throw IllegalArgumentException(::rtl::OUString::createFromAscii("The user name specified is invalid."), NULL, i);
+ }
+
+ // sesions which query for a password are always one instance
+ if (0 == aCurrentArg.Name.compareToAscii("password"))
+ {
+ bPasswordUsed = true;
+ if (!(aCurrentArg.Value >>= sPassword))
+ throw IllegalArgumentException(::rtl::OUString::createFromAscii("The password specified is invalid."), NULL, i);
+ }
+ }
+
+ Reference< XInterface > xThisUsersProvider;
+ if (!bPasswordUsed)
+ {
+ UserSpecificProviderIterator aExistentProvider = m_aUserProvider.find(sUser);
+ if (m_aUserProvider.end() != aExistentProvider)
+ xThisUsersProvider = aExistentProvider->second;
+ }
+
+ if (!xThisUsersProvider.is())
+ {
+ xThisUsersProvider = (*m_pObjectCreator)(m_xORB);
+ if (!bPasswordUsed)
+ m_aUserProvider[sUser] = xThisUsersProvider;
+
+ // initialize it
+ Reference< XInitialization > xProvInit(xThisUsersProvider, UNO_QUERY);
+ if (xProvInit.is())
+ xProvInit->initialize(_rArguments);
+ }
+
+ return xThisUsersProvider;
+ }
+
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OProviderFactory::createInstance( ) throw(Exception, RuntimeException)
+ {
+ // default provider
+ return createProvider();
+ }
+
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OProviderFactory::createInstanceWithArguments( const Sequence< Any >& _rArguments ) throw(Exception, RuntimeException)
+ {
+ return createProviderWithArguments(_rArguments);
+ }
+
+ //=======================================================================================
+ Reference< XSingleServiceFactory > SAL_CALL createProviderFactory(
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames
+ )
+ {
+ OSL_ENSHURE(0 == rComponentName.compareToAscii(ConfigurationProvider::staticServiceInfo.implementationName),
+ "configmgr::createProviderFactory : invalid argument !");
+ return new OProviderFactory(rServiceManager, pCreateFunction);
+ }
+
+} // namespace configmgr
+
+// ***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence<OUString>& Services,
+ const Reference< XRegistryKey > & xKey)
+{
+ OUString aMainKeyName(OUString(RTL_CONSTASCII_USTRINGPARAM("/")));
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
+
+ Reference< XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSHURE(xNewKey.is(), "CONFMGR::component_writeInfo : could not create a registry key !");
+
+ for (sal_uInt32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+void RegisterService(
+ const ServiceInfo* pInfo,
+ const Reference< XRegistryKey > & xKey)
+{
+ if (pInfo == 0 || pInfo->serviceNames==0 || pInfo->implementationName==0)
+ return;
+
+ OUString aMainKeyName(OUString(RTL_CONSTASCII_USTRINGPARAM("/")));
+ aMainKeyName += OUString::createFromAscii(pInfo->implementationName);
+ aMainKeyName += OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
+
+ Reference< XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSHURE(xNewKey.is(), "CONFMGR::component_writeInfo : could not create a registry key !");
+
+ AsciiServiceName const* p = pInfo->serviceNames;
+ if (p != 0)
+ for( ; *p; ++p)
+ {
+ xNewKey->createKey(OUString::createFromAscii(*p));
+ }
+}
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ OSL_ENSHURE(!xRet.is(), "CREATE_PROVIDER : invalid : already have a return value !");
+ if (xRet.is())
+ xRet->release();
+
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services);
+ OSL_ENSHURE(xRet.is(), "CREATE_PROVIDER : invalid return value !");
+
+ if (xRet.is())
+ xRet->acquire();
+ // we want to transport the interface pointer as flat C void pointer, so this prevents deletion
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ inline
+ sal_Bool CreateProvider(
+ const ServiceInfo* pInfo,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ OSL_ENSHURE(!xRet.is(), "CreateProvider : invalid : we already have a return value !");
+ if (xRet.is())
+ return true; //xRet->release();
+
+ if (!xRet.is() && pInfo!=0 && (0 == sImplementationName.compareToAscii(pInfo->implementationName)))
+ try
+ {
+ const Sequence< OUString > Services= configmgr::ServiceComponentImpl::getServiceNames(pInfo);
+
+ xRet = creator( xServiceManager, OUString::createFromAscii(pInfo->implementationName),Factory, Services);
+ OSL_ENSHURE(xRet.is(), "CreateProvider : WHERE IS THE return value !");
+
+ if (xRet.is())
+ xRet->acquire();
+ // we want to transport the interface pointer as flat C void pointer, so this prevents deletion
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **ppEnv
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< XRegistryKey > xKey(reinterpret_cast<XRegistryKey*>(pRegistryKey));
+
+ RegisterService(&configmgr::ConfigurationProvider::staticServiceInfo, xKey);
+
+ RegisterService(configmgr::getConfigurationRegistryServiceInfo(), xKey);
+
+ // im/export
+ RegisterService(configmgr::getDataExportServiceInfo(), xKey);
+ RegisterService(configmgr::getDataImportServiceInfo(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSHURE(sal_False, "SBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* pRegistryKey)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CreateProvider(
+ &configmgr::ConfigurationProvider::staticServiceInfo,
+ &configmgr::instantiateProvider,
+ ::configmgr::createProviderFactory)
+ ||
+ aReq.CreateProvider(
+ configmgr::getConfigurationRegistryServiceInfo(),
+ &configmgr::instantiateConfigRegistry,
+ ::cppu::createSingleFactory)
+ ||
+ /* Export */
+ aReq.CreateProvider(
+ configmgr::getDataExportServiceInfo(),
+ &configmgr::instantiateDataExport,
+ ::cppu::createSingleFactory)
+ ||
+ /* Import */
+ aReq.CreateProvider(
+ configmgr::getDataImportServiceInfo(),
+ &configmgr::instantiateDataImport,
+ ::cppu::createSingleFactory)
+ ||
+ false;
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+//---------------------------------------------------------------------------------------
+
diff --git a/configmgr/source/misc/filehelper.cxx b/configmgr/source/misc/filehelper.cxx
new file mode 100644
index 000000000000..f7bb7ec7138e
--- /dev/null
+++ b/configmgr/source/misc/filehelper.cxx
@@ -0,0 +1,320 @@
+/*************************************************************************
+ *
+ * $RCSfile: filehelper.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _RTL_USTRING_H_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+
+#ifndef _CONFIGMGR_FILEHELPER_HXX_
+#include "filehelper.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+
+namespace configmgr
+{
+using namespace ::osl;
+
+#define ASCII(x) rtl::OUString::createFromAscii(x)
+// ---------------------------- tryToRemoveFile ----------------------------
+ sal_Int32 FileHelper::tryToRemoveFile(const rtl::OUString& _aURL)
+ {
+ {
+ File aFile(_aURL);
+ FileBase::RC eError = aFile.open(OpenFlag_Read);
+ if (eError != osl_File_E_None)
+ {
+ // IF not exists
+ return 0;
+ }
+ aFile.close();
+ }
+ FileBase::RC eError = File::remove(_aURL);
+ if (eError != osl_File_E_None)
+ {
+ rtl::OUString sError = ASCII("tryToRemoveFile: ");
+ sError += FileHelper::createOSLErrorString(eError);
+ sError += ASCII("\n with URL: ");
+ sError += _aURL;
+ rtl::OString aStr = rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(0, aStr.getStr());
+ return 1;
+ }
+ return 0;
+ }
+
+// -----------------------------------------------------------------------------
+ sal_Int32 FileHelper::createBackupRemoveAndRename(
+ const rtl::OUString& _aFromURL, const rtl::OUString &_aToURL)
+ {
+ // remove FromURL
+ // rename ToURL to FromURL
+ if (FileHelper::tryToRemoveFile(_aFromURL) != 0)
+ return 1;
+
+ FileBase::RC eError = File::move(_aToURL, _aFromURL);
+ if (eError != osl_File_E_None)
+ {
+ rtl::OUString sError = ASCII("createBackupAndRemove: ") + FileHelper::createOSLErrorString(eError) + ASCII("\n with URL: ") + _aFromURL;
+ rtl::OString aStr = rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(0, aStr.getStr());
+ return 2;
+ }
+ return 0;
+ }
+// ------------------ Create a string from FileBase::RC Error ------------------
+ rtl::OUString FileHelper::createOSLErrorString(FileBase::RC eError)
+ {
+ rtl::OUString aRet;
+ switch(eError)
+ {
+ case osl_File_E_None:
+ aRet = ASCII("");
+ break;
+
+ case osl_File_E_PERM:
+ aRet = ASCII("Operation not permitted");
+ break;
+
+ case osl_File_E_NOENT:
+ aRet = ASCII("No such file or directory");
+ break;
+
+ case osl_File_E_SRCH:
+ aRet = ASCII("unknown error: osl_File_E_SRCH");
+ break;
+
+ case osl_File_E_INTR:
+ aRet = ASCII("function call was interrupted");
+ break;
+
+ case osl_File_E_IO:
+ aRet = ASCII("I/O error");
+ break;
+
+ case osl_File_E_NXIO:
+ aRet = ASCII("No such device or address");
+ break;
+
+ case osl_File_E_2BIG:
+ aRet = ASCII("unknown error: osl_File_E_2BIG");
+ break;
+
+ case osl_File_E_NOEXEC:
+ aRet = ASCII("unknown error: osl_File_E_NOEXEC");
+ break;
+
+ case osl_File_E_BADF:
+ aRet = ASCII("Bad file");
+ break;
+
+ case osl_File_E_CHILD:
+ aRet = ASCII("unknown error: osl_File_E_CHILD");
+ break;
+
+ case osl_File_E_AGAIN:
+ aRet = ASCII("Operation would block");
+ break;
+
+ case osl_File_E_NOMEM:
+ aRet = ASCII("not enough memory for allocating structures");
+ break;
+
+ case osl_File_E_ACCES:
+ aRet = ASCII("Permission denied");
+ break;
+
+ case osl_File_E_FAULT:
+ aRet = ASCII("Bad address");
+ break;
+
+ case osl_File_E_BUSY:
+ aRet = ASCII("Text file busy");
+ break;
+
+ case osl_File_E_EXIST:
+ aRet = ASCII("File exists");
+ break;
+
+ case osl_File_E_XDEV:
+ aRet = ASCII("unknown error: osl_File_E_XDEV");
+ break;
+
+ case osl_File_E_NODEV:
+ aRet = ASCII("No such device");
+ break;
+
+ case osl_File_E_NOTDIR:
+ aRet = ASCII("Not a directory");
+ break;
+
+ case osl_File_E_ISDIR:
+ aRet = ASCII("Is a director");
+ break;
+
+ case osl_File_E_INVAL:
+ aRet = ASCII("the format of the parameters was not valid");
+ break;
+
+ case osl_File_E_NFILE:
+ aRet = ASCII("too many open files in the system");
+ break;
+
+ case osl_File_E_MFILE:
+ aRet = ASCII("too many open files used by the process");
+ break;
+
+ case osl_File_E_NOTTY:
+ aRet = ASCII("unknown error: osl_File_E_NOTTY");
+ break;
+
+ case osl_File_E_FBIG:
+ aRet = ASCII("File too large");
+ break;
+
+ case osl_File_E_NOSPC:
+ aRet = ASCII("No space left on device");
+ break;
+
+ case osl_File_E_SPIPE:
+ aRet = ASCII("unknown error: osl_File_E_SPIPE");
+ break;
+
+ case osl_File_E_ROFS:
+ aRet = ASCII("Read-only file system");
+ break;
+
+ case osl_File_E_MLINK:
+ aRet = ASCII("Too many links");
+ break;
+
+ case osl_File_E_PIPE:
+ aRet = ASCII("unknown error: osl_File_E_PIPE");
+ break;
+
+ case osl_File_E_DOM:
+ aRet = ASCII("unknown error: osl_File_E_DOM");
+ break;
+
+ case osl_File_E_RANGE:
+ aRet = ASCII("unknown error: osl_File_E_RANGE");
+ break;
+
+ case osl_File_E_DEADLK:
+ aRet = ASCII("unknown error: osl_File_E_DEADLK");
+ break;
+
+ case osl_File_E_NAMETOOLONG:
+ aRet = ASCII("File name too long");
+ break;
+
+ case osl_File_E_NOLCK:
+ aRet = ASCII("No record locks available");
+ break;
+
+ case osl_File_E_NOSYS:
+ aRet = ASCII("Function not implemente");
+ break;
+
+ case osl_File_E_NOTEMPTY:
+ aRet = ASCII("Directory not empt");
+ break;
+
+ case osl_File_E_LOOP:
+ aRet = ASCII("Too many symbolic links encountered");
+ break;
+
+ case osl_File_E_ILSEQ:
+ aRet = ASCII("unknown error: osl_File_E_ILSEQ");
+ break;
+
+ case osl_File_E_NOLINK:
+ aRet = ASCII("Link has been severed");
+ break;
+
+ case osl_File_E_MULTIHOP:
+ aRet = ASCII("Multihop attempted");
+ break;
+
+ case osl_File_E_USERS:
+ aRet = ASCII("unknown error: osl_File_E_USERS");
+ break;
+
+ case osl_File_E_OVERFLOW:
+ aRet = ASCII("Value too large for defined data type");
+ break;
+
+ /* unmapped error: always last entry in enum! */
+ case osl_File_E_invalidError:
+ aRet = ASCII("unmapped Error");
+ break;
+ }
+ return aRet;
+ }
+} // namespace configmgr
diff --git a/configmgr/source/misc/makefile.mk b/configmgr/source/misc/makefile.mk
new file mode 100644
index 000000000000..38808828d11e
--- /dev/null
+++ b/configmgr/source/misc/makefile.mk
@@ -0,0 +1,100 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=configmgr
+TARGET=misc
+
+#ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+EXCEPTIONSFILES = \
+ $(SLO)$/saxtools.obj \
+ $(SLO)$/oslstream.obj \
+ $(SLO)$/attributes.obj \
+ $(SLO)$/confname.obj \
+ $(SLO)$/configmodule.obj \
+ $(SLO)$/configunoreg.obj \
+
+SLOFILES= \
+ $(SLO)$/tracer.obj \
+ $(SLO)$/saxtools.obj \
+ $(SLO)$/oslstream.obj \
+ $(SLO)$/attributes.obj \
+ $(SLO)$/confname.obj \
+ $(SLO)$/configmodule.obj \
+ $(SLO)$/configunoreg.obj \
+ $(SLO)$/synchronize.obj \
+ $(SLO)$/filehelper.obj \
+ $(SLO)$/strimpl.obj \
+ $(SLO)$/strconverter.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/configmgr/source/misc/oslstream.cxx b/configmgr/source/misc/oslstream.cxx
new file mode 100644
index 000000000000..1fe03b22ec7e
--- /dev/null
+++ b/configmgr/source/misc/oslstream.cxx
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * $RCSfile: oslstream.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_OSLSTREAM_HXX_
+#include "oslstream.hxx"
+#endif
+
+//#ifndef _STREAM_HXX //autogen
+//#include <tools/stream.hxx>
+//#endif
+//#ifndef _TOOLS_DEBUG_HXX
+//#include <tools/debug.hxx>
+//#endif
+
+namespace configmgr
+{
+ using namespace osl;
+
+//------------------------------------------------------------------
+OSLInputStreamWrapper::OSLInputStreamWrapper( File& _rFile )
+ :m_pFile(&_rFile)
+ ,m_bFileOwner(sal_False)
+{
+}
+
+//------------------------------------------------------------------
+OSLInputStreamWrapper::OSLInputStreamWrapper( File* pStream, sal_Bool bOwner )
+ :m_pFile( pStream )
+ ,m_bFileOwner( bOwner )
+{
+}
+
+//------------------------------------------------------------------
+OSLInputStreamWrapper::~OSLInputStreamWrapper()
+{
+ if( m_bFileOwner )
+ delete m_pFile;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OSLInputStreamWrapper::readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
+ throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException )
+{
+ if (!m_pFile)
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+
+ if (nBytesToRead < 0)
+ throw stario::BufferSizeExceededException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ aData.realloc(nBytesToRead);
+
+ sal_uInt64 nRead = 0;
+ FileBase::RC eError = m_pFile->read((void*)aData.getArray(), nBytesToRead, nRead);
+ if (eError != osl_File_E_None)
+ throw stario::BufferSizeExceededException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+
+ // Wenn gelesene Zeichen < MaxLength, staruno::Sequence anpassen
+ if (nRead < (sal_uInt32)nBytesToRead)
+ aData.realloc( nRead );
+
+ return nRead;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OSLInputStreamWrapper::readSomeBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException )
+{
+ if (!m_pFile)
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+
+ if (nMaxBytesToRead < 0)
+ throw stario::BufferSizeExceededException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+
+ /*
+ if (m_pFile->IsEof())
+ {
+ aData.realloc(0);
+ return 0;
+ }
+ else
+ */
+ return readBytes(aData, nMaxBytesToRead);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OSLInputStreamWrapper::skipBytes(sal_Int32 nBytesToSkip) throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (!m_pFile)
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+
+ sal_uInt64 nCurrentPos;
+ m_pFile->getPos(nCurrentPos);
+
+ sal_uInt64 nNewPos = nCurrentPos + nBytesToSkip;
+ FileBase::RC eError = m_pFile->setPos(osl_Pos_Absolut, nNewPos);
+ if (eError != osl_File_E_None)
+ {
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+ }
+
+#ifdef DBG_UTIL
+ m_pFile->getPos(nCurrentPos);
+ volatile int dummy = 0; // to take a look at last changes ;-)
+#endif
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OSLInputStreamWrapper::available() throw( stario::NotConnectedException, staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (!m_pFile)
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+
+ sal_uInt64 nPos;
+ FileBase::RC eError = m_pFile->getPos(nPos);
+ if (eError != osl_File_E_None)
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+
+ sal_uInt64 nDummy = 0;
+ eError = m_pFile->setPos(Pos_End, nDummy);
+ if (eError != osl_File_E_None)
+ throw stario::NotConnectedException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+
+ sal_uInt64 nAvailable;
+ eError = m_pFile->getPos(nAvailable);
+ if (eError != osl_File_E_None)
+ throw stario::NotConnectedException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+
+ nAvailable = nAvailable - nPos;
+ eError = m_pFile->setPos(Pos_Absolut, nPos);
+ if (eError != osl_File_E_None)
+ throw stario::NotConnectedException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+ return nAvailable;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OSLInputStreamWrapper::closeInput() throw( stario::NotConnectedException, staruno::RuntimeException )
+{
+ if (!m_pFile)
+ throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this));
+
+ m_pFile->close();
+ if (m_bFileOwner)
+ delete m_pFile;
+
+ m_pFile = NULL;
+}
+
+/*************************************************************************/
+// stario::XOutputStream
+//------------------------------------------------------------------------------
+void SAL_CALL OSLOutputStreamWrapper::writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException )
+{
+ sal_uInt64 nWritten;
+ if (aData.getLength() != 0)
+ {
+ FileBase::RC eError = rFile.write(aData.getConstArray(),aData.getLength(), nWritten);
+ if (eError != osl_File_E_None || nWritten != aData.getLength())
+ {
+ throw stario::BufferSizeExceededException(::rtl::OUString(),static_cast<staruno::XWeak*>(this));
+ }
+ }
+}
+
+
+//------------------------------------------------------------------
+void SAL_CALL OSLOutputStreamWrapper::flush() throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException )
+{
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OSLOutputStreamWrapper::closeOutput() throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException )
+{
+ rFile.close();
+}
+
+} // namespace configmgr
+
+
diff --git a/configmgr/source/misc/strimpl.cxx b/configmgr/source/misc/strimpl.cxx
new file mode 100644
index 000000000000..bf872dd58c3c
--- /dev/null
+++ b/configmgr/source/misc/strimpl.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * $RCSfile: strimpl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_STRINGS_HXX_
+#include "strings.hxx"
+#endif
+
+namespace configmgr
+{
+ // tag names
+ // <name>...</name>
+ IMPLEMENT_CONSTASCII_USTRING(TAG_VALUE, "cfg:value");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_USERVALUE, "uservalue");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_VALUE_ITEM, "value_item");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_DEFAULT_ITEM, "default_item");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_NODEFAULT, "nodefault");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_DEFAULT, "default");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_DEFAULTVALUE, "defaultvalue");
+ IMPLEMENT_CONSTASCII_USTRING(TAG_DATA, "data");
+
+ // simple types Attribut params
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_BOOLEAN, "boolean");
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_SHORT, "short");
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_INT, "int");
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_LONG, "long");
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_DOUBLE, "double");
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_STRING, "string");
+
+ // Type: Sequence<bytes>
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_BINARY, "binary");
+
+ // special types
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_SET, "set");
+ IMPLEMENT_CONSTASCII_USTRING(TYPE_GROUP, "group");
+
+
+ // Attributes name="..."
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_ENCODING_HEX, "hex");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_NAME, "name");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_TYPE, "cfg:type");
+
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_GROUP, "group");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_DERIVED, "derived");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_INSTANCE, "cfg:element-type");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_ENCODING, "encoding");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_MODE, "mode");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_PATH, "path");
+
+ // some Attribute params
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_DERIVED_LIST, "list");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_VALUE_ADD, "add");
+ IMPLEMENT_CONSTASCII_USTRING(ATTR_VALUE_REMOVE, "remove");
+
+ // Parameter
+ IMPLEMENT_CONSTASCII_USTRING(PARAM_OBJECT, "Object");
+ IMPLEMENT_CONSTASCII_USTRING(PARAM_NAME, "Name");
+ IMPLEMENT_CONSTASCII_USTRING(PARAM_ISNEWOBJECT, "IsNewObject");
+
+ IMPLEMENT_CONSTASCII_USTRING(XML_CDATA, "CDATA");
+
+// emacs:
+// create the declare from the implement
+// (fset 'create-declare-from-implement
+// [home M-right ?\C- ?\C-s ?, left right left ?\M-w f12 return up tab ?D ?E ?C ?L ?A ?R ?E ?\C-y ?) ?; home down f12 home down])
+
+} // namespace configmgr
diff --git a/configmgr/source/misc/tracer.cxx b/configmgr/source/misc/tracer.cxx
new file mode 100644
index 000000000000..64dbf87e5d1a
--- /dev/null
+++ b/configmgr/source/misc/tracer.cxx
@@ -0,0 +1,396 @@
+/*************************************************************************
+ *
+ * $RCSfile: tracer.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// SUNPRO5 does not like the following to be done after including stdio.h, that's why it's here at the very
+// beginning of the file
+#undef _TIME_T_DEFINED
+#include <time.h>
+#include <rtl/string.hxx>
+#include <map>
+
+namespace configmgr
+{
+ typedef ::std::map< ::rtl::OString, void*, ::std::less< ::rtl::OString > > VirtualDevices;
+}
+
+#ifndef _CONFIGMGR_TRACER_HXX_
+#include "tracer.hxx"
+#endif
+
+#ifdef CFG_ENABLE_TRACING
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+
+#define INFO 1
+#define WARNING 2
+#define ERROR 4
+
+namespace configmgr
+{
+
+struct OTracerSetup
+{
+ sal_Int32 s_nTraceMask;
+ sal_Int32 s_nIndentDepth;
+ FILE* s_pOutputMedium;
+ sal_Bool s_bInitialized;
+
+ VirtualDevices s_aDevices;
+
+ OTracerSetup()
+ :s_nTraceMask(INFO | WARNING | ERROR)
+ ,s_nIndentDepth(0)
+ ,s_pOutputMedium(NULL)
+ ,s_bInitialized(sal_False)
+ {
+ }
+};
+
+//==========================================================================
+//= OConfigTracer
+//==========================================================================
+::osl::Mutex OConfigTracer::s_aMutex;
+OTracerSetup* OConfigTracer::s_pImpl = NULL;
+
+//--------------------------------------------------------------------------
+void OConfigTracer::ensureData()
+{
+ if (s_pImpl)
+ return;
+ s_pImpl = new OTracerSetup;
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::inc()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ensureData();
+ ++s_pImpl->s_nIndentDepth;
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::dec()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ensureData();
+ --s_pImpl->s_nIndentDepth;
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::traceInfo(const sal_Char* _pFormat, ...)
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ensureData();
+ if (s_pImpl->s_nTraceMask & INFO)
+ {
+ va_list args;
+ va_start(args, _pFormat);
+ implTrace("info : ", _pFormat, args);
+ va_end(args);
+ }
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::traceWarning(const sal_Char* _pFormat, ...)
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ensureData();
+ if (s_pImpl->s_nTraceMask & WARNING)
+ {
+ va_list args;
+ va_start(args, _pFormat);
+ implTrace("warning : ", _pFormat, args);
+ va_end(args);
+ }
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::traceError(const sal_Char* _pFormat, ...)
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ensureData();
+ if (s_pImpl->s_nTraceMask & ERROR)
+ {
+ va_list args;
+ va_start(args, _pFormat);
+ implTrace("error : ", _pFormat, args);
+ va_end(args);
+ }
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::indent()
+{
+ for (sal_Int32 i=0; i<s_pImpl->s_nIndentDepth; ++i)
+ fprintf(s_pImpl->s_pOutputMedium, " ");
+}
+
+//--------------------------------------------------------------------------
+FILE* disambiguate(const ::rtl::OString& _rFileName)
+{
+ FILE* pExistenceCheck = NULL;
+ sal_Int32 i = 1;
+ ::rtl::OString sLoop;
+ while (i <= 256)
+ {
+ sLoop = _rFileName;
+ sLoop += ".";
+ sLoop += ::rtl::OString::valueOf(i);
+
+ pExistenceCheck = fopen(sLoop.getStr(), "r");
+ if (!pExistenceCheck)
+ // does not exist
+ return fopen(sLoop.getStr(), "w+");
+
+ // already exists, try the next name
+ fclose(pExistenceCheck);
+ ++i;
+ }
+
+ // could not open such a file
+ return NULL;
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::ensureInitalized()
+{
+ if (s_pImpl->s_bInitialized)
+ return;
+
+ s_pImpl->s_bInitialized = sal_True;
+
+ char* pSettings = getenv("ENVCFGFLAGS");
+ if (!pSettings)
+ return;
+
+ /* currently recognized structure :
+ + switches have to be separated by whitespaces
+ + valid switches are:
+ -m[e|o|f<file>] - output to stderr (e), stdout (o) or a file (f). In the latter case the whole rest
+ of the param ('til the next one, means 'til the next whitespace) is the filename
+ -t{i,w,e}* - type of output : i includes infos, w includes warnings, e includes errors
+ */
+
+ s_pImpl->s_pOutputMedium = stderr;
+ s_pImpl->s_nTraceMask = 0;
+
+ char* pParamLoop = pSettings;
+ while (*pParamLoop)
+ {
+ while (!isspace(*pParamLoop) && *pParamLoop)
+ ++pParamLoop;
+
+ sal_Int32 nLen = pParamLoop - pSettings;
+ if ((nLen > 1) && (*pSettings == '-'))
+ {
+ ++pSettings;
+ switch (*pSettings)
+ {
+ case 'm':
+ case 'w':
+ if (nLen > 2)
+ {
+ ++pSettings;
+ switch (*pSettings)
+ {
+ case 'e':
+ s_pImpl->s_pOutputMedium = stderr;
+ break;
+ case 'o':
+ s_pImpl->s_pOutputMedium = stdout;
+ break;
+ case 'f':
+ {
+ ++pSettings;
+ // copy the filename into an own buffer
+ ::rtl::OString sFileName(pSettings, pParamLoop - pSettings);
+
+ // open the file
+ s_pImpl->s_pOutputMedium = disambiguate(sFileName);
+
+ break;
+ }
+ }
+ }
+ break;
+ case 'd':
+ { // assign a virtual device
+ // copy the device assingment description
+ ::rtl::OString sDescription(pSettings + 1, pParamLoop - pSettings - 1);
+ sal_Int32 nSep = sDescription.indexOf(':');
+ if (-1 == nSep)
+ break; // invalid format
+
+ ::rtl::OString sVirtualDeviceName, sFileName;
+ sVirtualDeviceName = sDescription.copy(0, nSep);
+ sFileName = sDescription.copy(nSep + 1);
+
+ FILE* pVirtualDevice = disambiguate(sFileName);
+ if (pVirtualDevice)
+ s_pImpl->s_aDevices[sVirtualDeviceName] = pVirtualDevice;
+ }
+ case 't':
+ {
+ ++pSettings;
+ while (pSettings != pParamLoop)
+ {
+ switch (*pSettings)
+ {
+ case 'i': s_pImpl->s_nTraceMask |= INFO; break;
+ case 'w': s_pImpl->s_nTraceMask |= WARNING; break;
+ case 'e': s_pImpl->s_nTraceMask |= ERROR; break;
+ }
+ ++pSettings;
+ }
+ }
+ }
+ }
+
+ if (!*pParamLoop)
+ break;
+
+ ++pParamLoop;
+ pSettings = pParamLoop;
+ }
+}
+//--------------------------------------------------------------------------
+void OConfigTracer::traceToVirtualDevice(const sal_Char* _pDeviceName, const sal_Char* _pFormat, ...)
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ensureData();
+ ensureInitalized();
+
+ VirtualDevices::const_iterator aDeviceMediumPos = s_pImpl->s_aDevices.find(::rtl::OString(_pDeviceName));
+ if (aDeviceMediumPos != s_pImpl->s_aDevices.end())
+ {
+ FILE* pDeviceMedium = (FILE*)aDeviceMediumPos->second;
+
+ va_list args;
+ va_start(args, _pFormat);
+ vfprintf(pDeviceMedium, _pFormat, args);
+ fflush(pDeviceMedium);
+ va_end(args);
+ }
+}
+
+//--------------------------------------------------------------------------
+::rtl::OString OConfigTracer::getTimeStamp()
+{
+ time_t aTime = time(NULL);
+ tm* pStructuredTime = gmtime(&aTime);
+ ::rtl::OString sTimeStamp(asctime(pStructuredTime));
+ // cut the trainling linefeed (asctime is defined to contain such a line feed)
+ sal_Int32 nStampLen = sTimeStamp.getLength();
+ if ((0 != nStampLen) && ('\n' == sTimeStamp.getStr()[nStampLen - 1]))
+ sTimeStamp = sTimeStamp.copy(0, nStampLen - 1);
+
+ return sTimeStamp;
+}
+
+//--------------------------------------------------------------------------
+void OConfigTracer::implTrace(const sal_Char* _pType, const sal_Char* _pFormat, va_list args)
+{
+ ensureInitalized();
+ if (!s_pImpl->s_pOutputMedium)
+ // no tracing enabled
+ return;
+
+ fprintf(s_pImpl->s_pOutputMedium, "%s", _pType);
+ indent();
+ vfprintf(s_pImpl->s_pOutputMedium, _pFormat, args);
+ fprintf(s_pImpl->s_pOutputMedium,"\n");
+ fflush(s_pImpl->s_pOutputMedium);
+}
+
+} // namespace configmgr
+
+#endif // defined(DEBUG) || defined(_DEBUG)
+
+//**************************************************************************
+// history:
+// $Log: not supported by cvs2svn $
+// 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/cfgregistrykey.cxx b/configmgr/source/registry/cfgregistrykey.cxx
new file mode 100644
index 000000000000..259df2542b98
--- /dev/null
+++ b/configmgr/source/registry/cfgregistrykey.cxx
@@ -0,0 +1,783 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfgregistrykey.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_REGISTRY_CFGREGISTRYKEY_HXX_
+#include "cfgregistrykey.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+
+#define THISREF() static_cast< ::cppu::OWeakObject* >(this)
+#define UNISTRING(c) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(c) )
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::container;
+using namespace ::osl;
+using namespace ::cppu;
+
+//==========================================================================
+//= OConfigurationRegistryKey
+//==========================================================================
+
+//--------------------------------------------------------------------------
+OConfigurationRegistryKey::OConfigurationRegistryKey
+ (const Reference< XNameAccess >& _rxContainerNode
+ ,sal_Bool _bWriteable
+ ,SubtreeRoot
+ )
+ :m_xNodeAccess(_rxContainerNode)
+ ,m_bReadOnly(!_bWriteable)
+ ,m_xNodeDeepAccess(_rxContainerNode, UNO_QUERY)
+{
+ OSL_ENSHURE(m_xNodeAccess.is(), "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid config node param !");
+}
+
+//--------------------------------------------------------------------------
+OConfigurationRegistryKey::OConfigurationRegistryKey(
+ const Reference< XNameAccess >& _rxContainerNode,
+ const ::rtl::OUString& _rLocalName,
+ sal_Bool _bWriteable)
+ :m_xNodeAccess(_rxContainerNode)
+ ,m_bReadOnly(!_bWriteable)
+ ,m_xNodeDeepAccess(_rxContainerNode, UNO_QUERY)
+ ,m_sLocalName(_rLocalName)
+{
+ OSL_ENSHURE(m_xNodeAccess.is(), "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid config node param !");
+ OSL_ENSHURE(m_sLocalName.getLength(), "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid relative name !");
+}
+
+//--------------------------------------------------------------------------
+OConfigurationRegistryKey::OConfigurationRegistryKey(
+ Any _rCurrentValue,
+ const Reference< XNameAccess >& _rxParentNode,
+ const ::rtl::OUString& _rRelativeName,
+ sal_Bool _bWriteable)
+ :m_aLeafElement(_rCurrentValue)
+ ,m_xLeafParent(_rxParentNode)
+ ,m_sLocalName(_rRelativeName)
+ ,m_bReadOnly(!_bWriteable)
+{
+ OSL_ENSHURE(_rxParentNode.is() && _rCurrentValue.hasValue(),
+ "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid value and/or parent !");
+ OSL_ENSHURE(m_bReadOnly || Reference< XNameReplace >(_rxParentNode, UNO_QUERY).is(),
+ "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid parent (no value write access) !");
+ OSL_ENSHURE(m_sLocalName.getLength(), "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid relative name !");
+}
+
+//--------------------------------------------------------------------------
+void OConfigurationRegistryKey::checkValid(KEY_ACCESS_TYPE _eIntentedAccess) throw (InvalidRegistryException)
+{
+ if (!isValid())
+ throw InvalidRegistryException(UNISTRING("The registry is not bound to a configuration node anymore."), THISREF());
+ // "anymore", because at the moment the ctor was called it probably was bound ....
+ switch (_eIntentedAccess)
+ {
+ case KAT_VALUE_WRITE:
+ if (m_bReadOnly)
+ throw InvalidRegistryException(UNISTRING("This configuration node is not writeable."), THISREF());
+ // !!! NO !!! BREAK !!!
+ case KAT_VALUE:
+ if (!m_aLeafElement.hasValue())
+ throw InvalidRegistryException(UNISTRING("This configuration node does not have a value, it is a container."), THISREF());
+ if (!m_xLeafParent.is())
+ throw InvalidRegistryException(UNISTRING("This configuration nodes parent is invalid."), THISREF());
+ break;
+ case KAT_CHILD:
+ if (!m_xNodeAccess.is())
+ throw InvalidRegistryException(UNISTRING("This configuration node does not have children, it is a value node."), THISREF());
+ break;
+ }
+}
+
+//--------------------------------------------------------------------------
+Any OConfigurationRegistryKey::getDescendant(const ::rtl::OUString& _rDescendantName) throw(InvalidRegistryException)
+{
+ Any aElementReturn;
+
+ try
+ {
+ if (-1 != _rDescendantName.indexOf('/'))
+ {
+ if (m_xNodeDeepAccess.is())
+ aElementReturn = m_xNodeDeepAccess->getByHierarchicalName(_rDescendantName);
+ else
+ throw InvalidRegistryException(UNISTRING("Nested element access not supported by this node."), THISREF());
+ }
+ else
+ {
+ if (m_xNodeAccess.is())
+ aElementReturn = m_xNodeAccess->getByName(_rDescendantName);
+ else
+ {
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::getDescendant : invalid call !");
+ // this method should not be called if the object does not represent a container node ...
+ throw InvalidRegistryException(UNISTRING("invalid object."), THISREF());
+ }
+ }
+ }
+ catch(NoSuchElementException&)
+ { // not allowed to leave the method, wrap it
+ ::rtl::OUString sMessage(UNISTRING("There is no element named "));
+ sMessage += _rDescendantName;
+ sMessage += UNISTRING(".");
+ throw InvalidRegistryException(sMessage, THISREF());
+ }
+ catch(WrappedTargetException&)
+ { // allowed to be thrown by XNameAccess::getByName, but not allowed to leave this method
+ ::rtl::OUString sMessage(UNISTRING("The configuration node could not provide an element for "));
+ sMessage += _rDescendantName;
+ sMessage += UNISTRING(".");
+ throw InvalidRegistryException(sMessage, THISREF());
+ }
+
+ if (!aElementReturn.hasValue())
+ { // suspicious .... either there is an element, or there is none, but in the latter case an exception should
+ // have been thrown.
+ ::rtl::OUString sMessage(UNISTRING("There is no element named "));
+ sMessage += _rDescendantName;
+ sMessage += UNISTRING(".");
+ throw InvalidRegistryException(sMessage, THISREF());
+ }
+
+ return aElementReturn;
+}
+
+//--------------------------------------------------------------------------
+void OConfigurationRegistryKey::writeValueNode(const Any& _rValue) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE_WRITE);
+
+ Reference< XNameReplace > xParentValueAccess(m_xLeafParent, UNO_QUERY);
+ if (!xParentValueAccess.is())
+ throw InvalidRegistryException(UNISTRING("The parent configuration node does not allow write access to it's children."), THISREF());
+
+ try
+ {
+ xParentValueAccess->replaceByName(m_sLocalName, _rValue);
+ }
+ catch(IllegalArgumentException&)
+ {
+ throw InvalidRegistryException(UNISTRING("Unable to replace the old value. The configuration node threw an IllegalArgumentException."), THISREF());
+ }
+ catch(NoSuchElementException&)
+ {
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::writeValueNode : a NoSuchElementException should be impossible !");
+ throw InvalidRegistryException(UNISTRING("Unable to replace the old value. The configuration node threw an NoSuchElementException."), THISREF());
+ }
+ catch(WrappedTargetException&)
+ {
+ throw InvalidRegistryException(UNISTRING("Unable to replace the old value. The configuration node threw an WrappedTargetException."), THISREF());
+ }
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConfigurationRegistryKey::getKeyName() throw(RuntimeException)
+{
+ return m_sLocalName;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OConfigurationRegistryKey::isReadOnly( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_META);
+ return m_bReadOnly;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OConfigurationRegistryKey::isValid( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ // TODO : perhaps if the registry we're a part of is closed ....
+ return m_xNodeAccess.is() || m_aLeafElement.hasValue();
+}
+
+//--------------------------------------------------------------------------
+RegistryKeyType SAL_CALL OConfigurationRegistryKey::getKeyType( const ::rtl::OUString& _rKeyName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_CHILD);
+
+ // no further checks are made (for performance reasons) ...
+ return RegistryKeyType_KEY;
+}
+
+//--------------------------------------------------------------------------
+namespace {
+ inline
+ Type getBinaryDataType() {
+ Sequence<sal_Int8> const * const p= 0;
+ return ::getCppuType(p);
+ }
+}
+//--------------------------------------------------------------------------
+typedef typelib_TypeDescriptionReference ElementTypeDesc;
+
+RegistryValueType SAL_CALL OConfigurationRegistryKey::getValueType( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE);
+
+ switch (m_aLeafElement.getValueType().getTypeClass())
+ {
+ case TypeClass_STRING:
+ return RegistryValueType_STRING;
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_BYTE:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_BOOLEAN:
+ return RegistryValueType_LONG;
+ case TypeClass_SEQUENCE:
+ if (m_aLeafElement.getValueType() == getBinaryDataType())
+ return RegistryValueType_BINARY;
+ else
+ {
+ TypeDescription aType( m_aLeafElement.getValueType() );
+ typelib_IndirectTypeDescription* pSequenceType
+ = reinterpret_cast< typelib_IndirectTypeDescription* >(aType.get());
+ ElementTypeDesc* pElementType = pSequenceType->pType;
+
+ switch (pElementType->eTypeClass)
+ {
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_BYTE:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_BOOLEAN:
+ return RegistryValueType_LONGLIST;
+ case TypeClass_STRING:
+ return RegistryValueType_STRINGLIST;
+ case TypeClass_DOUBLE:
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::getValueType : registry does not support lists of floating point numebrs !");
+ default:
+ if (Type(pElementType) == getBinaryDataType())
+ OSL_ENSHURE(sal_False,"OConfigurationRegistryKey::getValueType : Registry cannot support LIST of BINARY");
+ else
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::getValueType : unknown sequence element type !");
+ return RegistryValueType_NOT_DEFINED;
+ }
+ }
+ case TypeClass_DOUBLE:
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::getValueType : registry does not support floating point numebrs !");
+ return RegistryValueType_NOT_DEFINED;
+ default:
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::getValueType : unknown entry type !");
+ return RegistryValueType_NOT_DEFINED;
+ }
+}
+
+//--------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConfigurationRegistryKey::getLongValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE);
+
+#define EXTRACT(tcname, type) \
+ case TypeClass_##tcname : { type nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; }
+
+ sal_Int32 nLongValue(0);
+ switch (m_aLeafElement.getValueTypeClass())
+ {
+ case TypeClass_SHORT : { sal_Int16 nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; } break;
+ case TypeClass_UNSIGNED_SHORT : { sal_uInt16 nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; } break;
+ case TypeClass_BYTE : { sal_Int8 nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; } break;
+ case TypeClass_LONG : { sal_Int32 nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; } break;
+ case TypeClass_UNSIGNED_LONG : { sal_uInt32 nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; } break;
+ case TypeClass_BOOLEAN : { sal_Bool nNativeValue; m_aLeafElement >>= nNativeValue; nLongValue = nNativeValue; } break;
+ default:
+ throw InvalidValueException(UNISTRING("This node does not contain a long (or a compatible) value."), THISREF());
+ }
+ return nLongValue;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setLongValue( sal_Int32 _nValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ writeValueNode(makeAny(_nValue));
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL OConfigurationRegistryKey::getLongListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE);
+
+ Sequence< sal_Int32 > aReturn;
+ if (m_aLeafElement >>= aReturn)
+ return aReturn;
+
+ // TODO : maybe it's a sequence of sal_Int8 or anything like that which we're able to convert ....
+
+ throw InvalidValueException(UNISTRING("This configuration node does not contain a list of longs !"), THISREF());
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setLongListValue( const Sequence< sal_Int32 >& _seqValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ writeValueNode(makeAny(_seqValue));
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConfigurationRegistryKey::getAsciiValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ ::rtl::OUString sReturn = getStringValue();
+ // TODO : check if it's really ascii ...
+ return sReturn;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setAsciiValue( const ::rtl::OUString& _rValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ setStringValue(_rValue);
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OConfigurationRegistryKey::getAsciiListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ return getStringListValue();
+ // TODO : it's not really an "ascii list" .... perhaps we should throw an exception here ...
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setAsciiListValue( const Sequence< ::rtl::OUString >& _seqValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ setStringListValue(_seqValue);
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConfigurationRegistryKey::getStringValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE);
+
+ ::rtl::OUString sReturn;
+ if (!(m_aLeafElement >>= sReturn))
+ throw InvalidValueException(UNISTRING("This node does not contain a string value."), THISREF());
+ return sReturn;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setStringValue( const ::rtl::OUString& _rValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ writeValueNode(makeAny(_rValue));
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OConfigurationRegistryKey::getStringListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE);
+
+ Sequence< ::rtl::OUString > aReturn;
+ if (m_aLeafElement >>= aReturn)
+ return aReturn;
+
+ throw InvalidValueException(UNISTRING("This configuration node does not contain a list of strings !"), THISREF());
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setStringListValue( const Sequence< ::rtl::OUString >& _seqValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ writeValueNode(makeAny(_seqValue));
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OConfigurationRegistryKey::getBinaryValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_VALUE);
+
+ Sequence< sal_Int8 > aReturn;
+ if (m_aLeafElement >>= aReturn)
+ return aReturn;
+
+ throw InvalidValueException(UNISTRING("This configuration node does not contain a list of strings !"), THISREF());
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::setBinaryValue( const Sequence< sal_Int8 >& _rValue ) throw(InvalidRegistryException, RuntimeException)
+{
+ writeValueNode(makeAny(_rValue));
+}
+
+//--------------------------------------------------------------------------
+Reference< XRegistryKey > OConfigurationRegistryKey::implGetKey( const ::rtl::OUString& _rKeyName )
+ throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sDescRelativeName(_rKeyName);
+ // will be the name of the new key relative to it's parent
+ sal_Bool bDeepAccess = sal_False;
+ sal_Int32 nSeparatorPos = _rKeyName.lastIndexOf('/');
+ if ((nSeparatorPos >= 0) && (nSeparatorPos == (_rKeyName.getLength() - 1)))
+ // recognize a trailing slashs
+ nSeparatorPos = _rKeyName.lastIndexOf('/', nSeparatorPos - 1);
+ if (nSeparatorPos >= 1)
+ {
+ sDescRelativeName = _rKeyName.copy(nSeparatorPos + 1);
+ bDeepAccess = sal_True;
+ }
+
+ Any aDescendant = getDescendant(_rKeyName);
+ if (aDescendant.getValueType().getTypeClass() == TypeClass_INTERFACE)
+ {
+ Reference< XNameAccess > xContainerNode;
+ ::cppu::extractInterface(xContainerNode, aDescendant);
+ if (!xContainerNode.is())
+ throw InvalidRegistryException(UNISTRING("invalid descendant node."), THISREF());
+ return new OConfigurationRegistryKey(xContainerNode, sDescRelativeName, !m_bReadOnly);
+ }
+ else
+ {
+ Reference< XNameAccess > xDescParent(m_xNodeAccess); // the parent config node of the descandent
+
+ OSL_ENSHURE(aDescendant.hasValue(), "OConfigurationRegistryKey::openKey : invalid return from getDescendant.");
+#ifdef DEBUG
+ switch (aDescendant.getValueType().getTypeClass())
+ {
+ case TypeClass_STRING:
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_BYTE:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_BOOLEAN:
+ case TypeClass_SEQUENCE:
+ break;
+ default:
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::openKey : unknown or invalid descendant value type !");
+ }
+#endif
+ if (bDeepAccess)
+ {
+ Any aDescParent = getDescendant(_rKeyName.copy(0, nSeparatorPos));
+ ::cppu::extractInterface(xDescParent, aDescParent);
+ if (!xDescParent.is())
+ throw InvalidRegistryException(UNISTRING("The internal registry structure seems to be corrupt."), THISREF());
+ }
+
+ return new OConfigurationRegistryKey(aDescendant, xDescParent, sDescRelativeName, !m_bReadOnly);
+ }
+}
+
+//--------------------------------------------------------------------------
+Reference< XRegistryKey > SAL_CALL OConfigurationRegistryKey::openKey( const ::rtl::OUString& _rKeyName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_CHILD);
+
+ return implGetKey(_rKeyName);
+}
+
+//--------------------------------------------------------------------------
+void OConfigurationRegistryKey::checkRelativeKeyName(::rtl::OUString& _rKeyName) throw(InvalidRegistryException, RuntimeException)
+{
+ // no empty names allowed
+ if (!_rKeyName.getLength())
+ throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
+
+ // no absolute names ("/...") allowed
+ if (_rKeyName.getStr()[0] == '/')
+ throw InvalidRegistryException(UNISTRING("The key name is invalid. It must be a relative, not an absolute name."), THISREF());
+
+ // cut trailing slashes
+ while (_rKeyName.getLength() && (_rKeyName.getStr()[_rKeyName.getLength() - 1] == '/'))
+ _rKeyName = _rKeyName.copy(0, _rKeyName.getLength() - 1);
+
+ if (!_rKeyName.getLength())
+ // the original name consists of slashes only
+ throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+Reference< XRegistryKey > SAL_CALL OConfigurationRegistryKey::createKey( const ::rtl::OUString& _rKeyName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_CHILD);
+
+ if (m_bReadOnly)
+ throw InvalidRegistryException(UNISTRING("The key is read only."), THISREF());
+
+ ::rtl::OUString sKeyName(_rKeyName);
+ checkRelativeKeyName(sKeyName);
+
+ sal_Int32 nSeparatorPos = sKeyName.lastIndexOf('/');
+ if (-1 != nSeparatorPos)
+ {
+ // deep access. delegate it to a registry key which is one level above the to-be-created one
+ ::rtl::OUString sSetNodeName = sKeyName.copy(0, nSeparatorPos);
+ sKeyName = sKeyName.copy(nSeparatorPos + 1);
+
+ Reference< XRegistryKey > xSetNode = implGetKey(sSetNodeName);
+ if (!xSetNode.is())
+ {
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::createKey : somebody changed the implGetKey behaviour !");
+ throw InvalidRegistryException(UNISTRING("An internal error occured."), THISREF());
+ }
+ return xSetNode->createKey(sKeyName);
+ }
+
+ // The requested new key is one level below ourself. Can't delegate the creation.
+ Reference< XNameContainer > xContainer(m_xNodeAccess, UNO_QUERY);
+ Reference< XSingleServiceFactory > xChildFactory(xContainer, UNO_QUERY);
+ if (!xChildFactory.is())
+ throw InvalidRegistryException(UNISTRING("The configuration node represented by this key is not a container node, you can't insert keys."), THISREF());
+
+ // In the configuration API, the creation of a new child is two-stage process : first you create a child which
+ // is "floating", i.e. does not belong to the configuration tree, yet. After filling it with values, you insert
+ // it into the container node which was used for the creation.
+ // We can't map this behaviour with the registry API, so we have to combine both steps
+
+ // create a new floating child for the container node
+ Reference< XInterface > xFloatingChild;
+ try
+ {
+ xFloatingChild = xChildFactory->createInstance();
+ }
+ catch (RuntimeException&)
+ { // allowed to leave this method
+ throw;
+ }
+ catch (Exception& e)
+ { // not allowed to leave this method
+ throw InvalidRegistryException(UNISTRING("Unable to create a new child for the configuration node. Original error message as provided by the configuration API : ") += e.Message,
+ THISREF());
+ }
+
+ // and immediately insert it into the container
+ try
+ {
+ xContainer->insertByName(sKeyName, makeAny(xFloatingChild));
+ }
+ catch (IllegalArgumentException& e)
+ {
+ throw InvalidRegistryException(UNISTRING("illegal argument : ") += e.Message, THISREF());
+ }
+ catch (ElementExistException& e)
+ {
+ if (e.Message.getLength())
+ throw InvalidRegistryException(e.Message, THISREF());
+ else
+ throw InvalidRegistryException((UNISTRING("There already is an element named ") += sKeyName) += UNISTRING("."), THISREF());
+ }
+ catch (WrappedTargetException& e)
+ {
+ throw InvalidRegistryException(UNISTRING("Caught an WrappedTargetException. Original error message : ") += e.Message, THISREF());
+ }
+
+ Reference< XNameAccess > xInsertedChild(xFloatingChild, UNO_QUERY);
+ if (!xInsertedChild.is())
+ throw InvalidRegistryException(UNISTRING("An internal error occured. The objects provided by the configuration API are invalid."), THISREF());
+
+ return new OConfigurationRegistryKey(xInsertedChild, sKeyName, !m_bReadOnly);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::closeKey( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ m_xNodeAccess = NULL;
+ m_xNodeDeepAccess = NULL;
+ m_aLeafElement.clear();
+ m_xLeafParent = NULL;
+ m_sLocalName = ::rtl::OUString();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::deleteKey( const ::rtl::OUString& _rKeyName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ checkValid(KAT_CHILD);
+ if (m_bReadOnly)
+ throw InvalidRegistryException(UNISTRING("The key is read only."), THISREF());
+
+ ::rtl::OUString sKeyName(_rKeyName);
+ checkRelativeKeyName(sKeyName);
+
+ sal_Int32 nSeparatorPos = sKeyName.lastIndexOf('/');
+ if (-1 != nSeparatorPos)
+ {
+ // deep access. delegate it to a registry key which is one level above the to-be-created one
+ ::rtl::OUString sSetNodeName = sKeyName.copy(0, nSeparatorPos);
+ sKeyName = sKeyName.copy(nSeparatorPos + 1);
+
+ Reference< XRegistryKey > xSetNode = implGetKey(sSetNodeName);
+ if (!xSetNode.is())
+ {
+ OSL_ENSHURE(sal_False, "OConfigurationRegistryKey::createKey : somebody changed the implGetKey behaviour !");
+ throw InvalidRegistryException(UNISTRING("An internal error occured."), THISREF());
+ }
+ xSetNode->deleteKey(sKeyName);
+ return;
+ }
+
+ // The requested new key is one level below ourself. Can't delegate the creation.
+ Reference< XNameContainer > xContainer(m_xNodeAccess, UNO_QUERY);
+ if (!xContainer.is())
+ throw InvalidRegistryException(UNISTRING("The configuration node represented by this key is not a container node, you can't remove keys."), THISREF());
+
+ // and immediately insert it into the container
+ try
+ {
+ xContainer->removeByName(sKeyName);
+ }
+ catch (NoSuchElementException& e)
+ {
+ if (e.Message.getLength())
+ throw InvalidRegistryException(e.Message, THISREF());
+ else
+ throw InvalidRegistryException((UNISTRING("There is no element named ") += sKeyName) += UNISTRING("."), THISREF());
+ }
+ catch (WrappedTargetException& e)
+ {
+ throw InvalidRegistryException(UNISTRING("Caught an WrappedTargetException. Original error message : ") += e.Message, THISREF());
+ }
+}
+
+//--------------------------------------------------------------------------
+Sequence< Reference< XRegistryKey > > SAL_CALL OConfigurationRegistryKey::openKeys( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_CHILD);
+
+ Sequence< ::rtl::OUString > aNames(m_xNodeAccess->getElementNames());
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ Sequence< Reference< XRegistryKey > > aReturn(aNames.getLength());
+ Reference< XRegistryKey >* pReturn = aReturn.getArray();
+ for (sal_Int32 i=0; i<aNames.getLength(); ++i, ++pNames, ++pReturn)
+ *pReturn = implGetKey(*pNames);
+
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OConfigurationRegistryKey::getKeyNames( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkValid(KAT_CHILD);
+ return m_xNodeAccess->getElementNames();
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OConfigurationRegistryKey::createLink( const ::rtl::OUString& aLinkName, const ::rtl::OUString& aLinkTarget ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ throw InvalidRegistryException(UNISTRING("This registry, which is base on a configuration tree, does not support links."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistryKey::deleteLink( const ::rtl::OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ throw InvalidRegistryException(UNISTRING("This registry, which is base on a configuration tree, does not support links."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConfigurationRegistryKey::getLinkTarget( const ::rtl::OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ throw InvalidRegistryException(UNISTRING("This registry, which is base on a configuration tree, does not support links."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConfigurationRegistryKey::getResolvedName( const ::rtl::OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ throw InvalidRegistryException(UNISTRING("This registry, which is base on a configuration tree, does not support links."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+
diff --git a/configmgr/source/registry/cfgregistrykey.hxx b/configmgr/source/registry/cfgregistrykey.hxx
new file mode 100644
index 000000000000..edf9c7d25fea
--- /dev/null
+++ b/configmgr/source/registry/cfgregistrykey.hxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfgregistrykey.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_REGISTRY_CFGREGISTRYKEY_HXX_
+#define _CONFIGMGR_REGISTRY_CFGREGISTRYKEY_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/Mutex.hxx>
+#endif
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+//==========================================================================
+//= OConfigurationRegistryKey
+//==========================================================================
+typedef ::cppu::WeakImplHelper1 < ::com::sun::star::registry::XRegistryKey
+ > OConfigurationRegistryKey_Base;
+
+/** wraps the registry-like access to a single node of a configuration sub tree
+*/
+class OConfigurationRegistryKey
+ :public OConfigurationRegistryKey_Base
+{
+ ::osl::Mutex m_aMutex; /// access safety
+ sal_Bool m_bReadOnly; /// is the key readonly ?
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xNodeAccess; /// the config node object, if it describes a container
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
+ m_xNodeDeepAccess; /// for accessing elements which are grandchildren
+
+ ::com::sun::star::uno::Any
+ m_aLeafElement; /// if the key represents a leaf, this is the value
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xLeafParent; /// if the key represents a leaf, this is it's parent. used for write access
+
+ ::rtl::OUString m_sLocalName; /** the name of the element relative to the parent, which would be
+ m_xLeafParent in case the key represents a value node
+ */
+
+ // TODO : the current concept does not recognize any changes in the config tree, i.e. the values stored
+ // in a configuration key wrapper are not changed if the value in the corresponding config node changes.
+ // Possible solutions:
+ // 1. on each value (or even on each sub key) access, the node is read from the configuration hierarchy, again.
+ // sounds very expensive.
+ // 2. each registry key is a listener on the node it represents.
+ // sounds expensive, too.
+ //
+ // At the moment we ignore this restriction, but perhaps we can't do that forever ....
+
+public:
+ /// when used as ctor parameter, this indicates that the key wraps a config tree subtree root
+ struct SubtreeRoot { };
+
+ /** builds an registry key which wraps the root of a configuration node
+ */
+ OConfigurationRegistryKey(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainerNode
+ ,sal_Bool _bWriteable
+ ,SubtreeRoot
+ );
+
+ /** builds an registry key for a configuration container node
+ @param _rxContainerNode the container the key should represent
+ @param _rLocalName the name of the node local to it's parent. Must be empty only if
+ the key represents the root node of a navigatable sub tree.
+ @param _bWriteable should the key be writeable ?
+ */
+ OConfigurationRegistryKey(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainerNode
+ ,const ::rtl::OUString& _rLocalName
+ ,sal_Bool _bWriteable
+ );
+
+ /** builds an registry key for a configuration value container node.
+ @param _rCurrentValue the current value of the node. Must be the same as _rxParentNode->getByName(_rRelativeName) would provide
+ @param _rxParentNode the parent of the value node. Used for update access and for obtaining the initial value.
+ @param _rRelativeName te relative name within the parent
+ @param _bWriteable should the key be writeable ?
+ */
+ OConfigurationRegistryKey(
+ ::com::sun::star::uno::Any _rCurrentValue
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxParentNode
+ ,const ::rtl::OUString& _rRelativeName
+ ,sal_Bool _bWriteable
+ );
+
+ // XRegistryKey
+ virtual ::rtl::OUString SAL_CALL getKeyName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::registry::RegistryKeyType SAL_CALL getKeyType( const ::rtl::OUString& rKeyName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::registry::RegistryValueType SAL_CALL getValueType( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getLongValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLongValue( sal_Int32 value ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLongListValue( const ::com::sun::star::uno::Sequence< sal_Int32 >& seqValue ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAsciiValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAsciiValue( const ::rtl::OUString& value ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAsciiListValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAsciiListValue( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& seqValue ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setStringValue( const ::rtl::OUString& value ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getStringListValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setStringListValue( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& seqValue ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::InvalidValueException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryValue( const ::com::sun::star::uno::Sequence< sal_Int8 >& value ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > SAL_CALL openKey( const ::rtl::OUString& aKeyName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > SAL_CALL createKey( const ::rtl::OUString& aKeyName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeKey( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteKey( const ::rtl::OUString& rKeyName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > > SAL_CALL openKeys( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getKeyNames( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL createLink( const ::rtl::OUString& aLinkName, const ::rtl::OUString& aLinkTarget ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteLink( const ::rtl::OUString& rLinkName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLinkTarget( const ::rtl::OUString& rLinkName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getResolvedName( const ::rtl::OUString& aKeyName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ /** specifies the kind of access to the key.
+ */
+ enum KEY_ACCESS_TYPE
+ {
+ KAT_META, /// access on a meta level, e.g. asking for the read-onyl flag
+ KAT_VALUE, /// read access to the value the node represents
+ KAT_VALUE_WRITE, /// write access to the value the node represents
+ KAT_CHILD /// access to one of the (grand-)children of the node
+ };
+
+ /** check if the registry key is valid
+ @param _eIntentedAccess type of access which the caller wants to perform on the object
+ @throws <type scope="com.sun.star.registry">InvalidRegistryException</type> if the key is invalid
+ */
+ void checkValid(KEY_ACCESS_TYPE _eIntentedAccess) throw (::com::sun::star::registry::InvalidRegistryException);
+
+ /** return an child element.
+ @param _rDescendantName the name of the descendant to open. May have a depth of more than 1, if
+ the node container support XHierarchicalNameAccess
+ @return the requested element. The caller can assume that the returned
+ <type scope="com.sun.star.uno">Any</type> always contains an object, all other cases are
+ handled with exceptions
+ @throws <type scope="com.sun.star.registry">InvalidRegistryException</type> if the key is invalid,
+ the element refered by _rName does not exist, the configuration node threw an exception, or
+ the name has a depth of more than one and the config node does not support this.
+ */
+ ::com::sun::star::uno::Any getDescendant(const ::rtl::OUString& _rDescendantName) throw(::com::sun::star::registry::InvalidRegistryException);
+
+ /** write the given value into the configuration node the object represents.
+ @throws <type scope="com.sun.star.registry">InvalidRegistryException</type> if the key is invalid,
+ not opened for write access or the configurations parent is not able to provide a value access
+ @throws <type scope="com.sun.star.uno">RuntimeException</type> if a fatal runtime error occurs
+ */
+ void writeValueNode(const ::com::sun::star::uno::Any& _rValue) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+
+ /** open the sub key (depth 1 or more) determined by the given name
+ @param _rKeyName the name of the descendant node
+ @return a XRegistryKey wrapper for the requested configuration node
+ @throws <type scope="com.sun.star.registry">InvalidRegistryException</type> if the key is invalid,
+ the element refered by _rName does not exist, the configuration node threw an exception, or
+ the name has a depth of more than one and the config node does not support this.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > OConfigurationRegistryKey::implGetKey( const ::rtl::OUString& _rKeyName ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+
+ /** check the given (relative) key name syntactically. In particular, this means that no checks are made if a node
+ with the given name exists or something like that ...
+ <BR>
+ In addition, the given name will be normalized. Basically, this means that it does not contain trailing slashes.
+ @throws InvalidRegistryException if the name is not relative (i.e. if it starts with an slash)
+ @throws InvalidRegistryException if the name is empty or consists of slashes only
+ */
+ void checkRelativeKeyName(::rtl::OUString& _rKeyName) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+};
+
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+#endif // _CONFIGMGR_REGISTRY_CFGREGISTRYKEY_HXX_
+
+
diff --git a/configmgr/source/registry/configregistry.cxx b/configmgr/source/registry/configregistry.cxx
new file mode 100644
index 000000000000..82d9eba7a743
--- /dev/null
+++ b/configmgr/source/registry/configregistry.cxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * $RCSfile: configregistry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _CONFIGMGR_REGISTRY_CONFIGREGISTRY_HXX_
+#include "configregistry.hxx"
+#endif
+#ifndef _CONFIGMGR_REGISTRY_CFGREGISTRYKEY_HXX_
+#include "cfgregistrykey.hxx"
+#endif
+
+#ifndef _UTL_SEQUENCE_HXX_
+#include <unotools/sequence.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#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_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+
+#define THISREF() static_cast< ::cppu::OWeakObject* >(this)
+#define UNISTRING(c) ::rtl::OUString::createFromAscii(c)
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::container;
+using namespace ::osl;
+using namespace ::cppu;
+
+//==========================================================================
+//= OConfigurationRegistry
+//==========================================================================
+
+ static const AsciiServiceName aConfigRegistryServices[] =
+ {
+ "com.sun.star.registry.SimpleRegistry",
+ "com.sun.star.configuration.ConfigurationRegistry",
+ NULL
+ };
+ const ServiceInfo OConfigurationRegistry::s_aServiceInfo =
+ {
+ "com.sun.star.configuration.configmgr.OConfigurationRegistry",
+ aConfigRegistryServices
+ };
+
+ Reference< XInterface > SAL_CALL instantiateConfigRegistry(Reference< XMultiServiceFactory > const& _rServiceManager )
+ {
+ return static_cast< ::cppu::OWeakObject* >(new OConfigurationRegistry(_rServiceManager));
+ }
+
+ const ServiceInfo* getConfigurationRegistryServiceInfo()
+ {
+ return &OConfigurationRegistry::s_aServiceInfo;
+ }
+
+//--------------------------------------------------------------------------
+OConfigurationRegistry::OConfigurationRegistry(const Reference< XMultiServiceFactory >& _rORB) throw(Exception, RuntimeException)
+ :ServiceComponentImpl(&s_aServiceInfo)
+ ,m_xORB(_rORB)
+ ,m_aFlushListeners(m_aMutex)
+{
+ // create the configuration provider used for accessing the configuration
+ OSL_ENSHURE(m_xORB.is(), "OConfigurationRegistry::OConfigurationRegistry : invalid service factory !");
+ if (m_xORB.is())
+ m_xConfigurationProvider =
+ Reference< XMultiServiceFactory > (
+ m_xORB->createInstance(UNISTRING("com.sun.star.configuration.ConfigurationProvider")),
+ UNO_QUERY
+ );
+
+ if (!m_xConfigurationProvider.is())
+ // it's heavily needed ...
+ throw ServiceNotRegisteredException(UNISTRING("Failed to instantiate the mandatory service com.sun.star.configuration.ConfigurationProvider."),
+ THISREF());
+}
+
+//--------------------------------------------------------------------------
+Any SAL_CALL OConfigurationRegistry::queryInterface( const Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = ServiceComponentImpl::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = OConfigurationRegistry_Base::queryInterface(_rType);
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OConfigurationRegistry::getTypes( ) throw(RuntimeException)
+{
+ return ::utl::concatSequences(
+ ServiceComponentImpl::getTypes(),
+ OConfigurationRegistry_Base::getTypes());
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OConfigurationRegistry::getImplementationId( ) throw(RuntimeException)
+{
+ static OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString OConfigurationRegistry::getNodePathFromURL(const ::rtl::OUString& _rURL)
+{
+ // TODO
+ return _rURL;
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConfigurationRegistry::getURL() throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_sLocation;
+}
+
+//--------------------------------------------------------------------------
+void OConfigurationRegistry::checkOpen() throw(InvalidRegistryException, RuntimeException)
+{
+ if (!isOpen())
+ throw InvalidRegistryException(UNISTRING("The registry is not bound to a configuration node."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::open( const ::rtl::OUString& _rURL, sal_Bool _bReadOnly, sal_Bool _bCreate ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if (isOpen())
+ close();
+
+ ::rtl::OUString sNodePath = getNodePathFromURL(_rURL);
+
+ if (!m_xConfigurationProvider.is())
+ throw RuntimeException(UNISTRING("invalid object. configuration provider is already disposed."), THISREF());
+
+ Reference< XInterface > xNodeAccess;
+ try
+ {
+ // the one and only parameter for creating the config access : the node path
+ Sequence< Any > aArguments(1);
+ aArguments[0] <<= sNodePath;
+
+ if (_bReadOnly)
+ xNodeAccess = m_xConfigurationProvider->createInstanceWithArguments(UNISTRING("com.sun.star.configuration.ConfigurationAccess"), aArguments);
+ else
+ xNodeAccess = m_xConfigurationProvider->createInstanceWithArguments(UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArguments);
+ }
+ catch (RuntimeException&)
+ { // allowed to leave this method
+ throw;
+ }
+ catch (Exception& e)
+ { // not allowed to leave this method
+ ::rtl::OUString sMessage = UNISTRING("The configuration provider does not supply a registry access for the requested Node.");
+ sMessage += UNISTRING(" original error message of the provider : ");
+ sMessage += e.Message;
+ throw InvalidRegistryException(sMessage, THISREF());
+ }
+
+ Reference< XNameAccess > xReadRoot(xNodeAccess, UNO_QUERY);
+ if (!_bReadOnly)
+ m_xUpdateRoot = m_xUpdateRoot.query(xNodeAccess);
+
+ if (!xReadRoot.is() || (!_bReadOnly && !m_xUpdateRoot.is()))
+ throw InvalidRegistryException(UNISTRING("The object supplied the by configuration provider is invalid."), THISREF());
+
+ m_xRootKey = new OConfigurationRegistryKey(xReadRoot, !_bReadOnly, OConfigurationRegistryKey::SubtreeRoot());
+ m_xSubtreeRoot = xNodeAccess;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OConfigurationRegistry::isValid( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_xRootKey.is();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::close( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if (m_xRootKey.is())
+ m_xRootKey->closeKey();
+ m_xRootKey = NULL;
+
+ Reference< XComponent > xRootComponent(m_xSubtreeRoot, UNO_QUERY);
+ if (xRootComponent.is())
+ xRootComponent->dispose();
+ m_xSubtreeRoot = NULL;
+ m_xUpdateRoot = NULL;
+
+ m_sLocation = ::rtl::OUString();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::destroy( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ throw InvalidRegistryException(UNISTRING("This registry is a wrapper for a configuration access. It can not be destroyed."), THISREF());
+}
+
+//--------------------------------------------------------------------------
+Reference< XRegistryKey > SAL_CALL OConfigurationRegistry::getRootKey( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkOpen();
+
+ return m_xRootKey;
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OConfigurationRegistry::isReadOnly( ) throw(InvalidRegistryException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkOpen();
+
+ return !m_xUpdateRoot.is();
+ // if we don't have the update root, we're readonly
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::mergeKey( const ::rtl::OUString& aKeyName, const ::rtl::OUString& aUrl ) throw(InvalidRegistryException, MergeConflictException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ // not supported. but we can't throw an NoSupportException here ...
+ throw InvalidRegistryException(UNISTRING("You can't merge into this registry. It's just a wrapper for a configuration node, which has a fixed structure which can not be modified"), THISREF());
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::flush( ) throw(RuntimeException)
+{
+ {
+ MutexGuard aGuard(m_aMutex);
+
+ try
+ {
+ m_xUpdateRoot->commitChanges();
+ }
+ catch (WrappedTargetException& e)
+ { // not allowed to leave this method
+ // TODO : the specification of XFlushable has to be changed !!!!!
+ OSL_ENSHURE(sal_False, "OConfigurationRegistry::flush : caught an exception, could not flush the data !");
+ return;
+// ::rtl::OUString sMessage;
+// sMessage = UNISTRING("The changes made could not be committed. Orginal exception message : ");
+// sMessage += e.Message;
+// throw RuntimeException(sMessage, THISREF());
+ }
+ }
+
+ EventObject aFlushed(THISREF());
+ ::cppu::OInterfaceIteratorHelper aIter(m_aFlushListeners);
+ while (aIter.hasMoreElements())
+ static_cast< XFlushListener* >(aIter.next())->flushed(aFlushed);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::addFlushListener( const Reference< XFlushListener >& _rxListener ) throw(RuntimeException)
+{
+ m_aFlushListeners.addInterface(_rxListener);
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OConfigurationRegistry::removeFlushListener( const Reference< XFlushListener >& _rxListener ) throw(RuntimeException)
+{
+ m_aFlushListeners.removeInterface(_rxListener);
+}
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+
diff --git a/configmgr/source/registry/configregistry.hxx b/configmgr/source/registry/configregistry.hxx
new file mode 100644
index 000000000000..661aa6b2bb32
--- /dev/null
+++ b/configmgr/source/registry/configregistry.hxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * $RCSfile: configregistry.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONFIGMGR_REGISTRY_CONFIGREGISTRY_HXX_
+#define _CONFIGMGR_REGISTRY_CONFIGREGISTRY_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef CONFIGMGR_API_SVCCOMPONENT_HXX_
+#include "confsvccomponent.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
+#include <com/sun/star/util/XFlushable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCHANGESBATCH_HPP_
+#include <com/sun/star/util/XChangesBatch.hpp>
+#endif
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+//==========================================================================
+//= OConfigurationRegistry
+//==========================================================================
+typedef ::cppu::ImplHelper2 < ::com::sun::star::registry::XSimpleRegistry
+ , ::com::sun::star::util::XFlushable
+ > OConfigurationRegistry_Base;
+
+/** an object implmenting the <service scope="com.sun.star.configuration">ConfigurationRegistry</service>
+ service.
+*/
+class OConfigurationRegistry
+ :public ServiceComponentImpl
+ ,public OConfigurationRegistry_Base
+{
+public:
+ static const ServiceInfo s_aServiceInfo;
+
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB; /// the service provider used for creating the instance
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xConfigurationProvider; /// the configuration provider used for creating configuration accesses
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey >
+ m_xRootKey; /// the root key for the registry-like configuration access
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xSubtreeRoot; /// the root of the sub tree the object wraps
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch >
+ m_xUpdateRoot; /// the update access to the root of the sub tree, valid if opened for writing
+ ::rtl::OUString m_sLocation; /// URL of the configuration node we're representing, if any
+
+ ::cppu::OInterfaceContainerHelper
+ m_aFlushListeners;
+
+
+public:
+ OConfigurationRegistry(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rORB)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw() { ServiceComponentImpl::acquire(); }
+ virtual void SAL_CALL release( ) throw() { ServiceComponentImpl::release(); }
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XSimpleRegistry
+ virtual ::rtl::OUString SAL_CALL getURL() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL open( const ::rtl::OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL close( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL destroy( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > SAL_CALL getRootKey( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mergeKey( const ::rtl::OUString& aKeyName, const ::rtl::OUString& aUrl ) throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::registry::MergeConflictException, ::com::sun::star::uno::RuntimeException);
+
+ // XFlushable
+ virtual void SAL_CALL flush( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual void SAL_CALL disposing() { ServiceComponentImpl::disposing(); }
+ /// translates the given URL into a nodepath which may be used with the configuration provider
+ ::rtl::OUString getNodePathFromURL(const ::rtl::OUString& _rURL);
+
+ void checkOpen() throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
+
+ sal_Bool isOpen() { return isValid(); }
+};
+
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+#endif // _CONFIGMGR_REGISTRY_CONFIGREGISTRY_HXX_
+
+
diff --git a/configmgr/source/registry/makefile.mk b/configmgr/source/registry/makefile.mk
new file mode 100644
index 000000000000..70653bc4fe59
--- /dev/null
+++ b/configmgr/source/registry/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source$/inc
+PRJNAME=configmgr
+TARGET=registry
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/configregistry.obj \
+ $(SLO)$/cfgregistrykey.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/configmgr/source/tree/changes.cxx b/configmgr/source/tree/changes.cxx
new file mode 100644
index 000000000000..0181578b88fe
--- /dev/null
+++ b/configmgr/source/tree/changes.cxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * $RCSfile: changes.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <stdio.h>
+#include "cmtreemodel.hxx"
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+using namespace configmgr;
+
+//==========================================================================
+//= ValueChange
+//==========================================================================
+// -------------------------------------------------------------------------
+ValueChange::ValueChange(OUString const& _rName,Any aNewValue, Mode aMode, Any aOldValue)
+ : Change(_rName)
+ ,m_aValue(aNewValue)
+ ,m_aOldValue(aOldValue)
+ ,m_eMode(aMode)
+{
+}
+// -------------------------------------------------------------------------
+ValueChange::ValueChange(Any aNewValue, ValueNode const& aOldValue)
+ : Change(aOldValue.getName())
+ ,m_aValue(aNewValue)
+ ,m_aOldValue(aOldValue.getValue())
+{
+ m_eMode = aOldValue.isDefault() ? wasDefault : changeValue;
+}
+// -------------------------------------------------------------------------
+ValueChange::ValueChange(SetToDefault, ValueNode const& aOldValue)
+ : Change(aOldValue.getName())
+ ,m_aValue(aOldValue.getDefault())
+ ,m_aOldValue(aOldValue.getValue())
+ ,m_eMode(setToDefault)
+{
+}
+
+// -------------------------------------------------------------------------
+namespace tree_changes_internal {
+ inline void doAdjust(uno::Any& aActual, uno::Any const& aTarget)
+ {
+ // If set - it should already match
+ OSL_ASSERT(!aActual.hasValue() || aTarget == aActual);
+ aActual = aTarget;
+ }
+}
+using namespace tree_changes_internal;
+
+// -------------------------------------------------------------------------
+void ValueChange::applyTo(ValueNode& aValue)
+{
+ switch (getMode())
+ {
+ case wasDefault:
+ OSL_ASSERT(aValue.isDefault());
+ case changeValue:
+ doAdjust( m_aOldValue, aValue.getValue());
+ aValue.setValue(getNewValue());
+ break;
+
+ case setToDefault:
+ doAdjust( m_aOldValue, aValue.getValue());
+ doAdjust( m_aValue, aValue.getDefault());
+ aValue.setDefault();
+ break;
+
+ case changeDefault:
+ doAdjust( m_aOldValue, aValue.getDefault());
+ aValue.changeDefault(getNewValue());
+ break;
+
+ default:
+ OSL_ENSHURE(0, "Unknown mode found for ValueChange");
+ break;
+ }
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString ValueChange::getModeAsString() const
+{
+ ::rtl::OUString aRet;
+ switch(m_eMode)
+ {
+ case wasDefault:
+ aRet = ::rtl::OUString::createFromAscii("wasDefault");
+ break;
+ case changeValue:
+ aRet = ::rtl::OUString::createFromAscii("changeValue");
+ break;
+ case setToDefault:
+ aRet = ::rtl::OUString::createFromAscii("setToDefault");
+ break;
+ case changeDefault:
+ aRet = ::rtl::OUString::createFromAscii("changeDefault");
+ break;
+ default:
+ OSL_ENSHURE(0,"getModeAsString: Wrong mode!");
+ }
+
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void ValueChange::setModeAsString(const ::rtl::OUString& _rMode)
+{
+ if(_rMode == ::rtl::OUString::createFromAscii("wasDefault")) m_eMode = wasDefault;
+ else if(_rMode == ::rtl::OUString::createFromAscii("changeValue")) m_eMode = changeValue;
+ else if(_rMode == ::rtl::OUString::createFromAscii("setToDefault")) m_eMode = setToDefault;
+ else if(_rMode == ::rtl::OUString::createFromAscii("changeDefault"))m_eMode = changeDefault;
+ else
+ {
+ OSL_ENSHURE(0,"setModeAsString: Wrong mode!");
+ }
+}
+
+//==========================================================================
+//= AddNode
+//==========================================================================
+//--------------------------------------------------------------------------
+AddNode::AddNode(std::auto_ptr<INode> aNewNode_, OUString const& _rName)
+ :Change(_rName)
+ ,m_aOwnNewNode(aNewNode_)
+{
+ m_pNewNode = m_aOwnNewNode.get();
+}
+
+//--------------------------------------------------------------------------
+AddNode::~AddNode()
+{
+}
+
+//--------------------------------------------------------------------------
+
+
diff --git a/configmgr/source/tree/cmtree.cxx b/configmgr/source/tree/cmtree.cxx
new file mode 100644
index 000000000000..ea565365f3e8
--- /dev/null
+++ b/configmgr/source/tree/cmtree.cxx
@@ -0,0 +1,719 @@
+/*************************************************************************
+ *
+ * $RCSfile: cmtree.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */
+
+#include <stl/deque>
+#include <stl/vector>
+#include <iostream>
+#include <exception>
+#include <sal/types.h>
+#include <stl/set>
+#include <rtl/string.hxx>
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+
+#include "cmtree.hxx"
+#include "confname.hxx" // Iterator for PathName scans
+#include "cmtreemodel.hxx"
+
+#include <com/sun/star/uno/Any.hxx>
+
+#ifndef _CONFIGMGR_TREEACCESS_HXX_
+#include "treeaccess.hxx"
+#endif
+
+// WISDOM
+// !!Never write same code twice!!
+
+using namespace std;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace configmgr
+{
+
+// ------------------------ ChildListSet implementations ------------------------
+ ChildListSet::ChildListSet(ChildListSet const& aSet)
+ {
+ for(ChildList::iterator it = aSet.GetSet().begin();
+ it != aSet.GetSet().end();
+ ++it)
+ m_aChildList.insert(m_aChildList.end(), (*it)->clone());
+ }
+ ChildListSet::~ChildListSet()
+ {
+ for(ChildList::iterator it = m_aChildList.begin();
+ it != m_aChildList.end();
+ ++it)
+ delete *it;
+ }
+
+
+// ---------------------------- Node implementation ----------------------------
+
+ INode::INode(){}
+ INode::INode(OUString const& aName)
+ :m_aName(aName){}
+ // CopyCTor will be create automatically
+
+ INode::~INode() {}
+
+ // Node* Node::clone() {}
+
+ OUString INode::getName() const {return m_aName;}
+ NodeAttributes INode::getAttributes() const {return m_aNodeAttribute;}
+
+ ISubtree* INode::asISubtree(){return NULL;}
+ ISubtree const* INode::asISubtree() const {return NULL;}
+ ValueNode* INode::asValueNode() {return NULL;}
+ ValueNode const* INode::asValueNode() const {return NULL;}
+
+
+// ------------------------- SearchNode implementation -------------------------
+ SearchNode::SearchNode(){}
+ SearchNode::SearchNode(OUString const& aName)
+ :INode(aName){}
+
+ INode* SearchNode::clone() const {return new SearchNode(*this);}
+
+ OUString SearchNode::getName() const {return getName();}
+ SearchNode::~SearchNode(){}
+
+
+// -------------------------- ISubtree implementation --------------------------
+ ISubtree* ISubtree::asISubtree() {return this;}
+ ISubtree const* ISubtree::asISubtree() const {return this;}
+
+// --------------------------- Subtree implementation ---------------------------
+
+ Subtree::Subtree(OUString const& aName)
+ :ISubtree(aName)
+ ,m_nLevel(0)
+ ,m_bComplete(sal_False)
+ {
+ }
+ Subtree::Subtree()
+ :m_nLevel(0)
+ ,m_bComplete(sal_False)
+ {
+ }
+ Subtree::~Subtree() {}
+
+// #pragma message("__FILE__(__LINE__) Subtree::clone() has empty implementation")
+ INode* Subtree::clone() const {return new Subtree(*this);}
+
+// #define MAX_NODE_NAME_LENGTH 256
+
+// RECURSIVE: Node* Subtree::createChild(OUString const& aPath)
+// RECURSIVE: {
+// RECURSIVE: //? configmgr::Node searchObj(aName);
+// RECURSIVE: //? ChildList::iterator it = m_aNode->GetSet().find(&searchObj);
+// RECURSIVE: //? if (it == m_aNode->GetSet().end())
+// RECURSIVE: //? return NULL;
+// RECURSIVE: //? else
+// RECURSIVE: //? return *it;
+// RECURSIVE: sal_Unicode aName[MAX_NODE_NAME_LENGTH];
+// RECURSIVE: int nStartPos = 0;
+// RECURSIVE: int nPos = 0;
+// RECURSIVE:
+// RECURSIVE: if (aPath[0] == '/')
+// RECURSIVE: {
+// RECURSIVE: nStartPos++;
+// RECURSIVE: }
+// RECURSIVE: if (aPath[nStartPos] == '\0')
+// RECURSIVE: {
+// RECURSIVE: return this;
+// RECURSIVE: }
+// RECURSIVE:
+// RECURSIVE: int nEndPos = nStartPos;
+// RECURSIVE: while ((aPath[nEndPos] != '\0') && (aPath[nEndPos] != '/')) {
+// RECURSIVE: aName[nPos++] = aPath[nEndPos++];
+// RECURSIVE: }
+// RECURSIVE: aName[nPos] = '\0';
+// RECURSIVE:
+// RECURSIVE: #ifdef DEBUG
+// RECURSIVE: // list(cout << " searching for [" << aName << "] in\n");
+// RECURSIVE: #endif
+// RECURSIVE:
+// RECURSIVE: // search Node
+// RECURSIVE: SearchNode searchObj(aName);
+// RECURSIVE: ChildList::iterator it = m_aChildren->GetSet().find(&searchObj);
+// RECURSIVE: if (it == m_aChildren->GetSet().end())
+// RECURSIVE: {
+// RECURSIVE: // create new Child
+// RECURSIVE: auto_ptr<Node> pSubtree( new Subtree(aName));
+// RECURSIVE: Node *pN = addChild(pSubtree);
+// RECURSIVE: Subtree *pS = (Subtree*)pN;
+// RECURSIVE: return pS->createChild(aPath + nEndPos);
+// RECURSIVE: }
+// RECURSIVE: else {
+// RECURSIVE: // call recursive the inner child
+// RECURSIVE: Node *pN = *it;
+// RECURSIVE: Subtree *pP = (Subtree*)pN;
+// RECURSIVE: return pP->createChild(aPath + nEndPos);
+// RECURSIVE: }
+// RECURSIVE: }
+
+ INode* Subtree::createChild(OUString const& aName)
+ {
+ // POST: create Subtree if not found
+
+ // search Node
+ SearchNode searchObj(aName);
+ ChildList::iterator it = m_aChildren.GetSet().find(&searchObj);
+ if (it == m_aChildren.GetSet().end())
+ {
+ // create new Child
+ auto_ptr<INode> pSubtree( new Subtree(aName));
+ return addChild(pSubtree);
+ }
+ return *it;
+ }
+
+ INode* Subtree::doGetChild(OUString const& aName) const
+ {
+ SearchNode searchObj(aName);
+ ChildList::iterator it = m_aChildren.GetSet().find(&searchObj);
+ if (it == m_aChildren.GetSet().end())
+ return NULL;
+ else
+ return *it;
+ }
+
+ INode* Subtree::addChild(std::auto_ptr<INode> aNode) // takes ownership
+ {
+ OUString aName = aNode->getName();
+ std::pair<ChildList::iterator, bool> aInserted =
+ m_aChildren.GetSet().insert(aNode.get());
+ if (aInserted.second)
+ aNode.release();
+ return *aInserted.first;
+ }
+
+ ::std::auto_ptr<INode> Subtree::removeChild(OUString const& aName)
+ {
+ SearchNode searchObj(aName);
+ ChildList::const_iterator it = m_aChildren.GetSet().find(&searchObj);
+
+ ::std::auto_ptr<INode> aReturn;
+ if (m_aChildren.GetSet().end() != it)
+ {
+ aReturn = ::std::auto_ptr<INode>(*it);
+ m_aChildren.GetSet().erase(it);
+ }
+ return aReturn;
+ }
+
+ struct OPropagateLevels : public NodeModification
+ {
+ protected:
+ sal_Int32 nChildLevel;
+ public:
+ OPropagateLevels(sal_Int32 _nParentLevel)
+ {
+ nChildLevel = (ITreeProvider::ALL_LEVELS == _nParentLevel) ? ITreeProvider::ALL_LEVELS : _nParentLevel - 1;
+ }
+ virtual void handle(ValueNode&) { /* not interested in value nodes */ }
+ virtual void handle(ISubtree& _rSubtree)
+ {
+ if ((ITreeProvider::ALL_LEVELS == nChildLevel) || (nChildLevel > 0))
+ {
+ OPropagateLevels aDeeperInto(nChildLevel);
+ aDeeperInto.applyToChildren(_rSubtree);
+ }
+ }
+ };
+
+ void Subtree::setLevel(sal_Int16 _nLevel)
+ {
+ m_nLevel = _nLevel;
+ if (0 == _nLevel)
+ // nothing more to do, this means "nothing known about any children"
+ return;
+
+ // forward the level number to any child subtrees we have
+ OPropagateLevels aDeeperInto(_nLevel);
+ aDeeperInto.applyToChildren(*this);
+ }
+
+ void Subtree::forEachChild(NodeAction& anAction) const {
+ for(ChildList::const_iterator it = m_aChildren.GetSet().begin();
+ it != m_aChildren.GetSet().end();
+ ++it)
+ (**it).dispatch(anAction);
+ }
+
+ void Subtree::forEachChild(NodeModification& anAction) {
+ for(ChildList::iterator it = m_aChildren.GetSet().begin();
+ it != m_aChildren.GetSet().end();
+ ++it)
+ (**it).dispatch(anAction);
+ }
+
+// -------------------------- ValueNode implementation --------------------------
+ void ValueNode::check_init() // may throw in the future
+ {
+ if (m_aValue.hasValue())
+ {
+ OSL_ASSERT(m_aType != ::getVoidCppuType());
+ OSL_ASSERT(m_aType == m_aValue.getValueType());
+ }
+ else OSL_ASSERT(getVoidCppuType() == m_aValue.getValueType());
+
+ if (m_aDefaultValue.hasValue())
+ {
+ OSL_ASSERT(m_aType != ::getVoidCppuType());
+ OSL_ASSERT(m_aType == m_aDefaultValue.getValueType());
+ }
+ else OSL_ASSERT(getVoidCppuType() == m_aDefaultValue.getValueType());
+ }
+
+ void ValueNode::init()
+ {
+ OSL_ASSERT(m_aType == ::getVoidCppuType());
+
+ if (m_aDefaultValue.hasValue())
+ {
+ m_aType = m_aDefaultValue.getValueType();
+ OSL_ASSERT(m_aType != ::getVoidCppuType());
+ }
+ else if (m_aValue.hasValue())
+ {
+ m_aType = m_aValue.getValueType();
+ OSL_ASSERT(m_aType != ::getVoidCppuType());
+ }
+ }
+
+ bool ValueNode::isDefault() const
+ {
+ // POST: true, if only m_aDefaultValue is set.
+ return !m_aValue.hasValue() && hasDefault();
+ }
+
+ bool ValueNode::hasDefault() const
+ {
+ // POST: true, if only m_aDefaultValue is set.
+ return getAttributes().optional || m_aDefaultValue.hasValue();
+ }
+
+ bool ValueNode::isNull() const
+ {
+ // POST: true, if neither Any is set.
+ return !m_aValue.hasValue() && !m_aDefaultValue.hasValue();
+ }
+
+
+ Type ValueNode::getValueType() const
+ {
+ // POST: return Type of Any
+ return m_aType;
+ }
+
+ Any ValueNode::getValue() const
+ {
+ // POST: getValue, if not set, get DefaultValue
+ if (isDefault())
+ return m_aDefaultValue;
+ return m_aValue;
+ }
+
+ Any ValueNode::getDefault() const
+ {
+ return m_aDefaultValue;
+ }
+
+
+ void ValueNode::setValue(Any aValue)
+ {
+ m_aValue = aValue;
+ }
+
+ void ValueNode::changeDefault(Any aValue)
+ {
+ m_aDefaultValue = aValue;
+ }
+
+ void ValueNode::setDefault()
+ {
+ // PRE: ????
+ // POST: isDefault() == true
+ m_aValue = Any();
+ }
+
+ INode* ValueNode::clone() const
+ {
+ return new ValueNode(*this);
+ }
+
+ ValueNode* ValueNode::asValueNode() {return this;}
+ ValueNode const* ValueNode::asValueNode() const {return this;}
+
+// ---------------------------- Tree implementation ----------------------------
+
+ Tree::Tree()
+ : m_pRoot(NULL), m_pLock(NULL)
+ {
+ m_pRoot = new Subtree();
+ m_pLock = new OTreeAccessor;
+ }
+
+ Tree::~Tree()
+ {
+ delete m_pLock;
+ }
+
+ void Tree::acquireReadAccess() const
+ {
+ m_pLock->acquireReadAccess();
+ }
+
+ void Tree::releaseReadAccess() const
+ {
+ m_pLock->releaseReadAccess();
+ }
+
+ void Tree::acquireWriteAccess()
+ {
+ m_pLock->acquireWriteAccess();
+ }
+
+ void Tree::releaseWriteAccess()
+ {
+ m_pLock->releaseWriteAccess();
+ }
+
+// -----------------------------------------------------------------------------
+ ISubtree* Tree::requestSubtree( OUString const& aComponentName, sal_Int16 nLevel )
+ {
+ // OLD:
+ // INode* pResult = m_pRoot->getChild(aComponentName);
+ // return pResult->asISubtree();
+
+ // Build SearchName
+ OSL_ENSHURE(m_pRoot, "Tree::requestSubtree : m_pRoot MUST NOT BE ZERO");
+ // hey, don't cry that loud ....
+
+ ISubtree* pSubtree = m_pRoot;
+ ConfigurationName aConfigName(aComponentName,ConfigurationName::Absolute() );
+ for(ConfigurationName::Iterator it = aConfigName.begin();
+ it != aConfigName.end();
+ ++it)
+ {
+ if (pSubtree)
+ {
+ INode* pNode = pSubtree->getChild(*it);
+ if (!pNode)
+ return NULL;
+
+ pSubtree = pNode->asISubtree();
+ }
+ else
+ break;
+ }
+
+ if (pSubtree && (ALL_LEVELS != pSubtree->getLevel()) && (nLevel > pSubtree->getLevel()))
+ pSubtree = NULL;
+ return pSubtree;
+ }
+
+// -----------------------------------------------------------------------------
+ const INode* Tree::getNode(const OUString& _rPath)
+ {
+ OSL_ENSHURE(m_pRoot, "Tree::getNode : invalid root !");
+
+ ConfigurationName aPath(_rPath, ConfigurationName::Absolute() );
+
+ INode* pNodeLoop = m_pRoot;
+ for ( ConfigurationName::Iterator aSearch = aPath.begin();
+ (aSearch != aPath.end()) && pNodeLoop;
+ ++aSearch)
+ {
+ ISubtree* pNodeContainer = pNodeLoop->asISubtree();
+ if (pNodeContainer)
+ pNodeLoop = pNodeContainer->getChild(*aSearch);
+ else
+ return NULL;
+ }
+
+ return pNodeLoop;
+ }
+
+// -----------------------------------------------------------------------------
+ ISubtree const* Tree::getSubtree( OUString const& aComponentName ) const
+ {
+ // Build SearchName
+ OSL_ENSHURE(m_pRoot, "m_pRoot MUST NOT BE ZERO");
+
+ ISubtree const* pSubtree = m_pRoot;
+ ConfigurationName aConfigName(aComponentName,ConfigurationName::Absolute() );
+ for(ConfigurationName::Iterator it = aConfigName.begin();
+ it != aConfigName.end();
+ ++it)
+ {
+ if (pSubtree)
+ {
+ const INode* pNode = pSubtree->getChild(*it);
+ if (!pNode)
+ return NULL;
+
+ pSubtree = pNode->asISubtree();
+ }
+ else
+ break;
+ }
+ return pSubtree;
+ /*
+ sal_Unicode aName[MAX_NODE_NAME_LENGTH];
+ int nStartPos = 0;
+ int nPos = 0;
+
+ if (aPath[0] == '/')
+ {
+ nStartPos++;
+ }
+ if (aPath[nStartPos] == '\0')
+ {
+ return this;
+ }
+
+ int nEndPos = nStartPos;
+ while ((aPath[nEndPos] != '\0') && (aPath[nEndPos] != '/')) {
+ aName[nPos++] = aPath[nEndPos++];
+ }
+ aName[nPos] = '\0';
+
+ ISubtree const* pSubtree = m_pRoot->getChild(aName)->asISubtree();
+
+
+ if (pSubtree)
+ {
+ // call recursive the inner child
+ return pSubtree->getSubtree(aPath + nEndPos);
+ }
+ return NULL;
+ */
+ }
+
+ Subtree * Tree::addSubtree(const ConfigurationName& _rLocation, std::auto_ptr<Subtree> _pSubtree, sal_Int16 nLevels)
+ {
+ OSL_ENSHURE(nLevels != 0, "Tree::addSubtree : invalid level count !");
+ // there was a time where 0 meant "all levels", but we changed the according enum in ITReeProvider
+ // so that it is -1 now. Since this time, 0 isn't valid as level depth anymore !
+
+ auto_ptr<INode> pNode;
+
+ // look for the place where to insert the given node
+ ConfigurationName::Iterator aGoDown = _rLocation.begin();
+ ConfigurationName::Iterator aStopAt = _rLocation.end();
+ Subtree* pInsertInto = m_pRoot;
+ while (aGoDown != aStopAt)
+ {
+ OUString sCurrentName = *aGoDown;
+ ++aGoDown;
+
+ Subtree* pExistentSubtree = static_cast<Subtree*>(pInsertInto->getChild(sCurrentName));
+ if (!pExistentSubtree)
+ {
+ Subtree* pNewChild = NULL;
+ if (aGoDown != aStopAt)
+ { // we already incremented aGoDown, so this means we still have (at least) one level to go
+ // -> we need a new temporary node
+ pNewChild = new Subtree(sCurrentName);
+ pNewChild = static_cast<Subtree*>(pInsertInto->addChild(::std::auto_ptr<INode>(pNewChild)));
+ pNewChild->setLevel(0); // which means "we know nothing about any children"
+ }
+ else
+ { // at this last level, we don't need an intermediate node, instead we have to insert _pSubtree here
+ break;
+ }
+ pExistentSubtree = pNewChild;
+ }
+
+ // one level down
+ pInsertInto = pExistentSubtree;
+ }
+
+ Subtree* pNewSubtree = static_cast<Subtree*>(pInsertInto->addChild(::std::auto_ptr<INode>(_pSubtree.release())));
+ pNewSubtree->setLevel(nLevels);
+ return pNewSubtree;
+ }
+
+
+ // --------------------------------- updateTree ---------------------------------
+ class TreeUpdate : public ChangeTreeModification
+ {
+ ISubtree* m_pCurrentSubtree;
+ std::vector<OString> aLog;
+
+ public:
+ TreeUpdate(ISubtree* pSubtree):m_pCurrentSubtree(pSubtree){}
+
+ void handle(ValueChange& aValueNode);
+ void handle(AddNode& aAddNode);
+ void handle(RemoveNode& aRemoveNode);
+ void handle(SubtreeChange& aSubtree);
+ };
+
+ void TreeUpdate::handle(ValueChange& aValueNode)
+ {
+ // Change a Value
+ OSL_ENSURE(m_pCurrentSubtree,"Cannot apply ValueChange without subtree");
+
+ INode* pBaseNode = m_pCurrentSubtree ? m_pCurrentSubtree->getChild(aValueNode.getNodeName()) : 0;
+ OSL_ENSURE(pBaseNode,"Cannot apply Change: No node to change");
+
+ ValueNode* pValue = pBaseNode ? pBaseNode->asValueNode() : 0;
+ OSL_ENSURE(pValue,"Cannot apply ValueChange: Node is not a value");
+
+ if (pValue)
+ aValueNode.applyTo(*pValue);
+#ifdef DBUG
+ else
+ {
+ ::rtl::OString aStr("TreeUpdate: Can't find value with name:=");
+ aStr += rtl::OUStringToOString(aValueNode.getNodeName(),RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(pValue, aStr.getStr());
+ aLog.push_back(aStr);
+ }
+#endif
+ }
+
+ void TreeUpdate::handle(AddNode& aAddNode)
+ {
+ // Add a new Value
+ if (m_pCurrentSubtree)
+ m_pCurrentSubtree->addChild(aAddNode.releaseAddedNode());
+#ifdef DBUG
+ else
+ aLog.push_back(OString("TreeUpdate: no CurrentSubtree for AddNode"));
+#endif
+
+ }
+
+ void TreeUpdate::handle(RemoveNode& aRemoveNode)
+ {
+ // remove a Value
+ if (m_pCurrentSubtree)
+ {
+ sal_Bool bOk = (NULL != m_pCurrentSubtree->removeChild(aRemoveNode.getNodeName()).get());
+
+#ifdef DBUG
+ ::rtl::OString aStr("TreeUpdate: Can't remove child with name:=");
+ aStr += rtl::OUStringToOString(aRemoveNode.getNodeName(),RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(bOk, aStr.getStr());
+ if (!bOk)
+ aLog.push_back(aStr);
+#endif
+ }
+ }
+
+
+ void TreeUpdate::handle(SubtreeChange& aSubtree)
+ {
+ // handle traversion
+ ISubtree *pOldSubtree = m_pCurrentSubtree;
+ OSL_ENSHURE(m_pCurrentSubtree->getChild(aSubtree.getNodeName()), "TreeUpdate::handle : invalid subtree change ... this will crash !");
+ m_pCurrentSubtree = m_pCurrentSubtree->getChild(aSubtree.getNodeName())->asISubtree();
+
+#if DEBUG
+ ::rtl::OString aStr("TreeUpdate: there is no Subtree for name:=");
+ aStr += rtl::OUStringToOString(aSubtree.getNodeName(),RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(m_pCurrentSubtree, aStr.getStr());
+ if (!m_pCurrentSubtree)
+ aLog.push_back(aStr);
+#endif
+
+ aSubtree.forEachChange(*this);
+ m_pCurrentSubtree = pOldSubtree;
+ }
+
+
+ void Tree::updateTree( TreeChangeList& aTree) throw (starlang::WrappedTargetException, uno::RuntimeException)
+ {
+ ConfigurationName aSubtreeName(aTree.pathToRoot, aTree.root.getNodeName());
+ ISubtree *pSubtree = requestSubtree(aSubtreeName.fullName(), ITreeProvider::ALL_LEVELS);
+
+#ifdef DEBUG
+ ::rtl::OString aStr("Tree: there is no Subtree for name:=");
+ aStr += rtl::OUStringToOString(aSubtreeName.fullName(),RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(pSubtree, aStr.getStr());
+#endif
+
+ if (pSubtree)
+ {
+ TreeUpdate aTreeUpdate(pSubtree);
+ aTree.root.forEachChange(aTreeUpdate);
+ }
+ // Better:
+ // ISubtree *pCloneTree = m_pRoot->clone();
+ // ISubtree *pSubtree = pCloneTree->requestSubtree(aTree.pathToRoot, ITreeProvider::ALL_LEVELS);
+ // TreeUpdate aTreeUpdate(pSubtree);
+ // aTreeUpdate.handle(aTree.root);
+ // if (aTreeUpdate.isOk())
+ // {
+ // delete m_pRoot;
+ // m_pRoot = pSubtree;
+ // }
+ }
+} // namespace configmgr
+
+
diff --git a/configmgr/source/tree/cmtreemodel.cxx b/configmgr/source/tree/cmtreemodel.cxx
new file mode 100644
index 000000000000..2ef5f6e846aa
--- /dev/null
+++ b/configmgr/source/tree/cmtreemodel.cxx
@@ -0,0 +1,323 @@
+/*************************************************************************
+ *
+ * $RCSfile: cmtreemodel.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#ifndef CONFIGMGR_CMTREEMODEL_HXX
+#include "cmtreemodel.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+//..........................................................................
+namespace configmgr
+{
+//..........................................................................
+
+//==========================================================================
+//= SubtreeChange
+//==========================================================================
+//--------------------------------------------------------------------------
+SubtreeChange::SubtreeChange(OUString const& _rName)
+ :Change(_rName)
+{
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::~SubtreeChange()
+{
+ for(Children::iterator aIter = m_mChanges.begin();
+ aIter != m_mChanges.end();
+ ++aIter)
+ {
+ // Change* pChange = aIter->second;
+ delete aIter->second;
+ }
+}
+
+//--------------------------------------------------------------------------
+void SubtreeChange::addChange(std::auto_ptr<Change> aChange)
+{
+ OUString aNodeName(aChange->getNodeName());
+ OSL_ENSHURE(m_mChanges.end() == m_mChanges.find(aNodeName),
+ "SubtreeChange::addChange : overwriting an existent change !");
+ delete m_mChanges[aNodeName];
+ m_mChanges[aNodeName] = aChange.release();
+}
+
+//--------------------------------------------------------------------------
+::std::auto_ptr<Change> SubtreeChange::removeChange(OUString const& _rName)
+{
+ Children::iterator aIter = m_mChanges.find(_rName);
+
+ ::std::auto_ptr<Change> aReturn;
+ if (m_mChanges.end() != aIter)
+ {
+ aReturn = ::std::auto_ptr<Change>(aIter->second);
+ m_mChanges.erase(aIter);
+ }
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+Change* SubtreeChange::getChange(OUString const& _rName)
+{
+ return doGetChild(_rName);
+}
+
+//--------------------------------------------------------------------------
+Change const* SubtreeChange::getChange(OUString const& _rName) const
+{
+ return doGetChild(_rName);
+}
+
+//--------------------------------------------------------------------------
+void SubtreeChange::dispatch(ChangeTreeAction& _anAction) const
+{
+ _anAction.handle(*this);
+}
+
+//--------------------------------------------------------------------------
+void SubtreeChange::dispatch(ChangeTreeModification& _anAction)
+{
+ _anAction.handle(*this);
+}
+
+//--------------------------------------------------------------------------
+void SubtreeChange::forEachChange(ChangeTreeAction& _anAction) const
+{
+ ::std::map< ::rtl::OUString,Change* >::const_iterator aIter = m_mChanges.begin();
+ for(;aIter != m_mChanges.end();)
+ {
+ ::std::map< ::rtl::OUString,Change* >::const_iterator aNextIter = aIter;
+ ++aNextIter;
+ aIter->second->dispatch(_anAction);
+ aIter = aNextIter;
+ }
+}
+
+//--------------------------------------------------------------------------
+void SubtreeChange::forEachChange(ChangeTreeModification& _anAction)
+{
+ ::std::map< ::rtl::OUString,Change* >::const_iterator aIter = m_mChanges.begin();
+ for(;aIter != m_mChanges.end();++aIter)
+ aIter->second->dispatch(_anAction);
+}
+
+//--------------------------------------------------------------------------
+Change* SubtreeChange::doGetChild(OUString const& _rName) const
+{
+ Children::const_iterator aIter = m_mChanges.find(_rName);
+ return (aIter != m_mChanges.end()) ? aIter->second : NULL;
+}
+
+//--------------------------------------------------------------------------
+uno::Sequence< OUString > SubtreeChange::elementNames() const
+{
+ uno::Sequence< OUString > aReturn(size());
+ OUString* pReturn = aReturn.getArray();
+
+ for ( Children::const_iterator aCollector = m_mChanges.begin();
+ aCollector != m_mChanges.end();
+ ++aCollector, ++pReturn
+ )
+ {
+ *pReturn = aCollector->first;
+ }
+
+ return aReturn;
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::ChildIterator SubtreeChange::begin() const throw()
+{
+ return ChildIterator(this);
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::ChildIterator SubtreeChange::end() const throw()
+{
+ return ChildIterator(this, ChildIterator::EndPos());
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::ChildIterator::ChildIterator(const SubtreeChange* _pTree)
+ :m_pTree(_pTree)
+ ,m_aNames(_pTree->elementNames())
+ ,m_nPos(0)
+{
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::ChildIterator::ChildIterator(const SubtreeChange* _pTree, struct EndPos)
+ :m_pTree(_pTree)
+ ,m_aNames(_pTree->elementNames())
+ ,m_nPos(_pTree->size())
+{
+}
+
+//--------------------------------------------------------------------------
+Change const * SubtreeChange::ChildIterator::operator*() const
+{
+ if (isValid())
+ return m_pTree->getChange(m_aNames[m_nPos]);
+ OSL_ENSHURE(sal_False, "SubtreeChange::ChildIterator::operator* : invalid iterator !");
+ return NULL;
+}
+
+//--------------------------------------------------------------------------
+Change const * SubtreeChange::ChildIterator::operator->() const
+{
+ if (isValid())
+ return m_pTree->getChange(m_aNames[m_nPos]);
+ OSL_ENSHURE(sal_False, "SubtreeChange::ChildIterator::operator-> : invalid iterator !");
+ return NULL;
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::ChildIterator& SubtreeChange::ChildIterator::operator++()
+{
+ OSL_ENSHURE(m_nPos < m_aNames.getLength(), "SubtreeChange::ChildIterator : can't increment the end iterator !");
+ if (m_nPos < m_aNames.getLength())
+ ++m_nPos;
+ return *this;
+}
+
+//--------------------------------------------------------------------------
+SubtreeChange::ChildIterator& SubtreeChange::ChildIterator::operator--()
+{
+ OSL_ENSHURE(m_nPos > 0, "SubtreeChange::ChildIterator : can't decrement the begin iterator !");
+ if (m_nPos > 0)
+ --m_nPos;
+ return *this;
+}
+
+//--------------------------------------------------------------------------
+bool operator==(SubtreeChange::ChildIterator const& lhs, SubtreeChange::ChildIterator const& rhs)
+{
+ return (lhs.m_pTree == rhs.m_pTree) && (lhs.m_nPos == rhs.m_nPos);
+}
+
+//==========================================================================
+//= SubtreeChangeReferrer
+//==========================================================================
+//--------------------------------------------------------------------------
+SubtreeChangeReferrer::SubtreeChangeReferrer(const SubtreeChange& _rSource)
+ :SubtreeChange(_rSource.getNodeName())
+{
+ ChildIterator aSourceChildren = _rSource.begin();
+ while (aSourceChildren != _rSource.end())
+ {
+ const Change* pChange = *aSourceChildren;
+ OSL_ENSHURE(pChange, "SubtreeChangeReferrer::SubtreeChangeReferrer : invalid change !");
+ if ( pChange->isA(ValueChange::getStaticType())
+ || pChange->isA(RemoveNode::getStaticType())
+ || pChange->isA(AddNode::getStaticType())
+ )
+ SubtreeChange::addChange(::std::auto_ptr<Change>(const_cast<Change*>(pChange)));
+ else if ( pChange->isA(SubtreeChange::getStaticType())
+ || pChange->isA(SubtreeChangeReferrer::getStaticType())
+ )
+ {
+ SubtreeChange::addChange(::std::auto_ptr<Change>(new SubtreeChangeReferrer(*static_cast<const SubtreeChange*>(pChange))));
+ }
+ else
+ OSL_ENSHURE(sal_False, "SubtreeChangeReferrer::SubtreeChangeReferrer : unknown changes type !");
+
+ ++aSourceChildren;
+ }
+}
+
+//--------------------------------------------------------------------------
+SubtreeChangeReferrer::~SubtreeChangeReferrer()
+{
+ for ( Children::iterator aChildren = m_mChanges.begin();
+ aChildren != m_mChanges.end();
+ ++aChildren
+ )
+ {
+ const Change* pChange = aChildren->second;
+ if ( pChange->isA(ValueChange::getStaticType())
+ || pChange->isA(RemoveNode::getStaticType())
+ || pChange->isA(AddNode::getStaticType())
+ )
+ {
+ // we just hold references to the non-SubtreeChange-objects, so don't delete them
+ m_mChanges.erase(aChildren);
+ }
+ else if ( pChange->isA(SubtreeChange::getStaticType())
+ || pChange->isA(SubtreeChangeReferrer::getStaticType())
+ )
+ {
+ // nothing to do
+ }
+ else
+ OSL_ENSHURE(sal_False, "SubtreeChangeReferrer::~SubtreeChangeReferrer : unknown changes type !");
+ }
+
+ // the base class will remove the remaining SubtreeChanges, which are SubtreeChangeReferrer's in real
+}
+
+//..........................................................................
+} // namespace configmgr
+//..........................................................................
+
+
diff --git a/configmgr/source/tree/makefile.mk b/configmgr/source/tree/makefile.mk
new file mode 100644
index 000000000000..6d0cead70b93
--- /dev/null
+++ b/configmgr/source/tree/makefile.mk
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source
+
+PRJNAME=configmgr
+TARGET=cm
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings ---
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+SLOFILES=\
+ $(SLO)$/changes.obj \
+ $(SLO)$/cmtreemodel.obj \
+ $(SLO)$/cmtree.obj
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
diff --git a/configmgr/source/treecache/makefile.mk b/configmgr/source/treecache/makefile.mk
new file mode 100644
index 000000000000..5a211c6a2238
--- /dev/null
+++ b/configmgr/source/treecache/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=configmgr
+TARGET=treecache
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/treecache.obj \
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/configmgr/source/xml/makefile.mk b/configmgr/source/xml/makefile.mk
new file mode 100644
index 000000000000..7dbbe2583a70
--- /dev/null
+++ b/configmgr/source/xml/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJINC=$(PRJ)$/source
+PRJNAME=configmgr
+TARGET=xml
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+
+SLOFILES=\
+ $(SLO)$/typeconverter.obj \
+ $(SLO)$/xmltreebuilder.obj \
+ $(SLO)$/xmlformater.obj \
+ $(SLO)$/localsession.obj \
+ $(SLO)$/mergeupdates.obj \
+ $(SLO)$/dataexport.obj \
+ $(SLO)$/dataimport.obj \
+ $(SLO)$/updatedom.obj \
+
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
diff --git a/configmgr/source/xml/typeconverter.cxx b/configmgr/source/xml/typeconverter.cxx
new file mode 100644
index 000000000000..db302e3c6a29
--- /dev/null
+++ b/configmgr/source/xml/typeconverter.cxx
@@ -0,0 +1,362 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeconverter.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:42 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "typeconverter.hxx"
+
+#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
+#include <com/sun/star/script/XTypeConverter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_FAILREASON_HPP_
+#include <com/sun/star/script/FailReason.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#include <com/sun/star/uno/Type.hxx>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+//#include <stdio.h>
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+namespace staruno = ::com::sun::star::uno;
+namespace starscript = ::com::sun::star::script;
+namespace starlang = ::com::sun::star::lang;
+
+namespace configmgr
+{
+
+//--------------------------------------------------------------------------------------------------
+ rtl::OUString toString(const staruno::Reference< starscript::XTypeConverter >& xTypeConverter, const staruno::Any& rValue) throw( starscript::CannotConvertException )
+ {
+ rtl::OUString aRes;
+ ::staruno::TypeClass aDestinationClass = rValue.getValueType().getTypeClass();
+
+ switch (aDestinationClass)
+ {
+ case ::staruno::TypeClass_BOOLEAN:
+ case ::staruno::TypeClass_CHAR:
+ case ::staruno::TypeClass_BYTE:
+ case ::staruno::TypeClass_SHORT:
+ case ::staruno::TypeClass_LONG:
+ case ::staruno::TypeClass_FLOAT:
+ case ::staruno::TypeClass_DOUBLE:
+ if (!xTypeConverter.is())
+ {
+ throw( starscript::CannotConvertException( ::rtl::OUString::createFromAscii("stardiv.script.Converter!"), ::staruno::Reference< ::staruno::XInterface > (),
+ aDestinationClass, starscript::FailReason::UNKNOWN, 0 ) );
+ }
+ xTypeConverter->convertToSimpleType(rValue, ::staruno::TypeClass_STRING) >>= aRes;
+ break;
+ case ::staruno::TypeClass_STRING:
+ rValue >>= aRes;
+ break;
+ default:
+ throw( starscript::CannotConvertException( ::rtl::OUString::createFromAscii("TYPE is not supported!"), staruno::Reference< ::staruno::XInterface > (),
+ aDestinationClass, starscript::FailReason::TYPE_NOT_SUPPORTED, 0 ) );
+
+ }
+ return aRes;
+ }
+
+ staruno::Any toAny(const staruno::Reference< starscript::XTypeConverter >& xTypeConverter, const ::rtl::OUString& _rValue,const staruno::TypeClass& _rTypeClass) throw( starscript::CannotConvertException )
+ {
+ staruno::Any aRes;
+ try
+ {
+ xTypeConverter->convertToSimpleType(staruno::makeAny(_rValue), _rTypeClass) >>= aRes;
+ }
+ catch (starscript::CannotConvertException&)
+ {
+ OSL_ENSHURE(sal_False, "toAny : could not convert !");
+ }
+ catch (starlang::IllegalArgumentException&)
+ {
+ OSL_ENSHURE(sal_False, "toAny : could not convert !");
+ }
+ return aRes;
+ }
+
+ ::rtl::OUString toTypeName(const staruno::TypeClass& _rTypeClass)
+ {
+ ::rtl::OUString aRet;
+ switch(_rTypeClass)
+ {
+ case staruno::TypeClass_BOOLEAN: aRet = ::rtl::OUString::createFromAscii("boolean"); break;
+ case staruno::TypeClass_SHORT: aRet = ::rtl::OUString::createFromAscii("short"); break;
+ case staruno::TypeClass_LONG: aRet = ::rtl::OUString::createFromAscii("integer"); break;
+ case staruno::TypeClass_HYPER: aRet = ::rtl::OUString::createFromAscii("long"); break;
+ case staruno::TypeClass_DOUBLE: aRet = ::rtl::OUString::createFromAscii("double"); break;
+ case staruno::TypeClass_STRING: aRet = ::rtl::OUString::createFromAscii("string"); break;
+ case staruno::TypeClass_SEQUENCE: aRet = ::rtl::OUString::createFromAscii("binary"); break;
+ default:
+ {
+ ::rtl::OString aStr("Wrong typeclass! ");
+ aStr += ::rtl::OString::valueOf((sal_Int32)_rTypeClass);
+ OSL_ENSHURE(0,aStr.getStr());
+ }
+ }
+ return aRet;
+ }
+
+ staruno::TypeClass toTypeClass(const ::rtl::OUString& _rType)
+ {
+ staruno::TypeClass aRet = staruno::TypeClass_VOID;
+
+ if (_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("boolean"))) aRet = staruno::TypeClass_BOOLEAN;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("short"))) aRet = staruno::TypeClass_SHORT;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("int"))) aRet = staruno::TypeClass_LONG;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("integer"))) aRet = staruno::TypeClass_LONG;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("long"))) aRet = staruno::TypeClass_HYPER;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("double"))) aRet = staruno::TypeClass_DOUBLE;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("string"))) aRet = staruno::TypeClass_STRING;
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("binary"))) aRet = staruno::TypeClass_SEQUENCE;
+ else
+ {
+ ::rtl::OString aStr("Wrong typeclass! ");
+ aStr += rtl::OUStringToOString(_rType,RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(0,aStr.getStr());
+ }
+
+ return aRet;
+ }
+
+// *************************************************************************
+
+ namespace
+ {
+
+ inline staruno::Type getBooleanType() { return ::getBooleanCppuType(); }
+
+ inline staruno::Type getShortType() { return ::getCppuType(static_cast<sal_Int16 const*>(0)); }
+ inline staruno::Type getIntType() { return ::getCppuType(static_cast<sal_Int32 const*>(0)); }
+ inline staruno::Type getLongType() { return ::getCppuType(static_cast<sal_Int64 const*>(0)); }
+
+ inline staruno::Type getDoubleType() { return ::getCppuType(static_cast<double const*>(0)); }
+
+ inline staruno::Type getStringType() { return ::getCppuType(static_cast<rtl::OUString const*>(0)); }
+
+// *************************************************************************
+/*
+ ::rtl::OUString findXMLTypeName(const staruno::Type& _rType)
+ {
+ ::rtl::OUString aRet;
+ switch(_rType.getTypeClass())
+ {
+ case staruno::TypeClass_BOOLEAN:
+ OSL_ASSERT( _rType == getBooleanType() );
+ aRet = ::rtl::OUString::createFromAscii("boolean");
+ break;
+
+ case staruno::TypeClass_SHORT:
+ OSL_ASSERT( _rType == getShortType() );
+ aRet = ::rtl::OUString::createFromAscii("short");
+ break;
+
+ case staruno::TypeClass_LONG:
+ OSL_ASSERT( _rType == getIntType() );
+ aRet = ::rtl::OUString::createFromAscii("int");
+ break;
+
+ case staruno::TypeClass_HYPER:
+ OSL_ASSERT( _rType == getLongType() );
+ Ret = ::rtl::OUString::createFromAscii("long");
+ break;
+
+ case staruno::TypeClass_DOUBLE:
+ OSL_ASSERT( _rType == getDoubleType() );
+ aRet = ::rtl::OUString::createFromAscii("double");
+ break;
+
+ case staruno::TypeClass_STRING:
+ OSL_ASSERT( _rType == getStringType() );
+ aRet = ::rtl::OUString::createFromAscii("string");
+ break;
+
+ case staruno::TypeClass_SEQUENCE:
+ if ( _rType == getStringType() );
+ aRet = ::rtl::OUString::createFromAscii("sequence");
+ break;
+
+ default:
+ {
+ ::rtl::OString aStr("Wrong typeclass! ");
+ aStr += ::rtl::OString::valueOf((sal_Int32)_rTypeClass);
+ OSL_ENSHURE(0,aStr.getStr());
+ }
+ }
+ return aRet;
+ }
+ */
+ } // unamed namespace
+// *************************************************************************
+
+ staruno::Type toType(const ::rtl::OUString& _rType)
+ {
+ staruno::Type aRet;
+
+ if (_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("boolean"))) aRet = getBooleanType();
+
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("short"))) aRet = getShortType();
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("int"))) aRet = getIntType();
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("integer"))) aRet = getIntType();
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("long"))) aRet = getLongType();
+
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("double"))) aRet = getDoubleType();
+
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("string"))) aRet = getStringType();
+ else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("binary"))) aRet = getBinaryType();
+// else if(_rType.equalsIgnoreCase(::rtl::OUString::createFromAscii("sequence"))) aRet = staruno::TypeClass_SEQUENCE;
+ else
+ {
+ ::rtl::OString aStr("Unknown type! ");
+ aStr += rtl::OUStringToOString(_rType,RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(0,aStr.getStr());
+ }
+
+ return aRet;
+ }
+ staruno::Type toListType(const ::rtl::OUString& _rsElementType)
+ {
+ staruno::Type aRet;
+
+ if (_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("boolean")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<sal_Bool> const*>(0));
+
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("short")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<sal_Int16> const*>(0));
+
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("int")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<sal_Int32> const*>(0));
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("integer")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<sal_Int32> const*>(0));
+
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("long")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<sal_Int64> const*>(0));
+
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("double")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<double> const*>(0));
+
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("string")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<rtl::OUString> const*>(0));
+
+ else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("binary")))
+ aRet = ::getCppuType(static_cast<staruno::Sequence<staruno::Sequence<sal_Int8> > const*>(0));
+
+// else if(_rsElementType.equalsIgnoreCase(::rtl::OUString::createFromAscii("sequence"))) aRet = staruno::TypeClass_SEQUENCE;
+ else
+ {
+ ::rtl::OString aStr("Unknown type! ");
+ aStr += rtl::OUStringToOString(_rsElementType,RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(0,aStr.getStr());
+ }
+
+ return aRet;
+ }
+
+ staruno::Type getSequenceElementType(staruno::Type const& rSequenceType)
+ {
+ OSL_ENSHURE(rSequenceType.getTypeClass() == staruno::TypeClass_SEQUENCE,
+ "getSequenceElementType() must be called with a sequence type");
+
+ if (!(rSequenceType.getTypeClass() == staruno::TypeClass_SEQUENCE))
+ return staruno::Type();
+
+ staruno::TypeDescription aTD(rSequenceType);
+ typelib_IndirectTypeDescription* pSequenceTD =
+ reinterpret_cast< typelib_IndirectTypeDescription* >(aTD.get());
+
+ OSL_ASSERT(pSequenceTD);
+ OSL_ASSERT(pSequenceTD->pType);
+
+ if (pSequenceTD && pSequenceTD->pType)
+ {
+ #if (SUPD >= 0x601)
+ return staruno::Type(pSequenceTD->pType);
+ #else
+ OSL_ASSERT(pSequenceTD->pType);
+ return staruno::Type(pSequenceTD->pType->pWeakRef);
+ #endif
+ }
+
+ return staruno::Type();
+ }
+ staruno::Type getBasicType(staruno::Type const& rType, bool& bSequence)
+ {
+ bSequence = rType.getTypeClass() == staruno::TypeClass_SEQUENCE &&
+ rType != getBinaryType();
+
+ if (!bSequence)
+ return rType;
+
+ return getSequenceElementType(rType);
+ }
+
+
+} // namespace configmgr
diff --git a/configmgr/util/exports.dxp b/configmgr/util/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/configmgr/util/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/configmgr/util/makefile.mk b/configmgr/util/makefile.mk
new file mode 100644
index 000000000000..ca92f116e0af
--- /dev/null
+++ b/configmgr/util/makefile.mk
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..
+PRJNAME=configmgr
+TARGET=cfgmgr
+
+ENABLE_EXCEPTIONS=TRUE
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(CFGMGR_TARGET)$(CFGMGR_MAJOR)
+SHL1VERSIONMAP= $(TARGET).map
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(OSLLIB) \
+ $(SALLIB) \
+ $(CPPRTLLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+SHL1LIBS= $(SLB)$/registry.lib \
+ $(SLB)$/treecache.lib \
+ $(SLB)$/session.lib \
+ $(SLB)$/misc.lib \
+ $(SLB)$/xml.lib \
+ $(SLB)$/api.lib \
+ $(SLB)$/cm.lib
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/configmgr/version.mk b/configmgr/version.mk
new file mode 100644
index 000000000000..0e11cac1e39b
--- /dev/null
+++ b/configmgr/version.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# $RCSfile: version.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:39 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+# ----------------------------CFGMGR settings------------------------------------#
+# target
+CFGMGR_TARGET=cfgmgr
+
+# the major
+CFGMGR_MAJOR=2
+# the minor
+CFGMGR_MINOR=0
+# the micro
+CFGMGR_MICRO=0
+
+# this is a c++ compatible library
+CFGMGR_CPP=1
+
+CFGMGR=$(CFGMGR_TARGET_TARGET)_$(CMPEXT)
+
+
+
+
diff --git a/configmgr/workben/apitest/cfgadduser.cxx b/configmgr/workben/apitest/cfgadduser.cxx
new file mode 100644
index 000000000000..a6d8b45d79f9
--- /dev/null
+++ b/configmgr/workben/apitest/cfgadduser.cxx
@@ -0,0 +1,409 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfgadduser.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+#include <cppuhelper/extract.hxx>
+
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#include <com/sun/star/uno/Type.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPECLASS_HPP_
+#include <com/sun/star/uno/TypeClass.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCHANGESBATCH_HPP_
+#include <com/sun/star/util/XChangesBatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+
+#define ASCII_STRING(rtlOUString) ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ASCII_US).getStr()
+
+//=============================================================================
+void explain(sal_Bool _bVerbose)
+{
+ cout << "cfgadduser - adding users to a registry server\n";
+ cout << "\nusage :\n";
+ cout << "cfgadduser [-s <server> -p <port>] [-portal] [-r <registry>] [-a <sysaccount>]";
+ cout << " [-h <homedirbase>] [-pwd] <user> [<user>]*\n";
+ cout << "\nparameters\n";
+ cout << " <server> - machine where the registry server is running\n";
+ cout << " <port> - port the registry server is listening at\n";
+ cout << " <registry> - registry file to use to instantiate services. Defaulted to\n";
+ cout << " applicat.rdb\n";
+ cout << " <sysaccount> - system account to use for the newly created user(s)\n";
+ cout << " <homedirbase> - home directory base. The concret home dir of a user will\n";
+ cout << " be built by appending the the user name to the base dir.\n";
+ cout << " <user> - user name to add\n";
+ cout << " -portal - specify that the program should connect to a running portal,\n";
+ cout << " not directly to the registry server (you need a ";
+#ifdef WIN32
+ cout << "portal.dll\n";
+#else
+ cout << "libportal.so\n";
+#endif
+ cout << " for this)\n";
+ cout << " In this case, <server> and <port> specify the location where\n";
+ cout << " StarPortal is running\n";
+ cout << "\n";
+ cout << "If no server is specified, the configuration proxy will try to bootstrap from\n";
+ cout << "the initialization file (";
+#ifdef WIN32
+ cout << "sregistry.ini";
+#else
+ cout << "sregistryrc";
+#endif
+ cout << ")\n\n";
+ cout.flush();
+}
+
+//=============================================================================
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ sal_Char* pPort = NULL;
+ sal_Char* pServer = NULL;
+ sal_Char* pRegistry = NULL;
+ sal_Char* pSysAccount = NULL;
+ sal_Char* pHomeDirBase = NULL;
+ sal_Bool bPortal = sal_False;
+
+ ::std::vector< sal_Char* > aUsers;
+
+ // collect some parameters
+ sal_Char** pArgs = argv + 1;
+ for (sal_Int32 i=1; i<argc; ++i, ++pArgs)
+ {
+ sal_Char* pCurArg = *pArgs;
+ sal_Int32 nLen = strlen(pCurArg);
+ sal_Bool bInvalidArg = sal_True;
+ if (nLen && ('-' == *pCurArg))
+ { // it's a switch
+ sal_Char* pSwitch = pCurArg + 1;
+ switch (nLen)
+ {
+ case 2:
+ switch (*pSwitch)
+ {
+ case '?':
+ explain(sal_True);
+ return 1;
+ case 'h':
+ pHomeDirBase = *++pArgs;
+ ++i;
+ bInvalidArg = sal_False;
+ break;
+ case 'a':
+ pSysAccount = *++pArgs;
+ ++i;
+ bInvalidArg = sal_False;
+ break;
+ case 'p':
+ pPort = *++pArgs;
+ ++i;
+ bInvalidArg = sal_False;
+ break;
+ case 's':
+ pServer = *++pArgs;
+ ++i;
+ bInvalidArg = sal_False;
+ break;
+ case 'r':
+ pRegistry = *++pArgs;
+ ++i;
+ bInvalidArg = sal_False;
+ break;
+ }
+ break;
+ case 7:
+ if (0 == strncmp(pSwitch, "portal", 6))
+ {
+ bInvalidArg = sal_False;
+ bPortal = sal_True;
+ }
+ break;
+ }
+ }
+ else
+ {
+ if ((1 == nLen) && ('?' == *pCurArg))
+ {
+ explain(sal_True);
+ return 1;
+ }
+ else
+ {
+ bInvalidArg = sal_False;
+ aUsers.push_back(pCurArg);
+ }
+ }
+ if (bInvalidArg)
+ {
+ explain(sal_False);
+ return 1;
+ }
+ }
+
+ if ((!pServer && pPort) || (!pPort && pServer))
+ {
+ explain(sal_False);
+ return 1;
+ }
+
+ if (0 == aUsers.size())
+ {
+ explain(sal_False);
+ return 1;
+ }
+
+ // refine some params
+ ::rtl::OUString sHomeDirBase, sSystemAccountName;
+ if (pHomeDirBase)
+ {
+ sHomeDirBase = ::rtl::OUString::createFromAscii(pHomeDirBase);
+ if (!sHomeDirBase.getLength() || ('/' != sHomeDirBase.getStr()[sHomeDirBase.getLength() - 1]))
+ sHomeDirBase += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ }
+ if (pSysAccount)
+ sSystemAccountName = ::rtl::OUString::createFromAscii(pSysAccount);
+
+ try
+ {
+ ::rtl::OUString const sServiceRegistry = ::rtl::OUString::createFromAscii( pRegistry ? pRegistry : "applicat.rdb" );
+ Reference< XMultiServiceFactory > xORB = ::cppu::createRegistryServiceFactory(
+ sServiceRegistry,
+ ::rtl::OUString()
+ );
+ if (!xORB.is())
+ {
+ cerr << "Could not create the service factory !\n\n";
+ return 1;
+ }
+
+ // collect the params for the config provider
+ Sequence< Any > aProviderArgs(3 + (pServer ? 2 : 0));
+ aProviderArgs[0] = makeAny(PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("servertype")),
+ 0,
+ makeAny(::rtl::OUString::createFromAscii(bPortal ? "portal" : "remote")),
+ PropertyState_DIRECT_VALUE
+ ));
+ aProviderArgs[1] = makeAny(PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")),
+ 0,
+ makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Administrator"))),
+ PropertyState_DIRECT_VALUE
+ ));
+ aProviderArgs[2] = makeAny(PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password")),
+ 0,
+ makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unused"))),
+ PropertyState_DIRECT_VALUE
+ ));
+ if (pServer)
+ {
+ aProviderArgs[3] = makeAny(PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("server")),
+ 0,
+ makeAny(::rtl::OUString::createFromAscii(pServer)),
+ PropertyState_DIRECT_VALUE
+ ));
+
+ sal_Int32 nPort = ::rtl::OUString::createFromAscii(pPort).toInt32();
+ aProviderArgs[4] = makeAny(PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("port")),
+ 0,
+ makeAny(nPort),
+ PropertyState_DIRECT_VALUE
+ ));
+ }
+
+ Reference< XMultiServiceFactory > xCfgProvider(
+ xORB->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"),
+ aProviderArgs),
+ UNO_QUERY);
+ if (!xCfgProvider.is())
+ {
+ cerr << "Could not create the configuration provider !\n\n";
+ return 3;
+ }
+
+ Reference< XInterface > xIFace = xCfgProvider->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.configuration.UserAdministration"));
+ if (!xIFace.is())
+ {
+ cerr << "Could not create the configuration provider !\n\n";
+ return 4;
+ }
+
+ Reference< XChangesBatch > xUserChanges(xIFace, UNO_QUERY);
+ Reference< XNameContainer > xUserContainer(xIFace, UNO_QUERY);
+ Reference< XSingleServiceFactory> xUserFactory(xIFace, UNO_QUERY);
+ if (!xUserChanges.is() || !xUserContainer.is() || !xUserFactory.is())
+ {
+ cerr << "the user admin access does not provide the necessary interfaces !\n\n";
+ return 5;
+ }
+
+ cout << "going to add the users ..." << endl << endl;
+ for ( ::std::vector< sal_Char* >::const_iterator aUserLoop = aUsers.begin();
+ aUserLoop != aUsers.end();
+ ++aUserLoop
+ )
+ {
+ cout << *aUserLoop << " ... ";
+ sal_Bool bHadLinebreak = sal_False;
+ try
+ {
+ Reference< XInterface > xNewUser = xUserFactory->createInstance();
+
+ // the user name as unicode string use more than once)
+ ::rtl::OUString sUserName = ::rtl::OUString::createFromAscii(*aUserLoop);
+
+ // the XNameContainer access to the Security node in the user profile data
+ Reference< XNameReplace > xSecurityDataAccess;
+ Reference< XNameAccess > xUserDataAccess(xNewUser, UNO_QUERY);
+ if (xUserDataAccess.is())
+ {
+ Any aSecurity = xUserDataAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Security")));
+ ::cppu::extractInterface(xSecurityDataAccess, aSecurity);
+ }
+
+ if (!xSecurityDataAccess.is())
+ throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The user administration service did not provide a valid user template.")), NULL);
+
+ // set the home directory
+ if (sHomeDirBase.getLength())
+ {
+ ::rtl::OUString sHomeDir(sHomeDirBase);
+ sHomeDir += sUserName;
+ xSecurityDataAccess->replaceByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("homeDirectory")), makeAny(sHomeDir));
+ cout << "\n\thome dir : " << ASCII_STRING(sHomeDir) << " ... ";
+ cout.flush();
+ bHadLinebreak = sal_True;
+ }
+
+ if (sSystemAccountName.getLength())
+ {
+ xSecurityDataAccess->replaceByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("systemAccount")), makeAny(sSystemAccountName));
+ cout << "\n\tsystem account: " << ASCII_STRING(sSystemAccountName) << " ... ";
+ cout.flush();
+ bHadLinebreak = sal_True;
+ }
+
+ xUserContainer->insertByName(sUserName, makeAny(xNewUser));
+ xUserChanges->commitChanges();
+ if (bHadLinebreak)
+ cout << "\n";
+ cout << "done.\n";
+ cout.flush();
+ }
+ catch(Exception& e)
+ {
+ cout << "\n";
+ if (!bHadLinebreak)
+ cout << "\t";
+ cerr << "unable to add the user named " << *aUserLoop << endl;
+ if (!bHadLinebreak)
+ cout << "\t";
+ cerr << "(exception message: " << ::rtl::OString(e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US).getStr() << ")" << endl;
+ }
+ cout << "\n";
+ }
+ }
+ catch(Exception& e)
+ {
+ cerr << "Caught exception: " << ASCII_STRING(e.Message) << endl;
+ return 2;
+ }
+
+ return 0;
+}
diff --git a/configmgr/workben/apitest/cfgapi.cxx b/configmgr/workben/apitest/cfgapi.cxx
new file mode 100644
index 000000000000..757f2675a937
--- /dev/null
+++ b/configmgr/workben/apitest/cfgapi.cxx
@@ -0,0 +1,496 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfgapi.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define _PRIVATE_TEST_
+
+#include <iostream>
+using namespace std;
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/TypeClass.hpp>
+
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XHierarchicalName.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+
+#include <rtl/ustring.hxx>
+#include <rtl/string.hxx>
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#include "createpropertyvalue.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+//using namespace ::com::sun::star::util;
+
+using ::rtl::OUString;
+using ::rtl::OString;
+//using namespace ::configmgr;
+
+using namespace ::cppu;
+
+#define ASCII(x) ::rtl::OUString::createFromAscii(x)
+
+ostream& operator << (ostream& out, rtl::OUString const& aStr)
+{
+ sal_Unicode const* const pStr = aStr.getStr();
+ sal_Unicode const* const pEnd = pStr + aStr.getLength();
+ for (sal_Unicode const* p = pStr; p < pEnd; ++p)
+ if (0 < *p && *p < 127) // ASCII
+ out << char(*p);
+ else
+ out << "[\\u" << hex << *p << "]";
+ return out;
+}
+//=============================================================================
+//=============================================================================
+void test_read_access(Reference< XInterface >& xIface);
+//=============================================================================
+struct prompt_and_wait
+{
+ char const* myText;
+ prompt_and_wait(char const* text = "") : myText(text) {}
+ ~prompt_and_wait()
+ {
+ cout << myText << ">" << endl;
+ int const mx = int( (+0u - +1u) >> 1);
+
+ char c=0;
+ if (cin.get(c) && c != '\n')
+ cin.ignore(mx,'\n');
+ }
+};
+static prompt_and_wait exit_prompt("Quitting\nQ");
+
+// -----------------------------------------------------------------------------
+rtl::OUString enterValue(const char* aStr)
+{
+ char aValue[300] = "com.sun.star.";
+ cout << aStr << flush;
+ if (!cin.getline(aValue, 200))
+ {
+ cerr << "\nInput error\n";
+ return OUString();
+ }
+
+ OUString sValue = OUString::createFromAscii(aValue);
+ return sValue;
+}
+
+//=============================================================================
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ TimeValue aTimeout;
+ aTimeout.Seconds = 5;
+ aTimeout.Nanosec = 0;
+
+ try
+ {
+ OUString const sServiceRegistry = OUString::createFromAscii( argc > 1 ? argv[1] : "applicat.rdb" );
+ Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory(
+ sServiceRegistry,
+ ::rtl::OUString()
+ );
+ if (!xORB.is())
+ {
+ flush(cout);
+ cerr << "Could not create the service factory !\n\n";
+ return 1;
+ }
+ cout << "Service factory created !\n---------------------------------------------------------------" << endl;
+
+ OUString sUser = enterValue(" Enter User: ");
+ OUString sPasswd = enterValue("Enter Password: ");
+
+ Sequence< Any > aCPArgs(2);
+ aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser);
+ aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd);
+
+ Reference< XMultiServiceFactory > xCfgProvider(
+ xORB->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"),
+ aCPArgs),
+ UNO_QUERY);
+ if (!xCfgProvider.is())
+ {
+ flush(cout);
+ cerr << "Could not create the configuration provider !\n\n";
+ return 3;
+ }
+
+// char aPath[300] = "Root/ApplProfile/StarPortal/";
+// int const nStart = sizeof( "Root/ApplProfile/StarPortal/" ) - 1;
+ char aPath[300] = "/";
+ int nStart = sizeof( "/" ) - 1;
+
+ cout << "Configuration Provider created !\n---------------------------------------------------------------" << endl;
+
+ OUString sPath = enterValue("Enter RootPath: ");
+
+ Sequence< Any > aArgs(2);
+ aArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser);
+ aArgs[1] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath);
+
+ Reference< XInterface > xIFace = xCfgProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"),
+ aArgs);
+ cout << "Configuration Read Access created !\n---------------------------------------------------------------" << endl;
+
+ test_read_access(xIFace);
+ }
+ catch (Exception& e)
+ {
+ flush(cout);
+ cerr << "Caught exception: " << e.Message << endl;
+ }
+ catch (...)
+ {
+ flush(cout);
+ cerr << "BUG: Caught UNKNOWN exception (?) " << endl;
+ }
+
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+void test(Reference< XHierarchicalName >& xAccessName)
+{
+ if (xAccessName.is())
+ cout << "Accessing Node: " << xAccessName->getHierarchicalName();
+ else
+ cout << "BUG: XHierarchicalName not available";
+ cout << endl;
+}
+void test(Reference< XNamed >& xAccess)
+{
+ if (xAccess.is())
+ cout << "Node is named: " << xAccess->getName();
+ else
+ cout << "BUG: XNamed not available";
+ cout << endl;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+void write(Reference<XNameAccess >& xAccess)
+{
+ if (xAccess.is())
+ {
+ Sequence<OUString> aNames( xAccess->getElementNames() );
+
+ cout << "Element Names: (" << aNames.getLength() << ")";
+ for (int i = 0; i < aNames.getLength(); ++i)
+ cout << "\n[" << i << "] -\t" << aNames[i];
+ cout << endl;
+ }
+ else
+ cout << "BUG: XNameAccess not available";
+ cout << endl;
+}
+void write(Reference< XChild >& xChild)
+{
+ if (xChild.is())
+ cout << "\n[ P ] -\tParent";
+ else
+ cout << "BUG: Parent not available (no XChild)";
+ cout << endl;
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+
+bool ask(Reference< XInterface >& xIface);
+
+void test_read_access(Reference< XInterface >& xIface)
+{
+ using com::sun::star::uno::UNO_QUERY;
+ do
+ {
+ cout << "\n\n---------------------------------------------------------------" << endl;
+ Reference< XNameAccess > xAccess(xIface, UNO_QUERY);
+ Reference< XChild > xChild(xIface, UNO_QUERY);
+ Reference< XHierarchicalName > xAccessPath(xIface,UNO_QUERY);
+ Reference< XNamed > xAccessName(xIface,UNO_QUERY);
+// Reference< XHierarchicalNameAccess >& xAccess(xIface, UNO_QUERY);
+
+ test(xAccessPath);
+ test(xAccessName);
+ write(xAccess);
+ write(xChild);
+ }
+ while (ask(xIface));
+}
+
+bool ask(Reference< XInterface >& xIface)
+{
+ cout << "\n[ Q ] -> <Quit>";
+ cout << endl;
+
+ cout << "\n:> " << flush;
+ char buf[200] = {0};
+ try
+ {
+ if (cin.getline(buf,sizeof buf))
+ {
+ Reference< XInterface > xNext;
+ if ((buf[0] == 0 || buf[0] == 'q' || buf[0] == 'Q') && (0 == buf[1]))
+ {
+ return false;
+ }
+ else if ((buf[0] == 'p' || buf[0] == 'P') && (0 == buf[1]))
+ {
+ Reference< XChild > xChild(xIface, UNO_QUERY);
+ if (xChild.is())
+ xNext = xChild->getParent();
+
+ }
+ else
+ {
+ Reference< XNameAccess > xAccess(xIface, UNO_QUERY);
+ Reference< XHierarchicalNameAccess > xDeepAccess(xIface, UNO_QUERY);
+ Reference< XExactName > xExactName(xIface, UNO_QUERY);
+
+ if (xAccess.is() || xDeepAccess.is())
+ {
+ OUString aName;
+ OUString aInput = OUString::createFromAscii(buf);
+
+ if (xExactName.is())
+ {
+ ::rtl::OUString sTemp = xExactName->getExactName(aInput);
+ if (sTemp.getLength())
+ aInput = sTemp;
+ }
+
+ if (xAccess.is() && xAccess->hasByName(aInput))
+ {
+ aName = aInput;
+ }
+ else if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(aInput))
+ {
+ aName = aInput;
+ }
+ else if ('0' <= buf[0] && buf[0] <= '9' && xAccess.is())
+ {
+ unsigned int n = unsigned(atoi(buf));
+ Sequence<OUString> aNames = xAccess->getElementNames();
+ if (n < aNames.getLength())
+ aName = aNames[n];
+ }
+
+ if (aName.getLength())
+ {
+ bool bNest = aInput.indexOf(sal_Unicode('/')) >= 0;
+
+ Any aElement = bNest ? ( xDeepAccess.is() ? xDeepAccess->getByHierarchicalName(aName) : Any())
+ : ( xAccess. is() ? xAccess-> getByName(aName) : Any() );
+
+ while (aElement.getValueTypeClass() == TypeClass_ANY)
+ {
+ 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();
+ bValueOk = (pVal != 0);
+
+ cout << "VALUE '" << aName << "' is a BOOLEAN = ";
+ if (!bValueOk)
+ cout << "NULL (error!!)";
+ else if (*pVal)
+ cout << "'TRUE'";
+ else
+ cout << "'FALSE'";
+
+ cout << endl;
+ }
+ break;
+ case TypeClass_SHORT:
+ {
+ sal_Int16 aValue;
+ cout << "VALUE '" << aName << "' is a SHORT (16 bit) = ";
+ if (bValueOk = (aElement >>= aValue))
+ cout << aValue;
+ else
+ cout << "ERROR RETRIEVING VALUE";
+ cout << endl;
+ }
+ break;
+ case TypeClass_LONG:
+ {
+
+ sal_Int32 aValue;
+ cout << "VALUE '" << aName << "' is a INT (32 bit) = ";
+ if (bValueOk = (aElement >>= aValue))
+ cout << aValue;
+ else
+ cout << "ERROR RETRIEVING VALUE";
+ cout << endl;
+ }
+ break;
+ case TypeClass_HYPER:
+ {
+ sal_Int64 aValue;
+ cout << "VALUE '" << aName << "' is a LONG (64 bit) = ";
+ if (bValueOk = (aElement >>= aValue))
+ cout << double(aValue);
+ else
+ cout << "ERROR RETRIEVING VALUE";
+ cout << endl;
+ }
+ break;
+ case TypeClass_DOUBLE:
+ {
+ double aValue;
+ cout << "VALUE '" << aName << "' is a DOUBLE = ";
+ if (bValueOk = (aElement >>= aValue))
+ cout << aValue;
+ else
+ cout << "ERROR RETRIEVING VALUE";
+ cout << endl;
+ }
+ break;
+ case TypeClass_STRING:
+ {
+ OUString aValue;
+ cout << "VALUE '" << aName << "' is a STRING = ";
+ if (bValueOk = (aElement >>= aValue))
+ cout << "\"" << aValue << "\"";
+ else
+ cout << "ERROR RETRIEVING VALUE";
+ cout << endl;
+ }
+ break;
+ case TypeClass_SEQUENCE:
+ {
+ cout << "VALUE '" << aName << "' is a SEQUENCE or BINARY" << endl;
+ bValueOk = true;
+ }
+ break;
+ case TypeClass_VOID:
+ cout << "Error: ELEMENT '" << aName << "' is NULL and VOID " << endl;
+ break;
+ default:
+ cout << "Error: ELEMENT '" << aName << "' is of unknown or unrecognized type" << endl;
+ break;
+ }
+ if (bValue)
+ {
+ prompt_and_wait();
+ return bValueOk;
+ }
+
+ if (aElement >>= xNext)
+ cout << "Got an Interface for '" << aName << "'" << endl;
+ else
+ cout << "Error: Cannot get an Interface for '" << aName << "'" << endl;
+ }
+ else
+ {
+ cout << "Error: No element \"" << aInput << "\" found." <<endl;
+ }
+ }
+
+ }
+ if (xNext.is())
+ {
+ xIface = xNext;
+ return true;
+ }
+ cout << "Error: could not obtain the requested Object " << endl;
+ }
+ else
+ {
+ cout << "Input Error " << endl;
+ return false;
+ }
+ }
+ catch (Exception& e)
+ {
+ cout << "An Exception occurred: " << e.Message << endl;
+
+ }
+ catch (...)
+ {
+ cout << "An UNKNOWN Exception occurred !" << endl;
+
+ }
+
+
+ prompt_and_wait();
+ return true;
+}
diff --git a/configmgr/workben/apitest/cfgregistry.cxx b/configmgr/workben/apitest/cfgregistry.cxx
new file mode 100644
index 000000000000..2c56ad013801
--- /dev/null
+++ b/configmgr/workben/apitest/cfgregistry.cxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfgregistry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <memory.h>
+#include <stdio.h>
+
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
+#include <com/sun/star/container/XNameReplace.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCHANGESBATCH_HPP_
+#include <com/sun/star/util/XChangesBatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
+#include <com/sun/star/util/XFlushable.hpp>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+#ifndef _VOS_CONDITN_HXX_
+#include <vos/conditn.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::xml;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::registry;
+using namespace ::vos;
+using namespace ::cppu;
+//using namespace ::configmgr;
+
+//=============================================================================
+//= a dirty littly class for printing ascii characters
+//=============================================================================
+class OAsciiOutput
+{
+protected:
+ sal_Char* m_pCharacters;
+
+public:
+ OAsciiOutput(const ::rtl::OUString& _rUnicodeChars);
+ ~OAsciiOutput() { delete m_pCharacters; }
+
+ const sal_Char* getCharacters() const { return m_pCharacters; }
+};
+
+//-----------------------------------------------------------------------------
+OAsciiOutput::OAsciiOutput(const ::rtl::OUString& _rUnicodeChars)
+{
+ sal_Int32 nLen = _rUnicodeChars.getLength();
+ m_pCharacters = new sal_Char[nLen + 1];
+ sal_Char* pFillPtr = m_pCharacters;
+ const sal_Unicode* pSourcePtr = _rUnicodeChars.getStr();
+#ifdef DEBUG
+ sal_Bool bAsserted = sal_False;
+#endif
+ for (sal_Int32 i=0; i<nLen; ++i, ++pFillPtr, ++pSourcePtr)
+ {
+ OSL_ENSHURE(bAsserted || !(bAsserted = (*pSourcePtr >= 0x80)),
+ "OAsciiOutput::OAsciiOutput : non-ascii character found !");
+ *pFillPtr = *reinterpret_cast<const sal_Char*>(pSourcePtr);
+ }
+ *pFillPtr = 0;
+}
+
+#define ASCII_STRING(rtlOUString) OAsciiOutput(rtlOUString).getCharacters()
+#define UNI_STRING(asciiString) ::rtl::OUString::createFromAscii(asciiString)
+
+//=============================================================================
+//=============================================================================
+
+#if (defined UNX) || (defined OS2)
+void main( int argc, char * argv[] )
+#else
+void _cdecl main( int argc, char * argv[] )
+#endif
+{
+ TimeValue aTimeout;
+ aTimeout.Seconds = 5;
+ aTimeout.Nanosec = 0;
+
+ Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory(
+ ::rtl::OUString::createFromAscii("l:\\bin.a\\applicat.rdb"),
+ ::rtl::OUString()
+ );
+ if (!xORB.is())
+ {
+ fprintf(stdout, "could not create the service factory !\n\n");
+ return;
+ }
+
+ try
+ {
+ Reference< XSimpleRegistry > xConfigurationRegistry;
+ printf("instantiating the configuration registry access\n\r");
+ xConfigurationRegistry = xConfigurationRegistry.query(
+ xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationRegistry"))
+ );
+
+ const sal_Char* pLayoutNode = "com.sun.star.Inet";
+ printf("opening the registry access to %s\n\r", pLayoutNode);
+ xConfigurationRegistry->open(UNI_STRING(pLayoutNode), sal_False, sal_False);
+
+ printf("retrieving the root key, enumerating elements\n\r");
+ Reference< XRegistryKey > xRoot = xConfigurationRegistry->getRootKey();
+ Sequence< ::rtl::OUString > aKeyNames = xRoot->getKeyNames();
+ const ::rtl::OUString* pKeyNames = aKeyNames.getConstArray();
+ for (sal_Int32 i=0; i<aKeyNames.getLength(); ++i, ++pKeyNames)
+ printf("\t%i\t%s\n\r", i, ASCII_STRING(*pKeyNames));
+
+ const sal_Char* pUpdateKey = "Proxy/NoProxy";
+ printf("retrieving the key for %s\n\r", pUpdateKey);
+ Reference< XRegistryKey > xTabStopsKey = xRoot->openKey(UNI_STRING(pUpdateKey));
+
+/* xTabStopsKey->createKey(UNI_STRING("blupp"));
+
+ Sequence< ::rtl::OUString > sLanguages = xTabStopsKey->getStringListValue();
+ sLanguages.realloc(sLanguages.getLength() + 1);
+ sLanguages[sLanguages.getLength() - 1] = UNI_STRING("ru");
+ xTabStopsKey->setStringListValue(sLanguages);
+*/
+
+ ::rtl::OUString sTest = xTabStopsKey->getStringValue();
+ xTabStopsKey->setStringValue(UNI_STRING("blimp"));
+
+ printf("flushing the changes\n\r");
+ Reference< XFlushable > xCommit(xConfigurationRegistry, UNO_QUERY);
+ xCommit->flush();
+ }
+ catch(RuntimeException& e)
+ {
+ printf("\n\r\n\rcaught an RuntimeException :\n\r");
+ printf(" exception message : %s\n\r", ASCII_STRING(e.Message));
+ return;
+ }
+ catch(Exception& e)
+ {
+ printf("\n\r\n\rcaught an Exception :\n\r");
+ printf(" exception message : %s\n\r", ASCII_STRING(e.Message));
+ return;
+ }
+}
diff --git a/configmgr/workben/apitest/makefile.mk b/configmgr/workben/apitest/makefile.mk
new file mode 100644
index 000000000000..e12353ea51f5
--- /dev/null
+++ b/configmgr/workben/apitest/makefile.mk
@@ -0,0 +1,133 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source
+
+PRJNAME=configmgr
+
+TARGET=cfgapi
+TARGET2=cfgreg
+TARGET3=cfgadduser
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\"
+
+# ... common for all test executables ..............................
+APPSTDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+# ... cfgapi ..............................
+APP1STDLIBS = $(APPSTDLIBS)
+
+APP1STDLIBS+=$(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+=$(LIBCIMT)
+.ENDIF
+
+APP1TARGET= $(TARGET)
+APP1OBJS= \
+ $(SLO)$/cfgapi.obj \
+
+# ... cfgreg ..............................
+APP2STDLIBS = $(APPSTDLIBS)
+
+APP2STDLIBS+=$(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP2STDLIBS+=$(LIBCIMT)
+.ENDIF
+
+APP2TARGET= $(TARGET2)
+APP2OBJS= \
+ $(SLO)$/cfgregistry.obj \
+
+# ... cfgadduser ..............................
+APP3STDLIBS = $(APPSTDLIBS)
+
+APP3STDLIBS+=$(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP3STDLIBS+=$(LIBCIMT)
+.ENDIF
+
+APP3TARGET= $(TARGET3)
+APP3OBJS= \
+ $(SLO)$/cfgadduser.obj \
+
+
+.INCLUDE : target.mk
+
+
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/cfgfile.cxx b/configmgr/workben/local_io/cfgfile.cxx
new file mode 100644
index 000000000000..844b20aabeb6
--- /dev/null
+++ b/configmgr/workben/local_io/cfgfile.cxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfgfile.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// ------------------------------------ main ------------------------------------
+// -----------------------------------------------------------------------------
+
+/*
+ OUString operator+(const OUString &a, const OUString &b)
+ {
+ OUString c = a;
+ c += b;
+ return c;
+ }
+*/
+
+namespace configmgr
+{
+ void simpleMappingTest();
+
+ void importTest();
+ void exportTest();
+
+ void hierarchyTest();
+ //void simpleTest();
+ void speedTest();
+ void stringTest();
+}
+
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+ int _cdecl main( int argc, char * argv[] )
+#endif
+{
+
+// configmgr::hierarchyTest();
+
+
+// configmgr::importTest();
+// configmgr::exportTest();
+// configmgr::speedTest();
+// configmgr::simpleTest();
+
+// configmgr::simpleMappingTest();
+ configmgr::stringTest();
+
+ return 0;
+}
+
+
diff --git a/configmgr/workben/local_io/cfglocal.cxx b/configmgr/workben/local_io/cfglocal.cxx
new file mode 100644
index 000000000000..8c2111b8f364
--- /dev/null
+++ b/configmgr/workben/local_io/cfglocal.cxx
@@ -0,0 +1,666 @@
+/*************************************************************************
+ *
+ * $RCSfile: cfglocal.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define _PRIVATE_TEST_
+
+#include <memory.h>
+#include <string.h>
+#include <stdio.h>
+
+#ifndef _VOS_SOCKET_HXX_
+#include <vos/socket.hxx>
+#endif
+
+#ifndef _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+#include "attributes.hxx"
+#endif
+
+#ifndef _CONFIGMGR_SESSION_REMOTESESSION_HXX_
+#include "remotesession.hxx"
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _VOS_CONDITN_HXX_
+#include <vos/conditn.hxx>
+#endif
+
+#include <osl/time.h>
+
+#include "localsession.hxx"
+#include "confname.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::xml;
+using namespace ::vos;
+using namespace ::cppu;
+using namespace ::configmgr;
+using namespace rtl;
+
+// #define USE_LAYOUT_NODE
+
+//=============================================================================
+//= a dirty littly class for printing ascii characters
+//=============================================================================
+class OAsciiOutput
+{
+protected:
+ sal_Char* m_pCharacters;
+
+public:
+ OAsciiOutput(const ::rtl::OUString& _rUnicodeChars);
+ ~OAsciiOutput() { delete m_pCharacters; }
+
+ const sal_Char* getCharacters() const { return m_pCharacters; }
+};
+
+//-----------------------------------------------------------------------------
+OAsciiOutput::OAsciiOutput(const ::rtl::OUString& _rUnicodeChars)
+{
+ sal_Int32 nLen = _rUnicodeChars.getLength();
+ m_pCharacters = new sal_Char[nLen + 1];
+ sal_Char* pFillPtr = m_pCharacters;
+ const sal_Unicode* pSourcePtr = _rUnicodeChars.getStr();
+#ifdef DBG_UTIL
+ sal_Bool bAsserted = sal_False;
+#endif
+ for (sal_Int32 i=0; i<nLen; ++i, ++pFillPtr, ++pSourcePtr)
+ {
+ OSL_ENSHURE(bAsserted || !(bAsserted = (*pSourcePtr >= 0x80)),
+ "OAsciiOutput::OAsciiOutput : non-ascii character found !");
+ *pFillPtr = *reinterpret_cast<const sal_Char*>(pSourcePtr);
+ }
+ *pFillPtr = 0;
+}
+
+#define ASCII_STRING(rtlOUString) OAsciiOutput(rtlOUString).getCharacters()
+#define UNI_STRING(salCharPtr) ::rtl::OUString::createFromAscii(salCharPtr)
+
+//=============================================================================
+//= OOpenNodeCallback
+//=============================================================================
+typedef ::cppu::WeakImplHelper1< sax::XDocumentHandler > OOpenNodeCallback_Base;
+class OOpenNodeCallback : public IOpenObjectCallback, public OOpenNodeCallback_Base
+{
+protected:
+ OUString m_sNodeId;
+ ::vos::OCondition& m_rFinishCondition;
+
+ enum ACTION { STARTELEMENT, CHARACTERS, ENDELEMENT };
+ ACTION m_eLastAction;
+ sal_Int32 m_nLevel;
+ sal_Bool m_bCloseStartTag;
+
+protected:
+ ~OOpenNodeCallback()
+ {
+ }
+
+public:
+ OOpenNodeCallback(::vos::OCondition& _rFinishCond) : m_rFinishCondition(_rFinishCond), m_nLevel(0), m_eLastAction(ENDELEMENT), m_bCloseStartTag(sal_False) { }
+
+ OUString getNodeId() const { return m_sNodeId; }
+
+ // IOpenObjectCallback
+ virtual void gotObjectId(const OUString &aName);
+
+ // IDataRequestCallback
+ virtual Reference< sax::XDocumentHandler > getDataReader() { return static_cast< sax::XDocumentHandler* >(this); }
+
+ // IRequestCallback
+ virtual void acknowledged(sal_Int32 _nTransId);
+ virtual void failed(sal_Int32 _nErrorCode);
+ virtual void done(const StatusInfo& _rStatus);
+
+ // IInterface
+ virtual void SAL_CALL acquire( ) throw (::com::sun::star::uno::RuntimeException) { OOpenNodeCallback_Base::acquire(); }
+ virtual void SAL_CALL release( ) throw (::com::sun::star::uno::RuntimeException) { OOpenNodeCallback_Base::release(); }
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument( ) throw(sax::SAXException, RuntimeException) { }
+ virtual void SAL_CALL endDocument( ) throw(sax::SAXException, RuntimeException) { }
+ virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const Reference< sax::XAttributeList >& xAttribs ) throw(sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw(sax::SAXException, RuntimeException);
+ virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw(sax::SAXException, RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw(sax::SAXException, RuntimeException) { }
+ virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw(sax::SAXException, RuntimeException) { }
+ virtual void SAL_CALL setDocumentLocator( const Reference< sax::XLocator >& xLocator ) throw(sax::SAXException, RuntimeException) { }
+};
+
+//.............................................................................
+inline void linefeed()
+{
+ // printf("\n");
+}
+
+//.............................................................................
+void printTabs(sal_Int32 _nCount)
+{
+ sal_Char* pBuffer = new sal_Char[2 * _nCount + 1];
+ memset(pBuffer, ' ', 2 * _nCount);
+ pBuffer[2 * _nCount] = 0;
+ // printf(pBuffer);
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OOpenNodeCallback::startElement( const ::rtl::OUString& _rName, const Reference< sax::XAttributeList >& xAttribs ) throw(sax::SAXException, RuntimeException)
+{
+ switch (m_eLastAction)
+ {
+ case STARTELEMENT:
+ if (m_bCloseStartTag)
+ {
+ // printf(">");
+ }
+
+ m_bCloseStartTag = sal_False;
+ // no break
+ case CHARACTERS:
+ case ENDELEMENT:
+ linefeed();
+ printTabs(m_nLevel);
+ break;
+ }
+ m_eLastAction = STARTELEMENT;
+ ++m_nLevel;
+ // printf("<%s", ASCII_STRING(_rName));
+ m_bCloseStartTag = sal_True;
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OOpenNodeCallback::endElement( const ::rtl::OUString& _rName ) throw(sax::SAXException, RuntimeException)
+{
+ --m_nLevel;
+ switch (m_eLastAction)
+ {
+ case STARTELEMENT:
+ if (m_bCloseStartTag)
+ {
+ // printf("/>");
+ }
+
+ m_bCloseStartTag = sal_False;
+ break;
+ case ENDELEMENT:
+ linefeed();
+ printTabs(m_nLevel);
+ // dont break
+ case CHARACTERS:
+ // printf("</%s>", ASCII_STRING(_rName));
+ break;
+ }
+ m_eLastAction = ENDELEMENT;
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OOpenNodeCallback::characters( const ::rtl::OUString& _rChars ) throw(sax::SAXException, RuntimeException)
+{
+ if (STARTELEMENT == m_eLastAction)
+ {
+ if (m_bCloseStartTag && _rChars.trim().getLength())
+ {
+ // printf(">");
+ m_bCloseStartTag = sal_False;
+ }
+ }
+ if (_rChars.trim().getLength() != 0)
+ {
+ // printf("%s", ASCII_STRING(_rChars));
+ m_eLastAction = CHARACTERS;
+ }
+}
+
+//-----------------------------------------------------------------------------
+void OOpenNodeCallback::gotObjectId(const OUString &_nId)
+{
+ m_sNodeId = _nId;
+ // printf("object id %i\n", m_nNodeId);
+}
+
+//-----------------------------------------------------------------------------
+void OOpenNodeCallback::acknowledged(sal_Int32 _nTransId)
+{
+ // printf("acknowledged, transaction id : %i\n", _nTransId);
+}
+
+//-----------------------------------------------------------------------------
+void OOpenNodeCallback::failed(sal_Int32 _nErrorCode)
+{
+ // printf("failed because of a connection error (%i)\n", _nErrorCode);
+ m_rFinishCondition.set();
+}
+
+//-----------------------------------------------------------------------------
+void OOpenNodeCallback::done(const StatusInfo& _rStatus)
+{
+ if (_rStatus.nCode)
+ {
+ printf("\n\ndone, but had an error : %s\n", ASCII_STRING(_rStatus.sMessage));
+ }
+ else
+ {
+ // printf("\n\nsuccessfully done\n", ASCII_STRING(_rStatus.sMessage));
+ }
+
+ m_rFinishCondition.set();
+}
+
+//=============================================================================
+//= ONodeUpdater
+//=============================================================================
+class ONodeUpdater : public IDOMNodeDataProvider
+{
+ sal_Bool m_bWriterLevel;
+ sal_Bool m_bAdd;
+public:
+ ONodeUpdater(sal_Bool _bStartAtWriterLevel, sal_Bool bAdd) : m_bWriterLevel(_bStartAtWriterLevel), m_bAdd(bAdd) { }
+
+ virtual void writeNodeData(const Reference< sax::XDocumentHandler >& _rHandler);
+};
+
+//-----------------------------------------------------------------------------
+void ONodeUpdater::writeNodeData(const Reference< sax::XDocumentHandler >& _rHandler)
+{
+ AttributeListImpl *pAttr = new AttributeListImpl;
+ Reference< sax::XAttributeList > xEmptyAttrList = pAttr;
+
+ pAttr = new AttributeListImpl;
+ pAttr->addAttribute(UNI_STRING("type"),UNI_STRING("CDATA"),UNI_STRING("string"));
+ Reference< sax::XAttributeList > xStringAttrList = pAttr;
+
+ if (m_bWriterLevel)
+ _rHandler->startElement(UNI_STRING("Writer"), xEmptyAttrList);
+#ifdef USE_LAYOUT_NODE
+ _rHandler->startElement(UNI_STRING("Layout"), xEmptyAttrList);
+ _rHandler->startElement(UNI_STRING("TabStops"), xEmptyAttrList);
+ if (m_bAdd)
+ _rHandler->characters(UNI_STRING("0.90"));
+ else
+ _rHandler->characters(UNI_STRING("99.99"));
+
+ _rHandler->endElement(UNI_STRING("TabStops"));
+ _rHandler->endElement(UNI_STRING("Layout"));
+#else
+ // _rHandler->startElement(UNI_STRING("com.sun.star.office.Setup"), xEmptyAttrList);
+ _rHandler->startElement(UNI_STRING("Modules"), xEmptyAttrList);
+ _rHandler->startElement(UNI_STRING("StandFonts"), xEmptyAttrList);
+ _rHandler->startElement(UNI_STRING("Standard"), xStringAttrList);
+ _rHandler->startElement(UNI_STRING("value"), xEmptyAttrList);
+ if (m_bAdd)
+ _rHandler->characters(UNI_STRING("Arial"));
+ else
+ _rHandler->characters(UNI_STRING("Courier"));
+
+ _rHandler->endElement(UNI_STRING("value"));
+ _rHandler->endElement(UNI_STRING("Standard"));
+ _rHandler->endElement(UNI_STRING("StandFonts"));
+ _rHandler->endElement(UNI_STRING("Modules"));
+ // _rHandler->endElement(UNI_STRING("com.sun.star.office.Setup"));
+
+ _rHandler->ignorableWhitespace(OUString());
+#endif
+ if (m_bWriterLevel)
+ _rHandler->endElement(UNI_STRING("Writer"));
+}
+
+//=============================================================================
+//= OSessionListener
+//=============================================================================
+class OSessionListener : public ISessionListener
+{
+protected:
+ oslInterlockedCount m_refCount;
+
+public:
+ // ISessionListener
+ virtual void nodeUpdated(const ::rtl::OUString& _rNodePath);
+ virtual void nodeDeleted(const ::rtl::OUString& _rNodePath);
+ virtual void nodeAdded(const ::rtl::OUString& _rNodePath);
+
+ // IInterface
+ virtual void SAL_CALL acquire( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL release( ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+//-----------------------------------------------------------------------------
+void OSessionListener::nodeUpdated(const ::rtl::OUString& _rNodePath)
+{
+ // printf("[listener] : a node was updated, node path : %s\n", ASCII_STRING(_rNodePath));
+}
+
+//-----------------------------------------------------------------------------
+void OSessionListener::nodeDeleted(const ::rtl::OUString& _rNodePath)
+{
+ // printf("[listener] : a node was deleted, node path : %s\n", ASCII_STRING(_rNodePath));
+}
+
+//-----------------------------------------------------------------------------
+void OSessionListener::nodeAdded(const ::rtl::OUString& _rNodePath)
+{
+ // printf("\n[listener] : a node was added, node path : %s", ASCII_STRING(_rNodePath));
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OSessionListener::acquire( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ osl_incrementInterlockedCount(&m_refCount);
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OSessionListener::release( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if (!osl_decrementInterlockedCount(&m_refCount))
+ delete this;
+}
+
+//=============================================================================
+//=============================================================================
+
+//=============================================================================
+static ::rtl::OUString sHost;
+static sal_Int32 nPort;
+static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb");
+
+//=============================================================================
+sal_Bool collectArgs(int argc, char * argv[])
+{
+ if (argc > 1)
+ {
+ sal_Char* pConnectTo = argv[1];
+ sal_Char* pSeparator = strchr(pConnectTo, ':');
+ if (pSeparator && (0 != *(pSeparator + 1)))
+ {
+ sHost = ::rtl::OUString(pConnectTo, pSeparator - pConnectTo, RTL_TEXTENCODING_ASCII_US);
+ nPort = ::rtl::OUString::createFromAscii(pSeparator + 1).toInt32();
+
+ if (argc > 2)
+ sRegistry = ::rtl::OUString::createFromAscii(argv[2]);
+ return sal_True;
+ }
+ }
+
+ printf("cfgclient - registry server client test ...\n\r\n\r");
+ printf("usage :\n\r");
+ printf(" cfgclient <server>:<port> [<registry file>]\n\r\n\r");
+ printf(" <server> : machine to connect to\n\r");
+ printf(" <port> : port to connect to\n\r");
+ printf(" <registry file> : (optional) registry to bootstrap from. defaulted to \"applicat.rdb\"\n\r\n\r");
+ return sal_False;
+}
+
+//=============================================================================
+
+#if (defined UNX) || (defined OS2)
+void main( int argc, char * argv[] )
+#else
+void _cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xORB;
+ try
+ {
+ xORB = createRegistryServiceFactory(sRegistry, ::rtl::OUString());
+ }
+ catch (Exception& e)
+ {
+ printf("could not bootstrap the services from %s\n\r", ASCII_STRING(sRegistry));
+ printf(" (error message : %s)", ASCII_STRING(e.Message));
+ }
+
+ if (!xORB.is())
+ {
+ fprintf(stdout, "could not create the service factory !");
+ return;
+ }
+
+ ORef< OSessionListener > xListener = new OSessionListener;
+ {
+/*
+ ORemoteSession aSession(xORB);
+ // --------- connect ----------
+ sal_Bool bSuccess = aSession.connect(sHost, nPort, &aTimeout);
+ if (!bSuccess)
+ {
+ printf("could not connect to the server (error : %i) ...", aSession.getConnectionError());
+ return;
+ }
+*/
+
+ void testSession(const Reference< XMultiServiceFactory > &xORB, bool bPrint);
+
+ for (int i=0;i<100;i++)
+ {
+ TimeValue aStartTime, aEndTime;
+ osl_getSystemTime(&aStartTime);
+ testSession(xORB, false);
+ osl_getSystemTime(&aEndTime);
+
+ sal_Int32 nSeconds = aEndTime.Seconds - aStartTime.Seconds;
+ sal_Int32 nNanoSec = aEndTime.Nanosec - aStartTime.Nanosec;
+ if (nNanoSec < 0)
+ {
+ nNanoSec = 1000000000 - nNanoSec;
+ nSeconds++;
+ }
+
+ cout << "Time: " << nSeconds << ". " << nNanoSec << endl;
+ }
+ }
+}
+
+void testSession(const Reference< XMultiServiceFactory > &xORB, bool bPrint)
+{
+ TimeValue aTimeout;
+ aTimeout.Seconds = 5;
+ aTimeout.Nanosec = 0;
+
+
+ // create it .. and connect
+ LocalSession aSession(xORB);
+
+ // --------- openSession ----------
+
+ OUString aRootPath = OUString::createFromAscii("f:/local/SRC598/configmgr/workben/local_io");
+ // f:/local/SRC595/configmgr/workben/local_io);
+ aSession.open(aRootPath);
+
+ if (aSession.isOpen())
+ {
+ if (bPrint) printf("\nopened the session ...");
+ }
+ else
+ {
+ printf("\ncould not open the session ... exiting\n\n");
+ return;
+ }
+
+ // aSession.setListener(xListener.getBodyPtr());
+
+ OCondition aWaitForSomething;
+ aWaitForSomething.reset();
+
+ // --------- openNode ----------
+ char* pWriterNode = "com.sun.star.Setup/Modules";
+ if (bPrint) printf("\nsending an openNode request for %s ...\n", pWriterNode);
+ ORef< OOpenNodeCallback > xOpenCallback = new OOpenNodeCallback(aWaitForSomething);
+ aSession.openNode(UNI_STRING(pWriterNode), 2, xOpenCallback.getBodyPtr());
+
+ aTimeout.Seconds = 30;
+ switch (aWaitForSomething.wait(&aTimeout))
+ {
+ case ICondition::result_error:
+ printf("error while waiting for the callback ... exiting\n\n");
+ return;
+ case ICondition::result_timeout:
+ if (bPrint) printf("timed out ... exiting\n\n");
+ return;
+ }
+
+ OUString sOpenedNode = xOpenCallback->getNodeId();
+
+// aSession.getNode(UNI_STRING("com.sun.star.Spreadsheet"), NULL);
+//
+// // --------- getNode (1) ----------
+//#ifdef USE_LAYOUT_NODE
+// char* pLayoutNode = "com.sun.star.office.Setup/Modules";
+//#else
+ char* pLayoutNode = "com.sun.star.Setup/Modules";
+//#endif
+// printf("\nsending an getNode request for %s ...\n", pLayoutNode);
+// aWaitForSomething.reset();
+// aSession.getNode(UNI_STRING(pLayoutNode), new OOpenNodeCallback(aWaitForSomething));
+//
+// switch (aWaitForSomething.wait(&aTimeout))
+// {
+// case ICondition::result_error:
+// printf("error while waiting for the callback ... exiting\n\n");
+// return;
+// case ICondition::result_timeout:
+// printf("timed out ... exiting\n\n");
+// return;
+// }
+
+ // --------- addNode ----------
+ if (bPrint) printf("\n\naddNode ....");
+ ONodeUpdater aAddTabstops(sal_False, true); // true = WRITER LEVEL
+ aWaitForSomething.reset();
+ aSession.addNode(sOpenedNode, UNI_STRING(pLayoutNode), &aAddTabstops, new OOpenNodeCallback(aWaitForSomething));
+ switch (aWaitForSomething.wait(&aTimeout))
+ {
+ case ICondition::result_error:
+ printf("error while waiting for the callback ... exiting\n\n");
+ return;
+ case ICondition::result_timeout:
+ if (bPrint) printf("timed out ... exiting\n\n");
+ return;
+ }
+
+ // --------- updateNode ----------
+ if (bPrint) printf("\n\nokay, let's try an update ....\n");
+
+ ONodeUpdater aUpdateWriter(sal_False, false);
+ aWaitForSomething.reset();
+ aSession.updateNode(sOpenedNode, UNI_STRING(pLayoutNode), &aUpdateWriter, new OOpenNodeCallback(aWaitForSomething));
+
+ switch (aWaitForSomething.wait(&aTimeout))
+ {
+ case ICondition::result_error:
+ printf("error while waiting for the callback ... exiting\n\n");
+ return;
+ case ICondition::result_timeout:
+ if (bPrint) printf("timed out ... exiting\n\n");
+ return;
+ }
+
+ // --------- deleteNode ----------
+ char* pLayoutNode2 = "com.sun.star.Setup/Modules/StandFonts";
+
+ if (bPrint) printf("\n\ndeleteNode ....");
+ aWaitForSomething.reset();
+ aSession.deleteNode(sOpenedNode, UNI_STRING(pLayoutNode2), new OOpenNodeCallback(aWaitForSomething));
+ switch (aWaitForSomething.wait(&aTimeout))
+ {
+ case ICondition::result_error:
+ printf("error while waiting for the callback ... exiting\n\n");
+ return;
+ case ICondition::result_timeout:
+ if (bPrint) printf("timed out ... exiting\n\n");
+ return;
+ }
+
+/*
+ // --------- startListening ----------
+ printf("\n\nadding a listener for the Layout node\n");
+ Sequence< ::rtl::OUString > aNodesToListen(1);
+ aNodesToListen[0] = UNI_STRING(pLayoutNode);
+ aSession.startListening(aNodesToListen, NULL);
+
+ printf("waiting 10 seconds ....\n\n");
+ aWaitForSomething.reset();
+ aTimeout.Seconds = 10;
+ aWaitForSomething.wait(&aTimeout);
+*/
+ // --------- getNode (2) ----------
+// printf("\ndoing a new getNode for the Layout node ...\n");
+// aWaitForSomething.reset();
+// aSession.getNode(UNI_STRING(pLayoutNode), new OOpenNodeCallback(aWaitForSomething));
+// switch (aWaitForSomething.wait(&aTimeout))
+// {
+// case ICondition::result_error:
+// printf("error while waiting for the callback ... exiting\n\n");
+// return;
+// case ICondition::result_timeout:
+// printf("timed out ... exiting\n\n");
+// return;
+// }
+
+ aSession.closeNode(sOpenedNode, NULL);
+ aSession.close(NULL);
+
+}
+
diff --git a/configmgr/workben/local_io/com.sun.star.office.Setup.xml b/configmgr/workben/local_io/com.sun.star.office.Setup.xml
new file mode 100644
index 000000000000..4018ab3b8d5d
--- /dev/null
+++ b/configmgr/workben/local_io/com.sun.star.office.Setup.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<com.sun.star.office.Setup>
+ <Language>
+ <Language_ID Type="string"><value>1033</value></Language_ID>
+ </Language>
+ <Modules>
+ <SCalc Type="boolean">
+ <value>true</value>
+ </SCalc>
+ <SChart Type="boolean">
+ <value>true</value>
+ </SChart>
+ <SDraw Type="boolean">
+ <value>true</value>
+ </SDraw>
+ <SImage Type="boolean">
+ <value>true</value>
+ </SImage>
+ <SImpress Type="boolean">
+ <value>true</value>
+ </SImpress>
+ <SMath Type="boolean">
+ <value>true</value>
+ </SMath>
+ <SWriter Type="boolean">
+ <value>true</value>
+ </SWriter>
+ </Modules>
+</com.sun.star.office.Setup> \ No newline at end of file
diff --git a/configmgr/workben/local_io/filetest.cxx b/configmgr/workben/local_io/filetest.cxx
new file mode 100644
index 000000000000..1d038480e827
--- /dev/null
+++ b/configmgr/workben/local_io/filetest.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * $RCSfile: filetest.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <iostream>
+
+#ifndef _OSL_FILE_HXX_
+#include<osl/file.hxx>
+#endif
+
+#include <rtl/ustring.hxx>
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+// -----------------------------------------------------------------------------
+// --------------------------------- namespaces ---------------------------------
+// -----------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+
+using ::rtl::OUString;
+using ::osl::File;
+// -----------------------------------------------------------------------------
+// ---------------------------------- defines ----------------------------------
+// -----------------------------------------------------------------------------
+#define ASCII(x) OUString::createFromAscii(x)
+
+
+// -----------------------------------------------------------------------------
+// ------------------------------------ main ------------------------------------
+// -----------------------------------------------------------------------------
+
+/*
+OUString operator+(const OUString &a, const OUString &b)
+{
+ OUString c = a;
+ c += b;
+ return c;
+}
+*/
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ OUString aPath = ASCII("f:/local/SRC598/configmgr/workben/local_io");
+ OUString aFilename = ASCII("com.sun.star.office.Setup");
+ OUString aExtension = ASCII("xml");
+
+ OUString aFullname = aPath + ASCII("/") + aFilename + ASCII(".") + aExtension;
+
+ // Filename convertieren
+ OUString aURL;
+ File aConvert(ASCII(""));
+ aConvert.normalizePath(aFullname, aURL);
+
+ // File oeffnen
+ File aFile(aURL);
+ aFile.open(osl_File_OpenFlag_Read);
+
+ sal_uInt64 nBytesRead;
+ Sequence< sal_Int8 > aBufferSeq(2000);
+ sal_Int8 *pBuff = aBufferSeq.getArray();
+ aFile.read(pBuff, 2000, nBytesRead);
+
+ aFile.close();
+ return 0;
+}
diff --git a/configmgr/workben/local_io/makefile.mk b/configmgr/workben/local_io/makefile.mk
new file mode 100644
index 000000000000..e82cc8e9c586
--- /dev/null
+++ b/configmgr/workben/local_io/makefile.mk
@@ -0,0 +1,154 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+#
+# 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: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=$(PRJ)$/source
+
+PRJNAME=configmgr
+
+TARGET=cfglocal
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\"
+
+# ... common for all test executables ..............................
+APPSTDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(UNOTOOLSLIB) \
+ $(CPPUHELPERLIB) \
+
+
+# ... FileTests .....................................................
+APP1STDLIBS = $(APPSTDLIBS) \
+ $(STDLIBCPP) \
+
+APP1STDLIBS+=$(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+=$(LIBCIMT)
+.ENDIF
+
+
+APP1TARGET= cfgfile
+
+APP1OBJS= \
+ $(SLO)$/cfgfile.obj \
+ $(SLO)$/oslstream.obj \
+ $(SLO)$/xmlexport.obj \
+ $(SLO)$/xmlimport.obj \
+ $(SLO)$/filehelper.obj \
+ $(SLO)$/simpletest.obj \
+ $(SLO)$/strimpl.obj \
+
+# $(SLO)$/xmltreebuilder.obj \
+# $(SLO)$/cmtree.obj \
+# $(SLO)$/cmtreemodel.obj \
+# $(SLO)$/typeconverter.obj \
+# $(SLO)$/confname.obj \
+# $(SLO)$/changes.obj \
+# $(SLO)$/xmlformater.obj \
+# $(SLO)$/attributes.obj \
+# $(SLO)$/tracer.obj \
+
+
+# ... common for all test executables ..............................
+APP2STDLIBS = $(APPSTDLIBS)
+
+APP2STDLIBS+=$(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP2STDLIBS+=$(LIBCIMT)
+.ENDIF
+
+APP2TARGET= $(TARGET)
+APP2OBJS= \
+ $(SLO)$/cfglocal.obj \
+ $(SLO)$/receivethread.obj \
+ $(SLO)$/redirector.obj \
+ $(SLO)$/socketstream.obj \
+ $(SLO)$/attributes.obj \
+ $(SLO)$/localsession.obj \
+ $(SLO)$/saxtools.obj \
+ $(SLO)$/mergeupdates.obj \
+ $(SLO)$/oslstream.obj \
+ $(SLO)$/configsession.obj \
+ $(SLO)$/confname.obj \
+ $(SLO)$/sessionstream.obj \
+ $(SLO)$/filehelper.obj \
+ $(SLO)$/tracer.obj \
+ $(SLO)$/updatedom.obj \
+
+
+.INCLUDE : target.mk
+
+
diff --git a/configmgr/workben/local_io/simpletest.cxx b/configmgr/workben/local_io/simpletest.cxx
new file mode 100644
index 000000000000..2cf9d567c225
--- /dev/null
+++ b/configmgr/workben/local_io/simpletest.cxx
@@ -0,0 +1,537 @@
+/*************************************************************************
+ *
+ * $RCSfile: simpletest.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stl/memory>
+#include <stl/vector>
+#include <stl/stack>
+
+#ifndef _OSL_FILE_HXX_
+#include<osl/file.hxx>
+#endif
+
+#include <rtl/ustring>
+
+#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_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HDL_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HDL_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATACONTROL_HDL_
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XDATATRANSFEREVENTLISTENER_HDL_
+#include <com/sun/star/io/XDataTransferEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XDATAIMPORTER_HDL_
+#include <com/sun/star/io/XDataImporter.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HDL_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
+#include <com/sun/star/xml/sax/XParser.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_SAXPARSEEXCEPTION_HPP_
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#endif
+
+#include <com/sun/star/xml/sax/InputSource.hpp>
+
+#ifndef _VOS_THREAD_HXX_
+#include <vos/thread.hxx>
+#endif
+
+#include <vos/pipe.hxx>
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#include "oslstream.hxx"
+
+#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#endif
+
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XHierarchicalName.hpp>
+
+#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+
+#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
+#include <com/sun/star/script/XTypeConverter.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+#ifndef _OSL_CONDITN_HXX_
+#include <osl/conditn.hxx>
+#endif
+
+#include "xmltreebuilder.hxx"
+
+#include "dataimport.hxx"
+
+#include "createpropertyvalue.hxx"
+
+#ifndef _CONFIGMGR_STRDECL_HXX_
+#include "strdecl.hxx"
+#endif
+
+// -----------------------------------------------------------------------------
+// --------------------------------- namespaces ---------------------------------
+// -----------------------------------------------------------------------------
+namespace uno = com::sun::star::uno;
+namespace lang = com::sun::star::lang;
+namespace io = com::sun::star::io;
+namespace sax = com::sun::star::xml::sax;
+namespace script = com::sun::star::script;
+
+using ::rtl::OUString;
+using ::osl::File;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::io;
+
+// -----------------------------------------------------------------------------
+// ---------------------------------- defines ----------------------------------
+// -----------------------------------------------------------------------------
+#define ASCII(x) OUString::createFromAscii(x)
+
+
+
+// -----------------------------------------------------------------------------
+// ---------------------------------- a Class ----------------------------------
+// -----------------------------------------------------------------------------
+// <Name a="xyz" b="bar">
+
+//==========================================================================
+//= Visitors
+//==========================================================================
+
+
+namespace configmgr
+{
+
+ class XMLSimpleDocHandler : public ::cppu::WeakImplHelper1<sax::XDocumentHandler>
+ {
+ // uno::Reference< sax::XDocumentHandler > m_xWriter; // the service object for writing XML code
+
+ sal_Int32 m_nElementDepth;
+ sal_Int32 m_nIgnoreLevel;
+ public:
+ XMLSimpleDocHandler::XMLSimpleDocHandler()
+ {}
+
+
+ // DECLARE_UNO3_DEFAULTS(XMLReadFilter, CmDocumentHandler_BASE);
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument(void)
+ throw (sax::SAXException, uno::RuntimeException)
+ {
+ }
+
+ virtual void SAL_CALL endDocument(void)
+ throw(sax::SAXException, uno::RuntimeException)
+ {
+ }
+
+ virtual void SAL_CALL startElement(const rtl::OUString& aName,
+ const uno::Reference< sax::XAttributeList > &_xAttrList)
+ throw(sax::SAXException, uno::RuntimeException)
+ {
+ sal_Int16 nAttrCount = _xAttrList.is() ? _xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ OUString aParamName( _xAttrList->getNameByIndex( i ) );
+ OUString aParamValue( _xAttrList->getValueByIndex( i ) );
+ volatile int dummy = 0;
+ }
+ }
+
+ virtual void SAL_CALL endElement(const rtl::OUString& aName)
+ throw(sax::SAXException, uno::RuntimeException)
+ {
+ }
+
+ virtual void SAL_CALL characters(const rtl::OUString& aChars)
+ throw(sax::SAXException, uno::RuntimeException)
+ {}
+
+
+ virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
+ throw(sax::SAXException, uno::RuntimeException)
+ {}
+
+
+ virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
+ const rtl::OUString& aData)
+ throw(sax::SAXException, uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL setDocumentLocator(const uno::Reference< sax::XLocator > &xLocator)
+ throw(sax::SAXException, uno::RuntimeException)
+ {}
+ };
+
+// -----------------------------------------------------------------------------
+// ------------------------------------ Test ------------------------------------
+// -----------------------------------------------------------------------------
+#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;
+ try
+ {
+ xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString());
+ }
+ catch (uno::Exception& e)
+ {
+ cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ;
+ cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl;
+ }
+
+ if (!xMSF.is())
+ {
+ cerr << "could not create the service factory !" << endl;
+ return;
+ }
+
+ OUString aPath = ASCII("e:/temp/Test");
+ OUString aFilename = ASCII("calc");
+ OUString aExtension = ASCII("xml");
+
+ OUString aFullname = aPath + ASCII("/") + aFilename + ASCII(".") + aExtension;
+
+ // Filename convertieren
+ OUString aURL;
+ File aConvert(ASCII(""));
+ aConvert.normalizePath(aFullname, aURL);
+
+ // File oeffnen
+ File aFile(aURL);
+ aFile.open(osl_File_OpenFlag_Read);
+
+ uno::Reference<io::XInputStream> xInputStream =
+ new configmgr::OSLInputStreamWrapper(aFile);
+
+ // connect stream to input stream to the parser
+ InputSource aInputSource;
+ Reference<XInputStream> xPipeInput( xInputStream, UNO_QUERY );
+ aInputSource.aInputStream = xPipeInput;
+
+ Reference< sax::XParser > xParser;
+ xParser = Reference< sax::XParser > (
+ xMSF->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser")), UNO_QUERY);
+
+ XMLSimpleDocHandler *pTest = new XMLSimpleDocHandler();
+
+ // get filter
+ Reference<XDocumentHandler> xFilter = pTest;
+
+ // connect parser and filter
+ xParser->setDocumentHandler( xFilter );
+
+ // parse
+ sal_Int16 nRet = 0;
+ OUString sError;
+ try
+ {
+ xParser->parseStream( aInputSource );
+ }
+ catch( SAXParseException &e )
+ {
+ OUString sLine = OUString::valueOf(e.LineNumber);
+ OUString aStr = ASCII("SAXParseException occured in ");
+ sError = aStr + ASCII(" Line: (") + sLine + ASCII(")");
+
+ OSL_ENSHURE(0, rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US).getStr());
+ nRet = 3;
+ }
+ catch( SAXException &e )
+ {
+ sError = e.Message;
+ OSL_ENSHURE(0, rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US).getStr());
+ nRet = 4;
+ }
+ catch( IOException &e )
+ {
+ sError = e.Message;
+ OSL_ENSHURE(0, rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US).getStr());
+ nRet = 5;
+ }
+ }
+
+
+#include <osl/time.h>
+#include <rtl/string.hxx>
+
+class TimeTest
+{
+ TimeValue m_aStartTime, m_aEndTime;
+ bool m_bStarted;
+public:
+ TimeTest()
+ :m_bStarted(false)
+ {
+ }
+
+ void start()
+ {
+ m_bStarted = true;
+ osl_getSystemTime(&m_aStartTime);
+ }
+ void stop()
+ {
+ osl_getSystemTime(&m_aEndTime);
+ OSL_ENSHURE(m_bStarted, "Not Started.");
+ m_bStarted = false;
+ }
+ void showTime(const rtl::OString & aWhatStr)
+ {
+ OSL_ENSHURE(!m_bStarted, "Not Stopped.");
+
+ sal_Int32 nSeconds = m_aEndTime.Seconds - m_aStartTime.Seconds;
+ sal_Int32 nNanoSec = m_aEndTime.Nanosec - m_aStartTime.Nanosec;
+ if (nNanoSec < 0)
+ {
+ nNanoSec = 1000000000 - nNanoSec;
+ nSeconds++;
+ }
+ rtl::OString aStr = "Time for ";
+ aStr += aWhatStr;
+ aStr += " : ";
+ aStr += rtl::OString::valueOf(nSeconds);
+ aStr += ".";
+ aStr += rtl::OString::valueOf(nNanoSec);
+
+ cout << aStr.getStr() << endl;
+ }
+
+};
+
+// -----------------------------------------------------------------------------
+// -------------------------------- Mapping Test --------------------------------
+// -----------------------------------------------------------------------------
+
+typedef ::std::pair< rtl::OUString, rtl::OUString > Assoc;
+// typedef ::std::set<Assoc, ltNode> MappingTable;
+typedef std::vector<Assoc> MappingTable;
+
+rtl::OUString mapTo(const rtl::OUString& aFrom, bool bToNew)
+{
+ static MappingTable aMap;
+ if (aMap.empty())
+ {
+ // Fill Map old, new
+
+ aMap.push_back(Assoc(ASCII("value"), TAG_VALUE));
+ aMap.push_back(Assoc(ASCII("type"), ATTR_TYPE));
+ aMap.push_back(Assoc(ASCII("instance"), ATTR_INSTANCE));
+ }
+ if (bToNew)
+ {
+ // check, if we should convert first to second
+ for (std::vector<Assoc>::const_iterator it = aMap.begin();it != aMap.end();++it)
+ {
+ if ((*it).first.equals(aFrom))
+ return (*it).second;
+ }
+ }
+ else
+ {
+ // check if we should convert second to first
+ for (std::vector<Assoc>::const_iterator it = aMap.begin();it != aMap.end();++it)
+ {
+ if ((*it).second.equals(aFrom))
+ return (*it).first;
+ }
+ }
+
+ // do nothing!
+ return aFrom;
+}
+// -----------------------------------------------------------------------------
+void simpleMappingTest()
+{
+ OUString aValue = ASCII("value");
+ OUString aNew;
+
+ aNew = mapTo(aValue, true); // true for ToNew
+ aNew = mapTo(aNew, false);
+ aNew = mapTo(aNew, false);
+
+ volatile int dummy = 0;
+}
+
+// -----------------------------------------------------------------------------
+ void speedTest()
+ {
+ // check speed of:
+ // ASCII("value")
+ // TAG_VALUE
+ // ...
+
+ sal_Int32 nCount = 1000 * 1000 * 100;
+ sal_Int32 n;
+
+ cout << "Starting Timetest" << endl;
+ TimeTest tt;
+ tt.start();
+ for(n=0;n<nCount;n++)
+ {
+ }
+ tt.stop();
+ tt.showTime("Leere Schleife: ");
+
+
+ nCount = 1000 * 1000 * 5;
+ rtl::OUString aStr;
+
+ tt.start();
+ for(n=0;n<nCount;n++)
+ {
+ aStr = ASCII("value");
+ }
+ tt.stop();
+ tt.showTime("ASCII() ");
+
+
+ OUString aValue = ASCII("value");
+ tt.start();
+ for(n=0;n<nCount;n++)
+ {
+ aStr = TAG_VALUE;
+ }
+ tt.stop();
+ tt.showTime("TAG_VALUE: ");
+
+ }
+
+OUString changeToComSunStarPath(const OUString &aPath)
+{
+ static OUString aOO = ASCII("org.OpenOffice");
+ static OUString aCSS = ASCII("com.sun.star");
+ OUString aNewPath;
+
+ // compare
+ if (aPath.compareTo( aOO, aOO.getLength() ) == 0)
+ {
+ aNewPath = aCSS;
+ aNewPath += aPath.copy(aOO.getLength());
+ return aNewPath;
+ }
+ return aPath;
+}
+
+void stringTest()
+{
+ OUString aPath = ASCII("org.OpenOffice.Setup/blah/blub");
+
+ OUString aNewPath = changeToComSunStarPath(aPath);
+ volatile int dummy = 0;
+}
+
+} // namespace configmgr
diff --git a/configmgr/workben/local_io/xmlexport.cxx b/configmgr/workben/local_io/xmlexport.cxx
new file mode 100644
index 000000000000..341647154baa
--- /dev/null
+++ b/configmgr/workben/local_io/xmlexport.cxx
@@ -0,0 +1,302 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlexport.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include<iostream>
+
+#ifndef _OSL_FILE_HXX_
+#include<osl/file.hxx>
+#endif
+
+#include <rtl/ustring.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+/*
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+*/
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XDATATRANSFEREVENTLISTENER_HDL_
+#include <com/sun/star/io/XDataTransferEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XDATAIMPORTER_HDL_
+#include <com/sun/star/io/XDataExporter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HDL_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_SAXPARSEEXCEPTION_HPP_
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#endif
+
+#include "oslstream.hxx"
+#include "attributes.hxx"
+#include "typeconverter.hxx"
+#include "xmlformater.hxx"
+
+#ifndef _CONFIGMGR_FILEHELPER_HXX_
+#include "filehelper.hxx"
+#endif
+
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+
+#include "createpropertyvalue.hxx"
+// -----------------------------------------------------------------------------
+// --------------------------------- namespaces ---------------------------------
+// -----------------------------------------------------------------------------
+namespace configmgr
+{
+
+ namespace uno = com::sun::star::uno;
+ namespace lang = com::sun::star::lang;
+ namespace io = com::sun::star::io;
+ namespace sax = com::sun::star::xml::sax;
+ namespace beans = com::sun::star::beans;
+
+ using ::rtl::OUString;
+ using ::osl::File;
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+
+// -----------------------------------------------------------------------------
+// ---------------------------------- defines ----------------------------------
+// -----------------------------------------------------------------------------
+#define ASCII(x) OUString::createFromAscii(x)
+
+// -----------------------------------------------------------------------------
+ class Listener : public ::cppu::WeakImplHelper1<io::XDataTransferEventListener>
+ {
+ virtual void SAL_CALL disposing( const lang::EventObject& Source )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "disposing");
+ }
+
+
+ virtual void SAL_CALL finished( const io::DataTransferEvent& aEvent )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "finished");
+ }
+
+ virtual void SAL_CALL cancelled( const io::DataTransferEvent& aEvent )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "cancelled");
+ }
+ };
+
+ class Component: public ::cppu::WeakImplHelper1<lang::XComponent>
+ {
+ virtual void SAL_CALL dispose( )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "dispose");
+
+ }
+ virtual void SAL_CALL addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "addEventListener");
+ }
+ virtual void SAL_CALL removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "removeEventListener");
+ }
+ };
+
+
+
+
+
+#define ASCII_STRING(rtlOUString) rtl::OUStringToOString(rtlOUString, RTL_TEXTENCODING_ASCII_US).getStr()
+ static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb");
+
+
+
+
+
+
+
+
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+ void exportTest()
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF;
+ try
+ {
+ xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString());
+ }
+ catch (uno::Exception& e)
+ {
+ cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ;
+ cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl;
+ }
+
+ if (!xMSF.is())
+ {
+ cerr << "could not create the service factory !" << endl;
+ return;
+ }
+
+ OUString aPath = ASCII("l:/SRC601/configmgr/workben/local_io");
+ OUString sFilename = ASCII("exported_config");
+ OUString aExtension = ASCII("xml");
+
+ OUString aFullname = aPath + ASCII("/") + sFilename + ASCII(".") + aExtension;
+
+ // Filename convertieren
+ OUString aURL;
+ File aConvert(ASCII(""));
+ aConvert.normalizePath(aFullname, aURL);
+
+ FileHelper::tryToRemoveFile(aURL);
+
+ rtl::OUString sError;
+
+ // File oeffnen
+ File aFile(aURL);
+ osl::FileBase::RC eError = aFile.open(OpenFlag_Write | OpenFlag_Create);
+
+ if (eError != osl_File_E_None)
+ {
+ sError = ASCII("XMLExportTest:");
+ rtl::OString aStr = rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSHURE(0, aStr.getStr());
+ return;
+ }
+
+ // create an outputstream
+ uno::Reference<io::XOutputStream> xOutputStream = new configmgr::OSLOutputStreamWrapper(aFile);
+
+ // Listener & Component
+ uno::Reference<io::XDataTransferEventListener> rListener = new Listener();
+ uno::Reference<lang::XComponent> rComponent = new Component();
+
+
+ OUString sPath = ASCII("com.sun.star.ucb.Hierarchy");
+
+ // Create a TypeConverter
+ uno::Reference<script::XTypeConverter> aConverter;
+ aConverter = aConverter.query(xMSF->createInstance(ASCII( "com.sun.star.script.Converter" )) );
+
+ // prepare parameters for DataExport
+ Sequence< uno::Any > aArgs(4);
+ aArgs[0] <<= createPropertyValue(ASCII("PackageName"), sFilename);
+ aArgs[1] <<= createPropertyValue(ASCII("Path"), sPath); // multiple occur possible
+ aArgs[2] <<= createPropertyValue(ASCII("TypeConverter"), aConverter); // optional
+ aArgs[3] <<= createPropertyValue(ASCII("Path"), ASCII("com.sun.star.office.Setup")); // multiple occur possible
+
+ // important: createInstanceWithArguments will throw an IllegalArgumentException() if
+ // parameters are wrong...
+ Reference< XInterface > xDataExport = xMSF->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.DataExport"),
+ aArgs);
+
+ uno::Reference<io::XDataExporter> rExporter(xDataExport, UNO_QUERY);
+
+ // Export Data
+ rExporter->exportData(xOutputStream, rComponent, rListener);
+ }
+
+} // namespace configmgr
diff --git a/configmgr/workben/local_io/xmlimport.cxx b/configmgr/workben/local_io/xmlimport.cxx
new file mode 100644
index 000000000000..1f8ad31f5d4c
--- /dev/null
+++ b/configmgr/workben/local_io/xmlimport.cxx
@@ -0,0 +1,545 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlimport.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:13:43 $
+ *
+ * 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: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stl/memory>
+#include <stl/vector>
+#include <stl/stack>
+
+#ifndef _OSL_FILE_HXX_
+#include<osl/file.hxx>
+#endif
+
+#include <rtl/ustring.hxx>
+
+#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_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HDL_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HDL_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATACONTROL_HDL_
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XDATATRANSFEREVENTLISTENER_HDL_
+#include <com/sun/star/io/XDataTransferEventListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XDATAIMPORTER_HDL_
+#include <com/sun/star/io/XDataImporter.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HDL_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
+#include <com/sun/star/xml/sax/XParser.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_SAXPARSEEXCEPTION_HPP_
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#endif
+
+#include <com/sun/star/xml/sax/InputSource.hpp>
+
+#ifndef _VOS_THREAD_HXX_
+#include <vos/thread.hxx>
+#endif
+
+#include <vos/pipe.hxx>
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#include "oslstream.hxx"
+
+#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#endif
+
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XHierarchicalName.hpp>
+
+#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+
+#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
+#include <com/sun/star/script/XTypeConverter.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+#ifndef _OSL_CONDITN_HXX_
+#include <osl/conditn.hxx>
+#endif
+
+#include "xmltreebuilder.hxx"
+
+#include "dataimport.hxx"
+
+#include "createpropertyvalue.hxx"
+// -----------------------------------------------------------------------------
+// --------------------------------- namespaces ---------------------------------
+// -----------------------------------------------------------------------------
+namespace uno = com::sun::star::uno;
+namespace lang = com::sun::star::lang;
+namespace io = com::sun::star::io;
+namespace sax = com::sun::star::xml::sax;
+namespace script = com::sun::star::script;
+
+using ::rtl::OUString;
+using ::osl::File;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+
+// -----------------------------------------------------------------------------
+// ---------------------------------- defines ----------------------------------
+// -----------------------------------------------------------------------------
+#define ASCII(x) OUString::createFromAscii(x)
+
+
+
+// -----------------------------------------------------------------------------
+// ---------------------------------- a Class ----------------------------------
+// -----------------------------------------------------------------------------
+// <Name a="xyz" b="bar">
+
+//==========================================================================
+//= Visitors
+//==========================================================================
+
+
+// -----------------------------------------------------------------------------
+class Listener : public ::cppu::WeakImplHelper1<io::XDataTransferEventListener>
+{
+ osl::Condition m_aCondition;
+public:
+ Listener()
+ {
+ m_aCondition.reset(); // will block
+ }
+
+ virtual void SAL_CALL disposing( const lang::EventObject& Source )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "disposing");
+ m_aCondition.set(); // will not block
+ }
+
+ virtual void SAL_CALL finished( const io::DataTransferEvent& aEvent )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "finished");
+ m_aCondition.set(); // will not block
+ }
+
+ virtual void SAL_CALL cancelled( const io::DataTransferEvent& aEvent )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "cancelled");
+ m_aCondition.set(); // will not block
+ }
+public:
+ void wait()
+ {
+ m_aCondition.wait();
+ }
+};
+
+class Component: public ::cppu::WeakImplHelper1<lang::XComponent>
+{
+ virtual void SAL_CALL dispose( )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "dispose");
+
+ }
+ virtual void SAL_CALL addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "addEventListener");
+ }
+ virtual void SAL_CALL removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
+ throw(uno::RuntimeException)
+ {
+ OSL_ENSHURE(0, "removeEventListener");
+ }
+};
+
+
+
+namespace configmgr
+{
+
+// -----------------------------------------------------------------------------
+// ------------------------------------ Test ------------------------------------
+// -----------------------------------------------------------------------------
+#define ASCII_STRING(rtlOUString) rtl::OUStringToOString(rtlOUString, RTL_TEXTENCODING_ASCII_US).getStr()
+ static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb");
+
+ void importTest()
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF;
+ try
+ {
+ xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString());
+ }
+ catch (uno::Exception& e)
+ {
+ cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ;
+ cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl;
+ }
+
+ if (!xMSF.is())
+ {
+ cerr << "could not create the service factory !" << endl;
+ return;
+ }
+
+ OUString aPath = ASCII("l:/SRC601/configmgr/workben/local_io");
+ OUString aFilename = ASCII("hierarchy");
+ OUString aExtension = ASCII("xml");
+
+ OUString aFullname = aPath + ASCII("/") + aFilename + ASCII(".") + aExtension;
+
+ // Filename convertieren
+ OUString aURL;
+ File aConvert(ASCII(""));
+ aConvert.normalizePath(aFullname, aURL);
+
+ // File oeffnen
+ File aFile(aURL);
+ aFile.open(osl_File_OpenFlag_Read);
+
+ // sal_uInt64 nBytesRead;
+ // uno::Sequence< sal_Int8 > aBufferSeq(2000);
+ // sal_Int8 *pBuff = aBufferSeq.getArray();
+ // aFile.read(pBuff, 2000, nBytesRead);
+ //
+ // aFile.close();
+
+ uno::Reference<io::XInputStream> xInputStream = new configmgr::OSLInputStreamWrapper(aFile);
+
+ uno::Reference <uno::XInterface> xPump = xMSF->createInstance( L"com.sun.star.io.Pump" );
+ OSL_ENSHURE(xPump.is(), "there is no pump");
+
+ uno::Reference<io::XActiveDataSink> xPumpSink(xPump, uno::UNO_QUERY);
+ xPumpSink->setInputStream(xInputStream);
+
+ uno::Reference<io::XActiveDataSource> xPumpSource(xPump, uno::UNO_QUERY);
+
+ Listener *pListener = new Listener();
+ uno::Reference<io::XDataTransferEventListener> rListener = pListener;
+ uno::Reference<lang::XComponent> rComponent = new Component();
+
+ // Create a TypeConverter
+ uno::Reference<script::XTypeConverter> aConverter;
+ aConverter = aConverter.query(xMSF->createInstance(ASCII( "com.sun.star.script.Converter" )) );
+
+ Sequence< uno::Any > aArgs(1); // optional arg.
+ aArgs[0] <<= configmgr::createPropertyValue(ASCII("TypeConverter"), aConverter);
+
+ Reference< XInterface > xDataImport = xMSF->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.DataImport"),
+ aArgs);
+
+ if (xDataImport.is())
+ {
+ uno::Reference<io::XDataImporter> rImporter(xDataImport, UNO_QUERY);
+
+ // Import Data
+ rImporter->importData(xPumpSource, rComponent, rListener);
+
+ // lets pump
+ uno::Reference<io::XActiveDataControl> xControl(xPump, uno::UNO_QUERY);
+ xControl->start();
+
+ // TEST:
+ // rImporter->cancel();
+
+ // pImporter->wait();
+ // Wait until the listener send ready
+ pListener->wait();
+ }
+ return;
+ }
+
+// -----------------------------------------------------------------------------
+// -------------------------------- Import Test --------------------------------
+// -----------------------------------------------------------------------------
+
+ // ----------- TEST ReadAccess -----------
+ void showSequence(const Sequence<OUString> &aSeq);
+
+void hierarchyTest()
+{
+
+ uno::Reference< lang::XMultiServiceFactory > xMSF;
+ try
+ {
+ xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString());
+ }
+ catch (uno::Exception& e)
+ {
+ cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ;
+ cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl;
+ }
+
+ if (!xMSF.is())
+ {
+ cerr << "could not create the service factory !" << endl;
+ return;
+ }
+
+
+ Reference< XMultiServiceFactory > xCfgProvider( xMSF->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ UNO_QUERY);
+
+ if (!xCfgProvider.is())
+ {
+ OSL_ENSHURE(0, "No Configuration Provider");
+ }
+
+ OUString sPath = ASCII("com.sun.star.ucb.Hierarchy");
+
+ Sequence< Any > aArgs(1);
+ aArgs[0] <<= sPath;
+
+ Reference< XInterface > xCfgUpdt = xCfgProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
+ aArgs);
+
+ Reference< XNameAccess > xNameAccess(xCfgUpdt, UNO_QUERY);
+
+ // which Names are exist?
+ showSequence(xNameAccess->getElementNames());
+
+ OUString aNamePath = ASCII("Root");
+ if (xNameAccess->hasByName(aNamePath))
+ {
+ Any aAny;
+ aAny = xNameAccess->getByName(aNamePath);
+ TypeClass aTypeClass = aAny.getValueTypeClass();
+ if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ Reference< XInterface > xInterface;
+ aAny >>= xInterface;
+ Reference< XNameAccess > xNameAccess2(xInterface, UNO_QUERY);
+ if (xNameAccess.is())
+ {
+ Sequence<OUString> aSeq = xNameAccess2->getElementNames();
+ showSequence(aSeq);
+
+ // insert a new set
+/*
+ Reference<XHierarchicalName> xHierarchical(xNameAccess, UNO_QUERY);
+ OUString aHierachicalName = xHierarchical->getHierarchicalName();
+
+ Sequence< Any > aArgs(2);
+ aArgs[0] <<= aHierachicalName;
+ sal_Int32 nLevels=1;
+ aArgs[1] <<= nLevels;
+
+ Reference< XInterface > xCfgNewUpdt = xCfgProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
+ aArgs);
+*/
+ Reference< lang::XSingleServiceFactory > xChildFactory(xNameAccess2, UNO_QUERY);
+ if (xChildFactory.is())
+ {
+ Reference< XInterface > xChild = xChildFactory->createInstance();
+ if (xChild.is())
+ {
+ Reference<XNameAccess> xObjectOnTheMedow(xChild, UNO_QUERY);
+
+
+
+
+ // which Names are exist?
+ showSequence(xObjectOnTheMedow->getElementNames());
+
+ OUString aChildren = ASCII("Children");
+ if (xObjectOnTheMedow->hasByName(aChildren))
+ {
+ Any aAny;
+ aAny = xObjectOnTheMedow->getByName(aChildren);
+ TypeClass aTypeClass = aAny.getValueTypeClass();
+ if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ Reference< XInterface > xInterface;
+ aAny >>= xInterface;
+ Reference< XNameAccess > xChildFromOOM(xInterface, UNO_QUERY);
+
+ if (xChildFromOOM.is())
+ {
+ // insert a new Object in the new Object
+
+ Reference< lang::XSingleServiceFactory > xChildFactory(xChildFromOOM, UNO_QUERY);
+ if (xChildFactory.is())
+ {
+ Reference< XInterface > xChild = xChildFactory->createInstance();
+ if (xChild.is())
+ {
+ Reference<XNameContainer> xNameContainer(xChildFromOOM, UNO_QUERY);
+ if (xNameContainer.is())
+ {
+ xNameContainer->insertByName(ASCII("Test2"), makeAny(xChild));
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ Reference<XNameContainer> xNameContainer(xNameAccess2, UNO_QUERY);
+ if (xNameContainer.is())
+ {
+ xNameContainer->insertByName(ASCII("Test"), makeAny(xObjectOnTheMedow));
+ }
+ }
+
+ // commit changes
+ Reference< XChangesBatch > xChangesBatch(xCfgUpdt, UNO_QUERY);
+ if (xChangesBatch.is())
+ {
+ xChangesBatch->commitChanges();
+ }
+ }
+
+ Sequence<OUString> aSeq2 = xNameAccess2->getElementNames();
+ showSequence(aSeq2);
+
+/*
+ OUString *pStr = aSeq.getArray();
+ for (int i=0;i<aSeq.getLength();i++)
+ {
+ OUString aStr = pStr[i];
+ Any aAny;
+ aAny = xNameAccess->getByName(aStr);
+ TypeClass aTypeClass = aAny.getValueTypeClass();
+
+ Reference< XNameReplace > xNameReplace(xNameAccess, UNO_QUERY);
+
+ Any aNewAny;
+ sal_Bool bValue = false;
+ aNewAny <<= bValue;
+ xNameReplace->replaceByName(aStr, aNewAny);
+
+ volatile int dummy = 0;
+ }
+*/
+ }
+ }
+ volatile int dummy = 0;
+ }
+}
+
+// ------------------------------ Helperfunctions ------------------------------
+
+ void showSequence(const Sequence<OUString> &aSeq)
+ {
+ OUString aArray;
+ const OUString *pStr = aSeq.getConstArray();
+ for (int i=0;i<aSeq.getLength();i++)
+ {
+ OUString aStr = pStr[i];
+ aArray += aStr + ASCII(", ");
+ }
+ volatile int dummy = 0;
+ }
+
+} // namespace configmgr