diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-09-17 12:01:14 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-09-17 12:01:14 +0000 |
commit | 92d98551629683fcb0806ddb5d63240b7b473b49 (patch) | |
tree | 94626b9b51a6ef6a4e1036329470120367663ac5 /shell | |
parent | 8ed7a244d5076566b63b03609cdad41ce15f0277 (diff) |
INTEGRATION: CWS syssettings02 (1.2.50); FILE MERGED
2004/09/03 07:13:32 obr 1.2.50.2: #i20364#,#i20369# removed debug output
2004/09/03 06:16:04 obr 1.2.50.1: #i20364#,#i20369# gconf platform configuration backend now buildable
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/backends/gconfbe/gconflayer.cxx | 258 |
1 files changed, 154 insertions, 104 deletions
diff --git a/shell/source/backends/gconfbe/gconflayer.cxx b/shell/source/backends/gconfbe/gconflayer.cxx index deaae54b8ab4..6684435e17bd 100644 --- a/shell/source/backends/gconfbe/gconflayer.cxx +++ b/shell/source/backends/gconfbe/gconflayer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: gconflayer.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: rt $ $Date: 2004-03-30 15:05:29 $ + * last change: $Author: rt $ $Date: 2004-09-17 13:01:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,80 +78,94 @@ #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ #include <com/sun/star/uno/Sequence.hxx> #endif + +#include <stdio.h> + //============================================================================== GconfLayer::GconfLayer( - const rtl::OUString& sComponent, - const KeyMappingTable& aKeyMap, - const rtl::OUString& sTimestamp, - const TSMappingTable& aTSMap, - const uno::Reference<lang::XMultiServiceFactory>& xFactory) - : mComponent(sComponent), mKeyMap(aKeyMap), - mTimestamp(sTimestamp), mTSMap(aTSMap), - mFactory(xFactory) + const rtl::OUString& aComponent, + const rtl::OUString& aTimestamp, + const uno::Reference<uno::XComponentContext>& xContext) + : m_aComponent(aComponent), m_aTimestamp(aTimestamp) { + //Create instance of LayerContentDescriber Service + rtl::OUString const k_sLayerDescriberService(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.backend.LayerDescriber")); + typedef uno::Reference<backend::XLayerContentDescriber> LayerDescriber; + uno::Reference< lang::XMultiComponentFactory > xServiceManager = xContext->getServiceManager(); + if( xServiceManager.is() ) + { + m_xLayerContentDescriber = LayerDescriber::query( + xServiceManager->createInstanceWithContext(k_sLayerDescriberService, xContext)); + } + else + { + OSL_TRACE("Could not retrieve ServiceManager"); + } } + //------------------------------------------------------------------------------ -void GconfLayer::convertGconfValue( - const GConfValue* aValue, - uno::Any* aOOValue, - const rtl::OUString& aOOType) + +/* +uno::Any GconfLayer::convertGconfValue(const GConfValue* aValue, const rtl::OUString& aOOType) { + uno::Any aRetVal; + sal_Bool bCorrectType = sal_True; switch (aValue->type) { case GCONF_VALUE_STRING: { - if(aOOType != rtl::OUString::createFromAscii("string")) + if(aOOType != rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("string"))) { bCorrectType = sal_False; } else { - rtl::OUString aVal( - rtl::OUString::createFromAscii(gconf_value_get_string(aValue))); - *aOOValue <<= aVal; + rtl::OString aVal(gconf_value_get_string(aValue)); + aRetVal <<= OStringToOUString(aVal, RTL_TEXTENCODING_UTF-8); } break; } case GCONF_VALUE_INT: { - if(aOOType != rtl::OUString::createFromAscii("int") && - aOOType != rtl::OUString::createFromAscii("integer")) + if( aOOType != rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("int") ) && + aOOType != rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("integer") ) ) { bCorrectType = sal_False; } else { sal_Int32 aVal = gconf_value_get_int(aValue); - *aOOValue <<= aVal; + aRetVal <<= aVal; } break; } case GCONF_VALUE_FLOAT: { - if(aOOType != rtl::OUString::createFromAscii("double") ) + if(aOOType != rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) ) { bCorrectType = sal_False; } else { double aVal = gconf_value_get_float(aValue); - *aOOValue <<= aVal; + aRetVal <<= aVal; } break; } case GCONF_VALUE_BOOL: { - if(aOOType != rtl::OUString::createFromAscii("boolean")) + if(aOOType != rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("boolean") ) ) { bCorrectType = sal_False; } else { sal_Bool aVal = gconf_value_get_bool(aValue); - *aOOValue <<= aVal; + aRetVal <<= aVal; } break; } @@ -167,112 +181,148 @@ void GconfLayer::convertGconfValue( default: break; } + if (!bCorrectType) - throw backend::MalformedDataException( - rtl::OUString::createFromAscii("Gconfbe:GconfLayer: GconfType does not match StarOffice Type"), - *this, uno::Any()); + throw backend::MalformedDataException( rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Gconfbe:GconfLayer: GconfType does not match StarOffice Type") + ), *this, uno::Any()); } -//------------------------------------------------------------------------------ - -void SAL_CALL GconfLayer::readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - std::vector<backend::PropertyInfo> aPropList; - //Look up in map all keys asociated with requested OOffice Component - //and retrieve values from Gconf - typedef KeyMappingTable::const_iterator BFIter; - typedef std::pair<BFIter, BFIter> BFRange; +*/ +//------------------------------------------------------------------------------ - BFRange aRange = mKeyMap.equal_range(mComponent); - GError* aError = NULL; - GConfClient* aClient = NULL; - if (aRange.first != mKeyMap.end()) - { - aClient = GconfBackend::getGconfClient(); - } +void SAL_CALL GconfLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) + throw ( backend::MalformedDataException, lang::NullPointerException, + lang::WrappedTargetException, uno::RuntimeException) +{ - while (aRange.first != aRange.second) + if( m_xLayerContentDescriber.is() ) { - BFIter cur = aRange.first++; - - //Need to read data using Gconf api here + uno::Sequence<backend::PropertyInfo> aPropInfoList(5); + sal_Int32 nProperties = 0; - GConfValue* aGconfValue = NULL; - rtl::OString sKeyValue = rtl::OUStringToOString(cur->second.mGconfName, RTL_TEXTENCODING_ASCII_US); - aGconfValue = gconf_client_get( aClient, sKeyValue.getStr(),&aError); + GError* aError; + GConfClient* aClient = GconfBackend::getGconfClient(); + GConfValue* aGconfValue; - if (aError == NULL) + if( m_aComponent.equalsAscii("org.openoffice.Inet" ) ) { + aError = NULL; + aGconfValue = gconf_client_get(aClient, "/system/proxy/mode" , &aError); - //Fill in the ProperyInfo Struct - backend::PropertyInfo aPropInfo; + if( aError == NULL ) + { + rtl::OString aMode(gconf_value_get_string(aGconfValue)); - aPropInfo.Name = cur->second.mOOName; - aPropInfo.Type = cur->second.mOOType; - aPropInfo.Protected = cur->second.mbProtected; - convertGconfValue(aGconfValue, &aPropInfo.Value,aPropInfo.Type ); + if( aMode.equals("manual") ) + { + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetProxyType") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "int" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( (sal_Int32) 1 ); + aError = NULL; + aGconfValue = gconf_client_get(aClient, "/system/http_proxy/host" , &aError); - aPropList.push_back(aPropInfo); - gconf_value_free(aGconfValue); - } - else - { - rtl::OString aErrorStr(aError->message); - //Do nothing for now - real impl can decide whether to throw exception - OSL_TRACE("GconfLayer cannot read data for Gconfkey:%s with message:%s", - sKeyValue.getStr(), aError->message); - } + if( aError == NULL ) { + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPProxyName") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "string" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( OStringToOUString( + rtl::OString( gconf_value_get_string(aGconfValue) ), + RTL_TEXTENCODING_UTF8 ) ); + } - } - if ( !aPropList.empty()) - { + aError = NULL; + aGconfValue = gconf_client_get(aClient, "/system/http_proxy/port" , &aError); - uno::Sequence<backend::PropertyInfo> aPropInfoList(aPropList.size()); - for( sal_Int32 i = 0; i < aPropList.size(); i++) - { - aPropInfoList[i] = aPropList[i]; - } + if( aError == NULL ) { + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPProxyPort") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "int" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( + (sal_Int32) gconf_value_get_int(aGconfValue) ); + } - //Create instance of LayerContentDescriber Service - rtl::OUString const k_sLayerDescriberService (RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.configuration.backend.LayerDescriber")); + aError = NULL; + aGconfValue = gconf_client_get(aClient, "/system/proxy/ftp_host" , &aError); - typedef uno::Reference<backend::XLayerContentDescriber> LayerDescriber; - LayerDescriber xLayerDescriber = LayerDescriber::query( - mFactory->createInstance(k_sLayerDescriberService)); + if( aError == NULL ) { + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetFTPProxyName") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "string" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( OStringToOUString( + rtl::OString( gconf_value_get_string(aGconfValue) ), + RTL_TEXTENCODING_UTF8 ) ); + } - if (xLayerDescriber.is()) - { - xLayerDescriber->describeLayer(xHandler, aPropInfoList); + aError = NULL; + aGconfValue = gconf_client_get(aClient, "/system/proxy/ftp_port" , &aError); + + if( aError == NULL ) { + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetFTPProxyPort") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "int" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( + (sal_Int32) gconf_value_get_int(aGconfValue) ); + } + } + else if( aMode.equals("none") ) + { + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetProxyType") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "int" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( (sal_Int32) 0 ); + } + } } - else + else if( m_aComponent.equalsAscii("org.openoffice.Office.Common" ) ) { - OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); + aError = NULL; + aGconfValue = gconf_client_get(aClient, "/desktop/gnome/url-handlers/mailto/command" , &aError); + + if( aError == NULL ) { + sal_Int32 nIndex = 0; + aPropInfoList[nProperties].Name = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer/Program") ); + aPropInfoList[nProperties].Type = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "string" ) ); + aPropInfoList[nProperties].Protected = sal_False; + aPropInfoList[nProperties++].Value = uno::makeAny( OStringToOUString( + rtl::OString( gconf_value_get_string(aGconfValue) ).getToken(0, ' ', nIndex), + RTL_TEXTENCODING_UTF8 ) ); + } } - } -} -//------------------------------------------------------------------------------ + aPropInfoList.realloc(nProperties); - rtl::OUString SAL_CALL GconfLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - TSMappingTable::const_iterator aTSIter; - aTSIter = mTSMap.find(mComponent); - if (aTSIter != mTSMap.end()) + m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); + } + else { - mTimestamp= aTSIter->second; + OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); } - - return mTimestamp; } + //------------------------------------------------------------------------------ + +rtl::OUString SAL_CALL GconfLayer::getTimestamp(void) + throw (uno::RuntimeException) +{ + return m_aTimestamp; +} |