diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-09-17 12:00:40 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-09-17 12:00:40 +0000 |
commit | 60f00a9b3f1a3d434e7b138eeef5ec3dc68aa6fa (patch) | |
tree | 391340a55a346e2784a67a7320d127d62202d6ce /shell/source/backends | |
parent | d8e561a2e168ec99caa8211d6724b12cafab6223 (diff) |
INTEGRATION: CWS syssettings02 (1.2.50); FILE MERGED
2004/09/03 06:16:03 obr 1.2.50.1: #i20364#,#i20369# gconf platform configuration backend now buildable
Diffstat (limited to 'shell/source/backends')
-rw-r--r-- | shell/source/backends/gconfbe/gconfbackend.cxx | 252 | ||||
-rw-r--r-- | shell/source/backends/gconfbe/gconfbackend.hxx | 123 |
2 files changed, 110 insertions, 265 deletions
diff --git a/shell/source/backends/gconfbe/gconfbackend.cxx b/shell/source/backends/gconfbe/gconfbackend.cxx index c14ec0066f35..afe01ca29d55 100644 --- a/shell/source/backends/gconfbe/gconfbackend.cxx +++ b/shell/source/backends/gconfbe/gconfbackend.cxx @@ -2,9 +2,9 @@ * * $RCSfile: gconfbackend.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: rt $ $Date: 2004-03-30 15:05:04 $ + * last change: $Author: rt $ $Date: 2004-09-17 13:00:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,12 +74,6 @@ #define INCLUDED_VECTOR #endif -#ifndef _OSL_FILE_HXX_ -#include <osl/file.hxx> -#endif -#ifndef _OSL_MODULE_HXX_ -#include <osl/module.hxx> -#endif #ifndef _OSL_PROCESS_H_ #include <osl/process.h> #endif @@ -95,12 +89,13 @@ #include <rtl/byteseq.h> #endif +// #include<glib.h> - - -#include<glib.h> +#include <stdio.h> //============================================================================== + +/* void ONotificationThread::run() { mLoop= NULL; @@ -109,180 +104,45 @@ void ONotificationThread::run() g_main_loop_run(mLoop); } ; -// ------------------------------------------------------------------------------- - -rtl::OUString GconfBackend::getCurrentModuleDirectory() // URL including terminating slash -{ - rtl::OUString aFileURL; - if ( !osl::Module::getUrlFromAddress((void*)&getCurrentModuleDirectory,aFileURL) ) - { - OSL_TRACE(false, "Cannot locate current module - using executable instead"); - - OSL_VERIFY(osl_Process_E_None == osl_getExecutableFile(&aFileURL.pData)); - } - - OSL_ENSURE(0 < aFileURL.lastIndexOf('/'), "Cannot find directory for module URL"); - - return aFileURL.copy(0, aFileURL.lastIndexOf('/') + 1); -} -// --------------------------------------------------------------------------------------- -void parseGconfString(const rtl::OUString& sKeyString, - rtl::OUString& sComponentName, - KeyMappingInfo& aKeyInfo) -{ - sal_Int32 nNextToken =0; - sal_Int32 nLength = sKeyString.getLength(); - - do - { - sComponentName = sKeyString.getToken(0, '/',nNextToken); - if((nNextToken ==-1)||(sComponentName.getLength()==0)) - { - throw backend::BackendSetupException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Malformed Gconf String specified")), - NULL, uno::Any()) ; - } - rtl::OUString sOOName = sKeyString.getToken(0, ':',nNextToken); - if((nNextToken ==-1)||(sOOName.getLength()==0)) - { - throw backend::BackendSetupException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Malformed Gconf String specified")), - NULL, uno::Any()) ; - - } - - rtl::OUString sOOType = sKeyString.getToken(0, ':',nNextToken); - if((nNextToken ==-1)||(sOOName.getLength()==0)) - { - throw backend::BackendSetupException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Malformed Gconf String specified")), - NULL, uno::Any()) ; - - } - rtl::OUString sGconfName = sKeyString.getToken(0, ':',nNextToken); - if((nNextToken ==-1)||(sGconfName.getLength()==0)) - { - throw backend::BackendSetupException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Malformed Gconf String specified")), - NULL, uno::Any()) ; - } - sal_Bool bProtected = sal_False; - rtl::OUString sProtected = sKeyString.getToken(0, ' ',nNextToken); - if ( sProtected.equalsIgnoreAsciiCaseAscii("true") || - sProtected.equalsAscii("1") || - sProtected.equalsIgnoreAsciiCaseAscii("yes")) - { - bProtected = sal_True ; - } - else if ( sProtected.equalsIgnoreAsciiCaseAscii("false") || - sProtected.equalsAscii("0") || - sProtected.equalsIgnoreAsciiCaseAscii("no")) - { - bProtected = sal_False ; - } - rtl::OUString sSep =rtl::OUString::createFromAscii("/"); - aKeyInfo.mOOName = sComponentName+sSep+sOOName; - aKeyInfo.mOOType = sOOType; - aKeyInfo.mGconfName = sGconfName; - aKeyInfo.mbProtected = bProtected; - - } - while (nNextToken >= 0 && nNextToken < nLength ) ; -} +*/ //------------------------------------------------------------------------------ + GconfBackend* GconfBackend::mInstance= 0; -GconfBackend* GconfBackend::createGconfInstance - (const uno::Reference<uno::XComponentContext>& xContext) +GconfBackend* GconfBackend::createInstance(const uno::Reference<uno::XComponentContext>& xContext) { if(mInstance == 0) { mInstance = new GconfBackend (xContext); } + return mInstance; } + //------------------------------------------------------------------------------ -GconfBackend::GconfBackend( - const uno::Reference<uno::XComponentContext>& xContext) + +GconfBackend::GconfBackend(const uno::Reference<uno::XComponentContext>& xContext) throw (backend::BackendAccessException) - : BackendBase(mMutex), - mFactory(xContext->getServiceManager(),uno::UNO_QUERY_THROW), - mNotificationThread(NULL) + : BackendBase(mMutex), m_xContext(xContext) +// , mNotificationThread(NULL) { - initializeMappingTable(); } + //------------------------------------------------------------------------------ GconfBackend::~GconfBackend(void) { - delete (mNotificationThread); +// delete (mNotificationThread); GconfBackend::mClient = NULL; } //------------------------------------------------------------------------------ -void checkIOErrorCode( - osl::File::RC aErrorCode, - rtl::OUString& aFileUrl) -{ - switch (aErrorCode) - { - case osl::File::E_None: // got it - { - - } - break; - default: - { - rtl::OUStringBuffer sMsg; - sMsg.appendAscii("GconfBackend: Cannot Read Key Mapping Table from INI/RC file:"); - sMsg.append(aFileUrl); - throw backend::BackendSetupException(sMsg.makeStringAndClear(), - NULL, uno::Any()); - } - } -} -//------------------------------------------------------------------------------ - -void GconfBackend::initializeMappingTable() -{ - rtl::OUString aFileUrl = getCurrentModuleDirectory() + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SYSTEMBE_INIFILE)); - - osl::File aMappingFile(aFileUrl) ; - osl::File::RC errorCode = aMappingFile.open(OpenFlag_Read) ; - checkIOErrorCode(errorCode,aFileUrl); - while(1) - { - rtl::ByteSequence aByteSequence; - sal_Bool bEof = false; - aMappingFile.isEndOfFile(&bEof); - if(bEof) - break; - - errorCode = aMappingFile.readLine(aByteSequence); - checkIOErrorCode(errorCode,aFileUrl); - - rtl::OUString sKeyString ( reinterpret_cast<char*> - (aByteSequence.getArray()), - aByteSequence.getLength(), - RTL_TEXTENCODING_ASCII_US); - rtl::OUString sComponentName; - KeyMappingInfo aKeyInfo; - parseGconfString(sKeyString,sComponentName,aKeyInfo); - mKeyMap.insert(KeyMappingTable::value_type(sComponentName, aKeyInfo)); - } -} -//------------------------------------------------------------------------------ GConfClient* GconfBackend::mClient= 0; @@ -322,13 +182,12 @@ GConfClient* GconfBackend::getGconfClient() //------------------------------------------------------------------------------ uno::Reference<backend::XLayer> SAL_CALL GconfBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& aTimestamp) + const rtl::OUString& aComponent, const rtl::OUString& aTimestamp) throw (backend::BackendAccessException, lang::IllegalArgumentException) { - - //All newly created layers have timestamp 0, timestamps are updated - //when notifications are recieved from gconf and stored in mTSMap + // timestamps need to be updated when notifications are recieved from gconf TimeValue aTimeValue = {0,0}; + osl_getSystemTime(&aTimeValue); oslDateTime aLayerTS; rtl::OUString aTimeStamp; @@ -336,33 +195,29 @@ uno::Reference<backend::XLayer> SAL_CALL GconfBackend::getLayer( if (osl_getDateTimeFromTimeValue(&aTimeValue, &aLayerTS)) { sal_Char asciiStamp [20] ; - sprintf(asciiStamp, "%04d%02d%02d%02d%02d%02dZ", + snprintf(asciiStamp, sizeof(asciiStamp), "%04d%02d%02d%02d%02d%02dZ", aLayerTS.Year, aLayerTS.Month, aLayerTS.Day, aLayerTS.Hours, aLayerTS.Minutes, aLayerTS.Seconds) ; aTimeStamp = rtl::OUString::createFromAscii(asciiStamp) ; } - //Need to pass mTSMap so GConfLayer can support XTimeStamp needed to - //work with binary cache feature - return new GconfLayer(aComponent, mKeyMap, aTimeStamp, mTSMap,mFactory); + + return new GconfLayer(aComponent, aTimeStamp, m_xContext); } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ uno::Reference<backend::XUpdatableLayer> SAL_CALL GconfBackend::getUpdatableLayer(const rtl::OUString& aComponent) throw (backend::BackendAccessException,lang::NoSupportException, lang::IllegalArgumentException) { - throw lang::NoSupportException( - rtl::OUString::createFromAscii( - "GconfBackend: No Update Operation allowed, Read Only access"), + throw lang::NoSupportException( rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("GconfBackend: No Update Operation allowed, Read Only access") ), *this) ; - - return NULL; - } + //------------------------------------------------------------------------------ + static void keyChangedCallback(GConfClient* aClient, guint aID, @@ -377,9 +232,12 @@ keyChangedCallback(GConfClient* aClient, aGconfBe->notifyListeners(aGconfKey); } + //------------------------------------------------------------------------------ + void GconfBackend::notifyListeners(const rtl::OUString& aGconfKey) { +/* //look up associated component from Map using GconfKey KeyMappingTable::iterator aIter; rtl::OUString aComponent; @@ -435,6 +293,7 @@ void GconfBackend::notifyListeners(const rtl::OUString& aGconfKey) cur->second->componentDataChanged(aEvent); } +*/ } @@ -444,6 +303,7 @@ void SAL_CALL GconfBackend::addChangesListener( const rtl::OUString& aComponent) throw (::com::sun::star::uno::RuntimeException) { +/* osl::MutexGuard aGuard(mMutex); GConfClient* aClient = getGconfClient(); @@ -498,7 +358,9 @@ void SAL_CALL GconfBackend::addChangesListener( } } +*/ +/* if (mNotificationThread == NULL) { @@ -513,7 +375,7 @@ void SAL_CALL GconfBackend::addChangesListener( mNotificationThread->create(); } } - +*/ //Store listener in list mListenerList.insert(ListenerList::value_type(aComponent, xListener)); @@ -525,6 +387,7 @@ void SAL_CALL GconfBackend::removeChangesListener( const rtl::OUString& aComponent) throw (::com::sun::star::uno::RuntimeException) { +/* osl::MutexGuard aGuard(mMutex); GConfClient* aClient = GconfBackend::getGconfClient(); ListenerList::iterator aIter; @@ -541,7 +404,7 @@ void SAL_CALL GconfBackend::removeChangesListener( BFRange aRange = mKeyMap.equal_range(aComponent); while (aRange.first != aRange.second) - { + { KMTIter cur = aRange.first++; sal_Int32 nIndex = cur->second.mGconfName.lastIndexOf('/'); @@ -559,40 +422,61 @@ void SAL_CALL GconfBackend::removeChangesListener( } } } +*/ } + //------------------------------------------------------------------------------ -rtl::OUString SAL_CALL GconfBackend::getGconfBackendName(void) { - return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.GconfBackend") ; +rtl::OUString SAL_CALL GconfBackend::getBackendName(void) { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.GconfBackend") ); } + //------------------------------------------------------------------------------ rtl::OUString SAL_CALL GconfBackend::getImplementationName(void) throw (uno::RuntimeException) { - return getGconfBackendName() ; + return getBackendName() ; } + //------------------------------------------------------------------------------ -uno::Sequence<rtl::OUString> SAL_CALL GconfBackend::getGconfBackendServiceNames(void) +uno::Sequence<rtl::OUString> SAL_CALL GconfBackend::getBackendServiceNames(void) { uno::Sequence<rtl::OUString> aServices(2) ; - aServices[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.GconfBackend")) ; - aServices[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; + aServices[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.GconfBackend")) ; + aServices[1] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; return aServices ; } + +//------------------------------------------------------------------------------ + +uno::Sequence<rtl::OUString> SAL_CALL GconfBackend::getSupportedComponents(void) +{ + uno::Sequence<rtl::OUString> aSupportedComponentsList(2) ; + aSupportedComponentsList[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Inet")) ; + aSupportedComponentsList[1] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common")) ; + + return aSupportedComponentsList ; +} + //------------------------------------------------------------------------------ -sal_Bool SAL_CALL GconfBackend::supportsService( - const rtl::OUString& aServiceName) +sal_Bool SAL_CALL GconfBackend::supportsService(const rtl::OUString& aServiceName) throw (uno::RuntimeException) { - uno::Sequence< rtl::OUString > const svc = getGconfBackendServiceNames(); + uno::Sequence< rtl::OUString > const svc = getBackendServiceNames(); for(sal_Int32 i = 0; i < svc.getLength(); ++i ) if(svc[i] == aServiceName) return true; + return false; } @@ -602,7 +486,7 @@ uno::Sequence<rtl::OUString> SAL_CALL GconfBackend::getSupportedServiceNames(void) throw (uno::RuntimeException) { - return getGconfBackendServiceNames() ; + return getBackendServiceNames() ; } // --------------------------------------------------------------------------------------- diff --git a/shell/source/backends/gconfbe/gconfbackend.hxx b/shell/source/backends/gconfbe/gconfbackend.hxx index 497aa262d3f2..63ce901bf243 100644 --- a/shell/source/backends/gconfbe/gconfbackend.hxx +++ b/shell/source/backends/gconfbe/gconfbackend.hxx @@ -2,9 +2,9 @@ * * $RCSfile: gconfbackend.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: rt $ $Date: 2004-03-30 15:05:16 $ + * last change: $Author: rt $ $Date: 2004-09-17 13:00:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,9 +76,9 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #endif // _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif // _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +//#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +//#include <com/sun/star/lang/XMultiServiceFactory.hpp> +//#endif // _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #ifndef _COM_SUN_STAR_CONFIGURATION_INVALIDBOOTSTRAPFILEEXCEPTION_HPP_ #include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> @@ -92,25 +92,17 @@ #include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp> #endif -#ifndef _COM_SUN_STAR_UCB_XSIMPLEFILEACCESS_HPP_ -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> -#endif - #ifndef _CPPUHELPER_COMPBASE3_HXX_ #include <cppuhelper/compbase3.hxx> #endif // _CPPUHELPER_COMPBASE3_HXX_ -#ifndef _OSL_FILE_HXX_ -#include <osl/file.hxx> -#endif - #ifndef INCLUDED_MAP #include <map> #define INCLUDED_MAP #endif -#ifndef _VOS_THREAD_HXX_ -#include <vos/thread.hxx> -#endif +//#ifndef _VOS_THREAD_HXX_ +//#include <vos/thread.hxx> +//#endif #include <gconf/gconf-client.h> @@ -118,36 +110,12 @@ namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace ucb = css::ucb; namespace backend = css::configuration::backend ; -#define SYSTEMBE_INIFILE SAL_CONFIGFILE("systembe") - -/** Structure containing the mapping between OOffice and Gconf keys. - AlOO specifies whether the key is protected, if key is protected it - can not be over riden in subsequent higher layers - */ -struct keyMapping -{ - - keyMapping(){}; - - rtl::OUString mOOName; - rtl::OUString mOOType; - rtl::OUString mGconfName; - sal_Bool mbProtected; - -}; - -typedef keyMapping KeyMappingInfo; -typedef std::multimap<rtl::OUString, KeyMappingInfo> KeyMappingTable; - -/*Time Stamp mapping table used to store timestamps of updated components - when a notification is recieved. It is needed as you cannot access gconf key - timestamps via the Gconf api */ -typedef std::multimap<rtl::OUString, rtl::OUString> TSMappingTable; //------------------------------------------------------------------------------ + +/* class ONotificationThread: public vos::OThread { @@ -171,12 +139,12 @@ private: GMainLoop* mLoop; }; - +*/ //------------------------------------------------------------------------------ typedef cppu::WeakComponentImplHelper3<backend::XSingleLayerStratum, backend::XBackendChangesNotifier, - lang::XServiceInfo> BackendBase ; + lang::XServiceInfo> BackendBase ; /** Implements the SingleLayerStratum service for gconf access. @@ -184,73 +152,67 @@ typedef cppu::WeakComponentImplHelper3<backend::XSingleLayerStratum, class GconfBackend : public BackendBase { public : - static GconfBackend* createGconfInstance( - const uno::Reference<uno::XComponentContext>& xContext); - - /** Destructor */ - ~GconfBackend(void) ; + static GconfBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); // XServiceInfo - virtual rtl::OUString SAL_CALL - getImplementationName( ) - throw (uno::RuntimeException) ; + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (uno::RuntimeException) ; - virtual sal_Bool SAL_CALL - supportsService( const rtl::OUString& aServiceName ) - throw (uno::RuntimeException) ; + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& aServiceName ) + throw (uno::RuntimeException) ; - virtual uno::Sequence<rtl::OUString> SAL_CALL - getSupportedServiceNames( ) - throw (uno::RuntimeException) ; + virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames( ) + throw (uno::RuntimeException) ; /** Provides the implementation name. @return implementation name */ - static rtl::OUString SAL_CALL getGconfBackendName(void) ; + static rtl::OUString SAL_CALL getBackendName(void) ; + /** Provides the supported services names @return service names */ - static uno::Sequence<rtl::OUString> SAL_CALL getGconfBackendServiceNames(void) ; + static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ; + /** - Provide the current module directory + Provides the supported component nodes - @return current module directory + @return supported component nodes */ - static rtl::OUString getCurrentModuleDirectory(); + static uno::Sequence<rtl::OUString> SAL_CALL getSupportedComponents(void) ; /* returns a GconfClient */ static GConfClient* getGconfClient(); //XSingleLayerStratum virtual uno::Reference<backend::XLayer> SAL_CALL - getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp ) - throw (backend::BackendAccessException, - lang::IllegalArgumentException) ; + getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp ) + throw (backend::BackendAccessException, lang::IllegalArgumentException) ; virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL - getUpdatableLayer( const rtl::OUString& aLayerId ) - throw (backend::BackendAccessException, - lang::NoSupportException, - lang::IllegalArgumentException) ; + getUpdatableLayer( const rtl::OUString& aLayerId ) + throw (backend::BackendAccessException, lang::NoSupportException, + lang::IllegalArgumentException) ; // XBackendChangesNotifier virtual void SAL_CALL addChangesListener( const uno::Reference<backend::XBackendChangesListener>& xListener, const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException); + throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeChangesListener( const uno::Reference<backend::XBackendChangesListener>& xListener, const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException); + throw (::com::sun::star::uno::RuntimeException); //Notify all listener of component change void notifyListeners(const rtl::OUString& aGconfKey); + protected: /** Service constructor from a service factory. @@ -259,6 +221,10 @@ class GconfBackend : public BackendBase { */ GconfBackend(const uno::Reference<uno::XComponentContext>& xContext) throw (backend::BackendAccessException); + + /** Destructor */ + ~GconfBackend(void) ; + private: typedef uno::Reference<backend::XBackendChangesListener> ListenerRef; @@ -267,16 +233,13 @@ class GconfBackend : public BackendBase { /** Build Gconf/OO mapping table */ void initializeMappingTable (); - uno::Reference<lang::XMultiServiceFactory> mFactory; + + /** The component context */ + uno::Reference<uno::XComponentContext> m_xContext; /** Mutex for reOOurces protection */ osl::Mutex mMutex ; - KeyMappingTable mKeyMap; - - /** List of component TimeStamps */ - TSMappingTable mTSMap; - static GconfBackend* mInstance; /** List of listener */ @@ -285,9 +248,7 @@ class GconfBackend : public BackendBase { /**Connection to Gconf */ static GConfClient* mClient; - ONotificationThread* mNotificationThread; - - +// ONotificationThread* mNotificationThread; } ; |