From: Yurii R. <yr...@us...> - 2003-02-09 08:18:20
|
Update of /cvsroot/eas-dev/eas-dev/components/econf/src In directory sc8-pr-cvs1:/tmp/cvs-serv3491/components/econf/src Added Files: .cvsignore Makefile.am econf.cxx Log Message: liburl is now needed, ldap library needed; slightly improved build process; econf source code initial submission (still very incomplete); minor changes to logger initial submissions for bostorage; directory for programs --- NEW FILE: .cvsignore --- Makefile Makefile.in .deps .libs *.o *.lo libeconf.la --- NEW FILE: Makefile.am --- PRJ = @ODK_PATH@ CPPUHELPERLIB = CPPULIB = SALHELPERLIB = SALLIB = STLPORTLIB = @INCLUDE@ @ODK_PATH@/settings/settings.mk @INCLUDE@ @ODK_PATH@/settings/dk.mk @INCLUDE@ @ODK_PATH@/settings/std.mk lib_LTLIBRARIES = libeconf.la libeconf_la_SOURCES = econf.cxx econf_ldap.cxx INCLUDES = -I../../.incs -I@top_include@ -I@ODK_PATH@/include CXXFLAGS = @GLIB_CFLAGS@ libeconf_la_LIBADD = $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) -lstdc++ @GLIB_LIBS@ libeconf_la_LDFLAGS = -L/opt/openoffice/program/ -L@ODK_PATH@/linux/lib --- NEW FILE: econf.cxx --- /* $Id: econf.cxx,v 1.1 2003/02/09 08:18:17 yrashk Exp $ */ #include <config.h> #include <stdio.h> #include <iostream.h> #include <glib.h> #include <url/url_string.hh> #ifndef _OSL_MUTEX_HXX_ #include <osl/mutex.hxx> #endif #ifndef _RTL_USTRING_HXX_ #include <rtl/ustring> #endif #ifndef _UNO_DISPATCHER_H_ #include <uno/dispatcher.h> #endif #ifndef _UNO_MAPPING_HXX_ #include <uno/mapping.hxx> #endif #ifndef _CPPUHELPER_QUIRYINTERFACE_HXX_ #include <cppuhelper/queryinterface.hxx> #endif #ifndef _CPPUHELPER_FACTORY_HXX_ #include <cppuhelper/factory.hxx> #endif // generated c++ interfaces // #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #endif #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ #include <com/sun/star/registry/XRegistryKey.hpp> #endif #ifndef _ORG_OPENEAS_CONFIGURATION_XREGISTRY_HPP #include <org/openeas/configuration/XRegistry.hpp> #endif using namespace ::rtl; using namespace ::osl; using namespace ::cppu; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::registry; using namespace ::org::openeas::configuration; #define REGISTRYIMPLNAME "org.openeas.configuration.XRegistry" #define SERVICENAME "org.openeas.configuration.Configuration" class XRegistryImpl: public XRegistry, public XServiceInfo { Reference<XMultiServiceFactory> m_xServiceManager; Mutex m_mutex; sal_Int32 m_nRefCount; Reference<XRegistryStorage> m_storage; GHashTable * m_storages; Reference<XRegistryStorage> m_getStorage(const OUString& aURL) { url_string url(aURL); return *g_hash_table_lookup(m_storages,url.get_scheme()); } public: XRegistryImpl(const Reference<XMultiServiceFactory> & xServiceManager) : m_xServiceManager(xServiceManager), m_nRefCount(0) { m_storages = g_hash_table_new(g_str_hash,g_str_equal); } ~XRegistryImpl() { g_hash_table_destroy(m_storages); } // XInterface virtual void SAL_CALL acquire() throw () { ++m_nRefCount; } virtual void SAL_CALL release() throw () { if (! --m_nRefCount) delete this; } virtual Any SAL_CALL queryInterface(const Type& rType) throw (RuntimeException) { return cppu::queryInterface(rType, static_cast<XInterface *> (static_cast<XServiceInfo *>(this)), static_cast<XRegistry *>(this), static_cast<XServiceInfo *>(this)); } // XServiceInfo virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException); virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(RuntimeException); static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static(); // XRegistry virtual void SAL_CALL open (const OUString& aURL) throw (RuntimeException) { m_storage = m_getStorage(aURL); m_storage->open(aURL); } virtual void SAL_CALL close() throw (RuntimeException) { m_storage->close(); } virtual void SAL_CALL storeString(const OUString& aKey, const OUString& aVal) throw (RuntimeException) { m_storage->storeString(aKey,aVal); } virtual void SAL_CALL storeNumeric(const OUString& aKey, sal_Int32 aVal) throw (RuntimeException) { m_storage->storeNumeric(aKey,aVal); } virtual void SAL_CALL remove(const OUString& aKey) throw (RuntimeException) { m_storage->remove(aKey); } virtual void SAL_CALL registerStorage(const OUString& aSchema, const Reference<XRegistryStorage>& xStorage) throw (RuntimeException) { if (xStorage->isSupported()) g_hash_table_replace(m_storages,aSchema,*xStorage); } }; OUString SAL_CALL XRegistryImpl::getImplementationName() throw(RuntimeException) { Guard<Mutex> aGuard(m_mutex); return OUString(RTL_CONSTASCII_USTRINGPARAM(REGISTRYIMPLNAME)); } sal_Bool SAL_CALL XRegistryImpl::supportsService(const OUString& ServiceName) throw(RuntimeException) { Guard< Mutex > aGuard( m_mutex ); Sequence< OUString > aSNL = getSupportedServiceNames(); const OUString * pArray = aSNL.getArray(); for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) if( pArray[i] == ServiceName ) return sal_True; return sal_False; } Sequence<OUString> SAL_CALL XRegistryImpl::getSupportedServiceNames() throw(RuntimeException) { Guard<Mutex> aGuard(m_mutex); return getSupportedServiceNames_Static(); } Sequence<OUString> SAL_CALL XRegistryImpl::getSupportedServiceNames_Static() { OUString aName(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) ); return Sequence<OUString>( &aName, 1 ); } Reference<XInterface> SAL_CALL XRegistryImpl_create( const Reference<XMultiServiceFactory> & xMgr) { return Reference<XRegistry>(new XRegistryImpl(xMgr)); } 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) { sal_Bool result = sal_False; if (pRegistryKey) { try { Reference< XRegistryKey > xNewKey( reinterpret_cast<XRegistryKey *> (pRegistryKey)->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "/" REGISTRYIMPLNAME "/UNO/SERVICES") ) ) ); // FIXME: /UNO/ or /EAS/ ? const Sequence< OUString > & rSNL = XRegistryImpl::getSupportedServiceNames_Static(); const OUString *pArray = rSNL.getConstArray(); for (sal_Int32 nPos = rSNL.getLength(); nPos--;) xNewKey->createKey(pArray[nPos]); } catch (InvalidRegistryException &) { // TODO: handle exception } try { Reference< XRegistryKey > xLDAPKey( reinterpret_cast<XRegistryKey *> (pRegistryKey)->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "/" LDAPREGISTRYSTORAGEIMPLNAME "/UNO/SERVICES") ) ) ); // FIXME: /UNO/ or /EAS/ ? const Sequence< OUString > & rSNL = XRegistryImpl::getSupportedServiceNames_Static(); const OUString *pArray = rSNL.getConstArray(); for (sal_Int32 nPos = rSNL.getLength(); nPos--;) xLDAPKey->createKey(pArray[nPos]); return sal_True; } catch (InvalidRegistryException &) { // TODO: handle exception } } return result; } extern "C" void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey) { void * pRet = 0; if (rtl_str_compare(pImplName, REGISTRYIMPLNAME) == 0) { Reference<XSingleServiceFactory> xFactory( createSingleFactory( reinterpret_cast<XMultiServiceFactory *> (pServiceManager), OUString(RTL_CONSTASCII_USTRINGPARAM( REGISTRYIMPLNAME)), XRegistryImpl_create, XRegistryImpl::getSupportedServiceNames_Static())); if (xFactory.is()) { xFactory->acquire(); pRet = xFactory.get(); } } if (rtl_str_compare(pImplName, LDAPREGISTRYSTORAGEIMPLNAME) == 0) { Reference<XSingleServiceFactory> xFactory( createSingleFactory( reinterpret_cast<XMultiServiceFactory *> (pServiceManager), OUString(RTL_CONSTASCII_USTRINGPARAM( LDAPREGISTRYSTORAGEIMPLNAME)), XLDAPRegistryStorageImpl_create, XLDAPRegistryStorageImpl::getSupportedServiceNames_Static())); if (xFactory.is()) { xFactory->acquire(); pRet = xFactory.get(); } } return pRet; } |