diff options
Diffstat (limited to 'shell/source/backends')
68 files changed, 3189 insertions, 6179 deletions
diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx new file mode 100644 index 000000000000..21371755b479 --- /dev/null +++ b/shell/source/backends/desktopbe/desktopbackend.cxx @@ -0,0 +1,290 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_shell.hxx" +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XPropertyChangeListener.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/XPropertySetInfo.hpp" +#include "com/sun/star/beans/XVetoableChangeListener.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "osl/diagnose.h" +#include "rtl/string.h" +#include "rtl/textenc.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/current_context.hxx" +#include "uno/lbnames.h" + +namespace { + +namespace css = com::sun::star; + +rtl::OUString SAL_CALL getDefaultImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.backend.DesktopBackend")); +} + +css::uno::Sequence< rtl::OUString > SAL_CALL getDefaultSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.DesktopBackend")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} + +class Default: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::beans::XPropertySet >, + private boost::noncopyable +{ +public: + Default() {} + +private: + virtual ~Default() {} + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return getDefaultImplementationName(); } + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return getDefaultSupportedServiceNames(); } + + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } + + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} +}; + +void Default::setPropertyValue(rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); +} + +css::uno::Any Default::getPropertyValue(rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) + { + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); +} + +css::uno::Reference< css::uno::XInterface > createBackend( + css::uno::Reference< css::uno::XComponentContext > const & context, + rtl::OUString const & name) +{ + try { + return css::uno::Reference< css::lang::XMultiComponentFactory >( + context->getServiceManager(), css::uno::UNO_SET_THROW)-> + createInstanceWithContext(name, context); + } catch (css::uno::RuntimeException &) { + // Assuming these exceptions are real errors: + throw; + } catch (css::uno::Exception & e) { + // Assuming these exceptions indicate that the service is not installed: + OSL_TRACE( + "createInstance(%s) failed with %s", + rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8).getStr(), + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); + return css::uno::Reference< css::uno::XInterface >(); + } +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( + css::uno::Reference< css::uno::XComponentContext > const & context) +{ + rtl::OUString desktop; + css::uno::Reference< css::uno::XCurrentContext > current( + css::uno::getCurrentContext()); + if (current.is()) { + current->getValueByName( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>= + desktop; + } + // Fall back to the default if the specific backend is not available: + css::uno::Reference< css::uno::XInterface > backend; + if (desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("GNOME"))) { + backend = createBackend( + context, + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.GconfBackend"))); + } else if (desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE"))) { + backend = createBackend( + context, + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.KDEBackend"))); + } else if (desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE4"))) { + backend = createBackend( + context, + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.KDE4Backend"))); + } + return backend.is() + ? backend : static_cast< cppu::OWeakObject * >(new Default); +} + +static cppu::ImplementationEntry const services[] = { + { &createInstance, &getDefaultImplementationName, + &getDefaultSupportedServiceNames, &cppu::createSingleComponentFactory, 0, + 0 }, + { 0, 0, 0, 0, 0, 0 } +}; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) +{ + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); +} + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey) +{ + return component_writeInfoHelper(pServiceManager, pRegistryKey, services); +} diff --git a/shell/source/backends/desktopbe/desktopbe.xml b/shell/source/backends/desktopbe/desktopbe.xml deleted file mode 100644 index 0230028157dd..000000000000 --- a/shell/source/backends/desktopbe/desktopbe.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name>desktopbe</module-name> - <component-description> - <author> Jan Holesovsky </author> - <name>com.sun.star.comp.configuration.backend.DesktopBackend</name> - <description> The shared gconf/KDE backend; will load GconfBackend or - KDEBackend depending on the desktop environment.</description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>c++</language> - <status value="beta"/> - <supported-service>com.sun.star.comp.configuration.backend.DesktopBackend</supported-service> - <supported-service>com.sun.star.comp.configuration.backend.PlatformBackend</supported-service> - <service-dependency>...</service-dependency> - <type>com.sun.star.configuration.backend.XBackendChangesListener</type> - <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> - <type>com.sun.star.configuration.backend.XLayerHandler</type> - <type>com.sun.star.configuration.backend.XSingleLayerStratum</type> - <type>com.sun.star.lang.XMultiComponentFactory</type> - <type>com.sun.star.lang.XServiceInfo</type> - <type>com.sun.star.lang.XSingleComponentFactory</type> - <type>com.sun.star.lang.XTypeProvider</type> - <type>com.sun.star.uno.TypeClass</type> - <type>com.sun.star.uno.XAggregation</type> - <type>com.sun.star.uno.XComponentContext</type> - <type>com.sun.star.uno.XCurrentContext</type> - <type>com.sun.star.uno.XWeak</type> - <type>com.sun.star.registry.XRegistryKey</type> - </component-description> - <project-build-dependency>cppuhelper</project-build-dependency> - <project-build-dependency>cppu</project-build-dependency> - <project-build-dependency>sal</project-build-dependency> - <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency> - <runtime-module-dependency>cppu3</runtime-module-dependency> - <runtime-module-dependency>sal3</runtime-module-dependency> -</module-description> diff --git a/shell/source/backends/desktopbe/desktopbe1-ucd.txt b/shell/source/backends/desktopbe/desktopbe1-ucd.txt index c1df46010377..fd874a82ead5 100644 --- a/shell/source/backends/desktopbe/desktopbe1-ucd.txt +++ b/shell/source/backends/desktopbe/desktopbe1-ucd.txt @@ -2,8 +2,5 @@ ImplementationName=com.sun.star.comp.configuration.backend.DesktopBackend ComponentName=desktopbe1.uno.so LoaderName=com.sun.star.loader.SharedLibrary -[Data] -SupportedComponents=org.openoffice.VCL;org.openoffice.Inet;org.openoffice.Office.Common;org.openoffice.Office.Paths;org.openoffice.UserProfile;org.openoffice.Office.Recovery;org.openoffice.Setup [SupportedServices] com.sun.star.configuration.backend.DesktopBackend -com.sun.star.configuration.backend.PlatformBackend diff --git a/shell/source/backends/desktopbe/desktopbecdef.cxx b/shell/source/backends/desktopbe/desktopbecdef.cxx deleted file mode 100644 index ab292cf1e5bb..000000000000 --- a/shell/source/backends/desktopbe/desktopbecdef.cxx +++ /dev/null @@ -1,202 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XSCHEMASUPPLIER_HPP_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#endif -#include <com/sun/star/registry/XRegistryKey.hpp> - -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include <cppuhelper/implementationentry.hxx> -#endif -#include <com/sun/star/uno/XComponentContext.hpp> - -#include "uno/current_context.hxx" - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -//============================================================================== - -static uno::Reference<uno::XInterface> SAL_CALL createDesktopBackend(const uno::Reference<uno::XComponentContext>& xContext) -{ - try { - uno::Reference< uno::XCurrentContext > xCurrentContext(uno::getCurrentContext()); - - if (xCurrentContext.is()) - { - uno::Any aValue = xCurrentContext->getValueByName( - rtl::OUString::createFromAscii( "system.desktop-environment" ) ); - - rtl::OUString aDesktopEnvironment; - if ( aValue >>= aDesktopEnvironment ) - { - rtl::OUString aDesktopService; - if ( aDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) ) - aDesktopService = rtl::OUString::createFromAscii( "com.sun.star.configuration.backend.GconfBackend" ); - else if ( aDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde" ) ) - aDesktopService = rtl::OUString::createFromAscii( "com.sun.star.configuration.backend.KDEBackend" ); - else - return uno::Reference<uno::XInterface>(); - - uno::Reference< lang::XMultiComponentFactory > xServiceManager = xContext->getServiceManager(); - if( xServiceManager.is() ) - { - return uno::Reference< backend::XSingleLayerStratum >::query( - xServiceManager->createInstanceWithContext( aDesktopService, xContext) ); - } - } - } - } catch (uno::RuntimeException e) { - } - - return uno::Reference<uno::XInterface>(); -} - -static rtl::OUString SAL_CALL getBackendName(void) { - return rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.DesktopBackend") ); -} - -static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) -{ - uno::Sequence<rtl::OUString> aServices(2) ; - aServices[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.DesktopBackend")) ; - aServices[1] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; - - return aServices ; -} - -static uno::Sequence<rtl::OUString> SAL_CALL getSupportedComponents(void) -{ - const sal_Int32 nComponents = 7; - - uno::Sequence<rtl::OUString> aSupportedComponentsList(nComponents) ; - - aSupportedComponentsList[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.VCL")) ; - aSupportedComponentsList[1] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Inet")) ; - aSupportedComponentsList[2] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common")) ; - aSupportedComponentsList[3] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Paths")) ; - - aSupportedComponentsList[4] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.UserProfile")) ; - aSupportedComponentsList[5] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Recovery")) ; - aSupportedComponentsList[6] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")) ; - - return aSupportedComponentsList ; -} -//============================================================================== - -static const cppu::ImplementationEntry kImplementations_entries[] = -{ - { - createDesktopBackend, - getBackendName, - getBackendServiceNames, - cppu::createSingleComponentFactory, - NULL, - 0 - }, - { NULL, NULL, NULL, NULL, NULL, 0 } -} ; -//------------------------------------------------------------------------------ - -extern "C" void SAL_CALL component_getImplementationEnvironment( - const sal_Char **aEnvTypeName, - uno_Environment ** /* aEnvironment */) -{ - *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; -} - -//------------------------------------------------------------------------------ - -extern "C" sal_Bool SAL_CALL component_writeInfo(void * /* pServiceManager */, - void *pRegistryKey) -{ - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - // Register supported components - uno::Reference<XRegistryKey> xComponentKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/DATA/SupportedComponents") ) - ); - - xComponentKey->setAsciiListValue( getSupportedComponents() ); - - return sal_True; - } - - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - - return sal_False; -} - -//------------------------------------------------------------------------------ - -extern "C" void *component_getFactory(const sal_Char *aImplementationName, - void *aServiceManager, - void *aRegistryKey) -{ - return cppu::component_getFactoryHelper( - aImplementationName, - aServiceManager, - aRegistryKey, - kImplementations_entries) ; -} -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/desktopbe/exports.map b/shell/source/backends/desktopbe/exports.map deleted file mode 100644 index ba501f9ae076..000000000000 --- a/shell/source/backends/desktopbe/exports.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - - local: - *; -}; diff --git a/shell/source/backends/desktopbe/makefile.mk b/shell/source/backends/desktopbe/makefile.mk index dd0afd88fe13..29260821d551 100644 --- a/shell/source/backends/desktopbe/makefile.mk +++ b/shell/source/backends/desktopbe/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,49 +23,31 @@ # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. # -#************************************************************************* -PRJ=..$/..$/.. - -PRJNAME=shell -TARGET=desktopbe - -LIBTARGET=NO -ENABLE_EXCEPTIONS=TRUE +#***********************************************************************/ -COMP1TYPELIST=$(TARGET) -COMPRDB=$(SOLARBINDIR)$/types.rdb -UNOUCROUT=$(OUT)$/inc$/$(TARGET) -INCPRE=$(UNOUCROUT) +PRJ = ../../.. +PRJNAME = shell +TARGET = desktopbe -# --- Settings --- +ENABLE_EXCEPTIONS = TRUE +VISIBILITY_HIDDEN = TRUE -.INCLUDE : settings.mk +.INCLUDE: settings.mk -UNIXTEXT=$(MISC)/$(TARGET)1-ucd.txt - -# no "lib" prefix DLLPRE = -# --- Files --- - -SLOFILES=\ - $(SLO)$/desktopbecdef.obj - -SHL1NOCHECK=TRUE -SHL1TARGET=$(TARGET)1.uno -SHL1OBJS=$(SLOFILES) -SHL1DEF=$(MISC)$/$(SHL1TARGET).def +SLOFILES = $(SLO)/desktopbackend.obj -SHL1IMPLIB=i$(SHL1TARGET) -SHL1STDLIBS= \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SALLIB) - -SHL1VERSIONMAP=exports.map -SHL1DEF=$(MISC)$/$(SHL1TARGET).def -DEF1NAME=$(SHL1TARGET) +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLOFILES) +SHL1STDLIBS = \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) +SHL1TARGET = desktopbe1.uno +SHL1USE_EXPORTS = name +DEF1NAME = $(SHL1TARGET) -# --- Targets --- +UNIXTEXT = $(MISC)/desktopbe1-ucd.txt -.INCLUDE : target.mk +.INCLUDE: target.mk diff --git a/shell/source/backends/gconfbe/exports.map b/shell/source/backends/gconfbe/exports.map deleted file mode 100644 index ba501f9ae076..000000000000 --- a/shell/source/backends/gconfbe/exports.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - - local: - *; -}; diff --git a/shell/source/backends/gconfbe/gconflayer.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx index 67fbb3ea2750..99a5b362c161 100644 --- a/shell/source/backends/gconfbe/gconflayer.cxx +++ b/shell/source/backends/gconfbe/gconfaccess.cxx @@ -1,78 +1,102 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -// MARKER(update_precomp.py): autogen include statement, do not remove +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + #include "precompiled_shell.hxx" -#include "gconflayer.hxx" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <rtl/strbuf.hxx> -#include <rtl/ustrbuf.hxx> -#include <osl/security.hxx> -#include <osl/file.hxx> -#include <osl/thread.h> -#include <com/sun/star/uno/Sequence.hxx> +#include "sal/config.h" #include <string.h> -using namespace rtl; +#include "com/sun/star/uno/RuntimeException.hpp" +#include "osl/file.hxx" +#include "osl/security.hxx" +#include "osl/thread.h" +#include "rtl/strbuf.hxx" +#include "rtl/ustrbuf.hxx" -//============================================================================== +#include "gconfaccess.hxx" -GconfLayer::GconfLayer( const uno::Reference<uno::XComponentContext>& xContext, - const ConfigurationValue pConfigurationValuesList[], - const sal_Int32 nConfigurationValues, - const char * pPreloadValuesList[] ) - :m_pConfigurationValuesList( pConfigurationValuesList ) - ,m_nConfigurationValues( nConfigurationValues ) - ,m_pPreloadValuesList( pPreloadValuesList ) -{ - //Create instance of LayerContentDescriber Service - rtl::OUString const k_sLayerDescriberService( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.configuration.backend.LayerDescriber" ) ); +#define GCONF_PROXY_MODE_KEY "/system/proxy/mode" +#define GCONF_AUTO_SAVE_KEY "/apps/openoffice/auto_save" - 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 +namespace gconfaccess { + +namespace { + +namespace css = com::sun::star ; +namespace uno = css::uno ; +using namespace rtl; + +GConfClient* getGconfClient() +{ + static GConfClient* mClient= 0; + if (mClient == NULL) { - OSL_TRACE( "Could not retrieve ServiceManager" ); + /* initialize glib object type library */ + g_type_init(); + + GError* aError = NULL; + if (!gconf_init(0, NULL, &aError)) + { + rtl::OUStringBuffer msg; + msg.appendAscii("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " ); + msg.appendAscii(aError->message); + + g_error_free(aError); + aError = NULL; + throw uno::RuntimeException(msg.makeStringAndClear(),NULL); + } + + mClient = gconf_client_get_default(); + if (!mClient) + { + throw uno::RuntimeException(rtl::OUString::createFromAscii + ("GconfBackend:GconfLayer: Cannot Initialize Gconf connection"),NULL); + } + + static const char * const PreloadValuesList[] = + { + "/desktop/gnome/interface", + "/system/proxy", + "/system/http_proxy/host", + "/desktop/gnome/url-handlers/mailto", +#ifdef ENABLE_LOCKDOWN + "/apps/openoffice", + "/desktop/gnome/lockdown", + "/apps/openoffice/lockdown", +#endif // ENABLE_LOCKDOWN + NULL + }; + int i = 0; + while( PreloadValuesList[i] != NULL ) + gconf_client_preload( mClient, PreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL ); } -} -//------------------------------------------------------------------------------ + return mClient; +} static OUString xdg_user_dir_lookup (const char *type) { @@ -373,13 +397,12 @@ uno::Any translateToOOo( const ConfigurationValue aValue, GConfValue *aGconfValu //------------------------------------------------------------------------------ -sal_Bool SAL_CALL isDependencySatisfied( const ConfigurationValue aValue ) +sal_Bool SAL_CALL isDependencySatisfied( GConfClient* aClient, const ConfigurationValue aValue ) { switch( aValue.nDependsOn ) { case SETTING_PROXY_MODE: { - GConfClient* aClient = GconfBackend::getGconfClient(); GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_PROXY_MODE_KEY, NULL ); if ( aGconfValue != NULL ) @@ -446,116 +469,381 @@ sal_Bool SAL_CALL isDependencySatisfied( const ConfigurationValue aValue ) return sal_False; } -//------------------------------------------------------------------------------ +} -void SAL_CALL GconfLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler ) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException ) +ConfigurationValue const ConfigurationValues[] = { - if( ! m_xLayerContentDescriber.is() ) { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } + SETTING_ENABLE_ACCESSIBILITY, + "/desktop/gnome/interface/accessibility", + "EnableATToolSupport", + sal_True, + SETTINGS_LAST + }, - uno::Sequence<backend::PropertyInfo> aPropInfoList( m_nConfigurationValues ); - sal_Int32 nProperties = 0; + { + SETTING_PROXY_MODE, + GCONF_PROXY_MODE_KEY, + "ooInetProxyType", + sal_True, + SETTINGS_LAST + }, - GConfClient* aClient = GconfBackend::getGconfClient(); - GConfValue* aGconfValue; - int i = 0; + { + SETTING_PROXY_HTTP_HOST, + "/system/http_proxy/host", + "ooInetHTTPProxyName", + sal_False, + SETTING_PROXY_MODE + }, - while( m_pPreloadValuesList[i] != NULL ) - gconf_client_preload( aClient, m_pPreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL ); + { + SETTING_PROXY_HTTP_PORT, + "/system/http_proxy/port", + "ooInetHTTPProxyPort", + sal_False, + SETTING_PROXY_MODE + }, + + { + SETTING_PROXY_HTTPS_HOST, + "/system/proxy/secure_host", + "ooInetHTTPSProxyName", + sal_False, + SETTING_PROXY_MODE + }, - for( i = 0; i < m_nConfigurationValues; i++ ) { - if( ( m_pConfigurationValuesList[i].nDependsOn != SETTINGS_LAST ) && !isDependencySatisfied( m_pConfigurationValuesList[i] ) ) - continue; + SETTING_PROXY_HTTPS_PORT, + "/system/proxy/secure_port", + "ooInetHTTPSProxyPort", + sal_False, + SETTING_PROXY_MODE + }, - aGconfValue = gconf_client_get( aClient, m_pConfigurationValuesList[i].GconfItem, NULL ); + { + SETTING_PROXY_FTP_HOST, + "/system/proxy/ftp_host", + "ooInetFTPProxyName", + sal_False, + SETTING_PROXY_MODE + }, - if( aGconfValue != NULL ) - { - aPropInfoList[nProperties].Name = rtl::OUString::createFromAscii( m_pConfigurationValuesList[i].OOoConfItem ); - aPropInfoList[nProperties].Type = rtl::OUString::createFromAscii( m_pConfigurationValuesList[i].OOoConfValueType ); - aPropInfoList[nProperties].Protected = m_pConfigurationValuesList[i].bLocked; + { + SETTING_PROXY_FTP_PORT, + "/system/proxy/ftp_port", + "ooInetFTPProxyPort", + sal_False, + SETTING_PROXY_MODE + }, - if( m_pConfigurationValuesList[i].bNeedsTranslation ) - aPropInfoList[nProperties].Value = translateToOOo( m_pConfigurationValuesList[i], aGconfValue ); - else - aPropInfoList[nProperties].Value = makeAnyOfGconfValue( aGconfValue ); + { + SETTING_NO_PROXY_FOR, + "/system/http_proxy/ignore_hosts", + "ooInetNoProxy", + sal_True, + SETTING_PROXY_MODE + }, - gconf_value_free( aGconfValue ); + { + SETTING_MAILER_PROGRAM, + "/desktop/gnome/url-handlers/mailto/command", + "ExternalMailer", + sal_True, + SETTINGS_LAST + }, + { + SETTING_SOURCEVIEWFONT_NAME, + "/desktop/gnome/interface/monospace_font_name", + "SourceViewFontName", + sal_True, + SETTINGS_LAST + }, + { + SETTING_SOURCEVIEWFONT_HEIGHT, + "/desktop/gnome/interface/monospace_font_name", + "SourceViewFontHeight", + sal_True, + SETTINGS_LAST + }, - nProperties++; - } - } + { + SETTING_WORK_DIRECTORY, + "/desktop/gnome/url-handlers/mailto/command", // dummy + "WorkPathVariable", + sal_True, + SETTING_WORK_DIRECTORY, // so that the existence of the dir can be checked + }, - if( nProperties > 0 ) +#ifdef ENABLE_LOCKDOWN { - aPropInfoList.realloc( nProperties ); - m_xLayerContentDescriber->describeLayer( xHandler, aPropInfoList ); - } -} + SETTING_WRITER_DEFAULT_DOC_FORMAT, + "/apps/openoffice/writer_default_document_format", + "TextDocumentSetupFactoryDefaultFilter", + sal_False, + SETTINGS_LAST + }, -//------------------------------------------------------------------------------ + { + SETTING_IMPRESS_DEFAULT_DOC_FORMAT, + "/apps/openoffice/impress_default_document_format", + "PresentationDocumentSetupFactoryDefaultFilter", + sal_False, + SETTINGS_LAST + }, -rtl::OUString SAL_CALL GconfLayer::getTimestamp( void ) - throw (uno::RuntimeException) -{ - // Return a hash of the values as timestamp to avoid regenerating - // the binary cache on each office launch. - rtl::OStringBuffer aTimeStamp; + { + SETTING_CALC_DEFAULT_DOC_FORMAT, + "/apps/openoffice/calc_default_document_format", + "SpreadsheetDocumentSetupFactoryDefaultFilter", + sal_False, + SETTINGS_LAST + }, - // Make sure the timestamp differs from beta - sal_Int32 nHashCode = 0; + { + SETTING_AUTO_SAVE, + GCONF_AUTO_SAVE_KEY, + "AutoSaveEnabled", + sal_False, + SETTINGS_LAST + }, - GConfClient* aClient = GconfBackend::getGconfClient(); - GConfValue* aGconfValue; - int i = 0; + { + SETTING_AUTO_SAVE_INTERVAL, + "/apps/openoffice/auto_save_interval", + "AutoSaveTimeIntervall", + sal_False, + SETTING_AUTO_SAVE + }, + + { + SETTING_USER_GIVENNAME, + "/desktop/gnome/url-handlers/mailto/command", // dummy + "givenname", + sal_True, + SETTING_USER_GIVENNAME + }, - while( m_pPreloadValuesList[i] != NULL ) - gconf_client_preload( aClient, m_pPreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL ); + { + SETTING_USER_SURNAME, + "/desktop/gnome/url-handlers/mailto/command", // dummy + "sn", + sal_True, + SETTING_USER_SURNAME + }, + + { + SETTING_DISABLE_PRINTING, + "/desktop/gnome/lockdown/disable_printing", + "DisablePrinting", + sal_True, + SETTINGS_LAST + }, + + { + SETTING_USE_SYSTEM_FILE_DIALOG, + "/apps/openoffice/use_system_file_dialog", + "UseSystemFileDialog", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_PRINTING_MODIFIES_DOCUMENT, + "/apps/openoffice/printing_modifies_doc", + "PrintingModifiesDocument", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_SHOW_ICONS_IN_MENUS, + "/apps/openoffice/show_menu_icons", + "ShowIconsInMenues", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_SHOW_INACTIVE_MENUITEMS, + "/apps/openoffice/show_menu_inactive_items", + "DontHideDisabledEntry", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_SHOW_FONT_PREVIEW, + "/apps/openoffice/show_font_preview", + "ShowFontBoxWYSIWYG", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_SHOW_FONT_HISTORY, + "/apps/openoffice/show_font_history", + "FontViewHistory", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_ENABLE_OPENGL, + "/apps/openoffice/use_opengl", + "OpenGL", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_OPTIMIZE_OPENGL, + "/apps/openoffice/optimize_opengl", + "OpenGL_Faster", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_USE_SYSTEM_FONT, + "/apps/openoffice/use_system_font", + "AccessibilityIsSystemFont", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_USE_FONT_ANTI_ALIASING, + "/apps/openoffice/use_font_anti_aliasing", + "FontAntiAliasingEnabled", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_FONT_ANTI_ALIASING_MIN_PIXEL, + "/apps/openoffice/font_anti_aliasing_min_pixel", + "FontAntiAliasingMinPixelHeight", + sal_True, + SETTINGS_LAST + }, + + { + SETTING_WARN_CREATE_PDF, + "/apps/openoffice/lockdown/warn_info_create_pdf", + "WarnCreatePDF", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_WARN_PRINT_DOC, + "/apps/openoffice/lockdown/warn_info_printing", + "WarnPrintDoc", + sal_False, + SETTINGS_LAST + }, - for( i = 0; i < m_nConfigurationValues; i++ ) { - aGconfValue = gconf_client_get( aClient, m_pConfigurationValuesList[i].GconfItem, NULL ); + SETTING_WARN_SAVEORSEND_DOC, + "/apps/openoffice/lockdown/warn_info_saving", + "WarnSaveOrSendDoc", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_WARN_SIGN_DOC, + "/apps/openoffice/lockdown/warn_info_signing", + "WarnSignDoc", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_REMOVE_PERSONAL_INFO, + "/apps/openoffice/lockdown/remove_personal_info_on_save", + "Scripting/RemovePersonalInfoOnSaving", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_RECOMMEND_PASSWORD, + "/apps/openoffice/lockdown/recommend_password_on_save", + "RecommendPasswordProtection", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_UNDO_STEPS, + "/apps/openoffice/undo_steps", + "UndoSteps", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_SYMBOL_SET, + "/apps/openoffice/icon_size", + "SymbolSet", + sal_True, + SETTINGS_LAST + }, + + { + SETTING_MACRO_SECURITY_LEVEL, + "/apps/openoffice/lockdown/macro_security_level", + "MacroSecurityLevel", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_CREATE_BACKUP, + "/apps/openoffice/create_backup", + "CreateBackup", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_WARN_ALIEN_FORMAT, + "/apps/openoffice/warn_alien_format", + "WarnAlienFormat", + sal_False, + SETTINGS_LAST + }, + +#endif // ENABLE_LOCKDOWN +}; + +std::size_t const nConfigurationValues = + sizeof ConfigurationValues / sizeof ConfigurationValues[0]; + +css::beans::Optional< css::uno::Any > getValue(ConfigurationValue const & data) +{ + GConfClient* aClient = getGconfClient(); + GConfValue* aGconfValue; + if( ( data.nDependsOn == SETTINGS_LAST ) || isDependencySatisfied( aClient, data ) ) + { + aGconfValue = gconf_client_get( aClient, data.GconfItem, NULL ); if( aGconfValue != NULL ) { - switch( aGconfValue->type ) - { - case GCONF_VALUE_BOOL: - nHashCode ^= (sal_Int32) !gconf_value_get_bool( aGconfValue ); - break; - - case GCONF_VALUE_INT: - nHashCode ^= (sal_Int32) gconf_value_get_int( aGconfValue ); - break; - - case GCONF_VALUE_STRING: - nHashCode ^= (sal_Int32) g_str_hash( gconf_value_get_string( aGconfValue ) ); - break; - - case GCONF_VALUE_LIST: - if( GCONF_VALUE_STRING == gconf_value_get_list_type( aGconfValue ) ) - { - GSList *list = gconf_value_get_list( aGconfValue ); - for(; list; list = g_slist_next(list)) - nHashCode ^= (sal_Int32) g_str_hash( gconf_value_get_string((GConfValue *) list->data) ); - break; - } - - default: - fprintf( stderr, "getTimestamp: Type not handled.\n" ); - break; - } - nHashCode = (nHashCode << 5) - nHashCode; + css::uno::Any value; + if( data.bNeedsTranslation ) + value = translateToOOo( data, aGconfValue ); + else + value = makeAnyOfGconfValue( aGconfValue ); + gconf_value_free( aGconfValue ); + + return css::beans::Optional< css::uno::Any >(true, value); } } + return css::beans::Optional< css::uno::Any >(); +} - return rtl::OUString::valueOf( nHashCode ); } diff --git a/shell/source/backends/gconfbe/gconfaccess.hxx b/shell/source/backends/gconfbe/gconfaccess.hxx new file mode 100644 index 000000000000..7fdd82ff05e7 --- /dev/null +++ b/shell/source/backends/gconfbe/gconfaccess.hxx @@ -0,0 +1,119 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_GCONFBE_GCONFACCESS_HXX +#define INCLUDED_SHELL_SOURCE_BACKENDS_GCONFBE_GCONFACCESS_HXX + +#include "sal/config.h" + +#include <cstddef> + +#include "com/sun/star/beans/Optional.hpp" +#include "gconf/gconf-client.h" +#include "sal/types.h" + +namespace com { namespace sun { namespace star { namespace uno { + class Any; +} } } } + +namespace gconfaccess { + +enum ConfigurationSetting +{ + SETTING_PROXY_MODE, + SETTING_PROXY_HTTP_HOST, + SETTING_PROXY_HTTP_PORT, + SETTING_PROXY_HTTPS_HOST, + SETTING_PROXY_HTTPS_PORT, + SETTING_PROXY_FTP_HOST, + SETTING_PROXY_FTP_PORT, + SETTING_NO_PROXY_FOR, + SETTING_ENABLE_ACCESSIBILITY, + SETTING_MAILER_PROGRAM, + SETTING_WORK_DIRECTORY, + SETTING_SOURCEVIEWFONT_NAME, + SETTING_SOURCEVIEWFONT_HEIGHT, + SETTING_USER_GIVENNAME, + SETTING_USER_SURNAME, + +#ifdef ENABLE_LOCKDOWN + + SETTING_DISABLE_PRINTING, + SETTING_USE_SYSTEM_FILE_DIALOG, + SETTING_PRINTING_MODIFIES_DOCUMENT, + SETTING_SHOW_ICONS_IN_MENUS, + SETTING_SHOW_INACTIVE_MENUITEMS, + SETTING_SHOW_FONT_PREVIEW, + SETTING_SHOW_FONT_HISTORY, + SETTING_ENABLE_OPENGL, + SETTING_OPTIMIZE_OPENGL, + SETTING_SAVE_DOCUMENT_WINDOWS, + SETTING_SAVE_DOCUMENT_VIEW_INFO, + SETTING_USE_SYSTEM_FONT, + SETTING_USE_FONT_ANTI_ALIASING, + SETTING_FONT_ANTI_ALIASING_MIN_PIXEL, + SETTING_WARN_CREATE_PDF, + SETTING_WARN_PRINT_DOC, + SETTING_WARN_SAVEORSEND_DOC, + SETTING_WARN_SIGN_DOC, + SETTING_REMOVE_PERSONAL_INFO, + SETTING_RECOMMEND_PASSWORD, + SETTING_UNDO_STEPS, + SETTING_SYMBOL_SET, + SETTING_MACRO_SECURITY_LEVEL, + SETTING_CREATE_BACKUP, + SETTING_WARN_ALIEN_FORMAT, + SETTING_AUTO_SAVE, + SETTING_AUTO_SAVE_INTERVAL, + SETTING_WRITER_DEFAULT_DOC_FORMAT, + SETTING_IMPRESS_DEFAULT_DOC_FORMAT, + SETTING_CALC_DEFAULT_DOC_FORMAT, + +#endif // ENABLE_LOCKDOWN + + SETTINGS_LAST +}; + +struct ConfigurationValue +{ + const ConfigurationSetting nSettingId; + const gchar *GconfItem; + const char *OOoConfItem; + const sal_Bool bNeedsTranslation; + const ConfigurationSetting nDependsOn; +}; + +extern ConfigurationValue const ConfigurationValues[]; + +extern std::size_t const nConfigurationValues; + +com::sun::star::beans::Optional< com::sun::star::uno::Any > getValue( + ConfigurationValue const & data); + +} + +#endif diff --git a/shell/source/backends/gconfbe/gconfbackend.cxx b/shell/source/backends/gconfbe/gconfbackend.cxx index 15d2ee654e8e..122d1cad02b3 100644 --- a/shell/source/backends/gconfbe/gconfbackend.cxx +++ b/shell/source/backends/gconfbe/gconfbackend.cxx @@ -1,1007 +1,239 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_shell.hxx" - -#include "gconfbackend.hxx" -#include "gconflayer.hxx" -#include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp> - -#ifndef INCLUDED_VECTOR -#include <vector> -#define INCLUDED_VECTOR -#endif -#include <osl/process.h> -#include <osl/time.h> -#include <rtl/ustrbuf.hxx> -#include <rtl/byteseq.h> - -#include <stdio.h> - -#ifdef ENABLE_LOCKDOWN -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue SetupConfigurationValuesList[] = -{ - { - SETTING_WRITER_DEFAULT_DOC_FORMAT, - "/apps/openoffice/writer_default_document_format", - "org.openoffice.Setup/Office/Factories/com.sun.star.text.TextDocument/ooSetupFactoryDefaultFilter", - "string", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_IMPRESS_DEFAULT_DOC_FORMAT, - "/apps/openoffice/impress_default_document_format", - "org.openoffice.Setup/Office/Factories/com.sun.star.presentation.PresentationDocument/ooSetupFactoryDefaultFilter", - "string", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_CALC_DEFAULT_DOC_FORMAT, - "/apps/openoffice/calc_default_document_format", - "org.openoffice.Setup/Office/Factories/com.sun.star.sheet.SpreadsheetDocument/ooSetupFactoryDefaultFilter", - "string", - sal_False, - sal_False, - SETTINGS_LAST - }, -}; -#endif // ENABLE_LOCKDOWN - -#ifdef ENABLE_LOCKDOWN -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue RecoveryConfigurationValuesList[] = -{ - { - SETTING_AUTO_SAVE, - GCONF_AUTO_SAVE_KEY, - "org.openoffice.Office.Recovery/AutoSave/Enabled", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_AUTO_SAVE_INTERVAL, - "/apps/openoffice/auto_save_interval", - "org.openoffice.Office.Recovery/AutoSave/TimeIntervall", - "int", - sal_False, - sal_False, - SETTING_AUTO_SAVE - }, -}; -#endif // ENABLE_LOCKDOWN - -/* - * This should be in a different backend actually, but this has to wait .. - */ - -#ifdef ENABLE_LOCKDOWN -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue UserProfileConfigurationValuesList[] = -{ - { - SETTING_USER_GIVENNAME, - "/desktop/gnome/url-handlers/mailto/command", // dummy, needed for getTimestamp - "org.openoffice.UserProfile/Data/givenname", - "string", - sal_False, - sal_True, - SETTING_USER_GIVENNAME - }, - - { - SETTING_USER_SURNAME, - "/desktop/gnome/url-handlers/mailto/command", // dummy, needed for getTimestamp - "org.openoffice.UserProfile/Data/sn", - "string", - sal_False, - sal_True, - SETTING_USER_SURNAME - }, -}; -#endif // ENABLE_LOCKDOWN - -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue VCLConfigurationValuesList[] = -{ - { - SETTING_ENABLE_ACCESSIBILITY, - "/desktop/gnome/interface/accessibility", - "org.openoffice.VCL/Settings/Accessibility/EnableATToolSupport", - "string", - sal_False, - sal_True, - SETTINGS_LAST - }, - -#ifdef ENABLE_LOCKDOWN - - { - SETTING_DISABLE_PRINTING, - "/desktop/gnome/lockdown/disable_printing", - "org.openoffice.VCL/Settings/DesktopManagement/DisablePrinting", - "string", - sal_False, - sal_True, - SETTINGS_LAST - }, - -#endif // ENABLE_LOCKDOWN - -}; - -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue InetConfigurationValuesList[] = -{ - { - SETTING_PROXY_MODE, - GCONF_PROXY_MODE_KEY, - "org.openoffice.Inet/Settings/ooInetProxyType", - "int", - sal_False, - sal_True, - SETTINGS_LAST - }, - - { - SETTING_PROXY_HTTP_HOST, - "/system/http_proxy/host", - "org.openoffice.Inet/Settings/ooInetHTTPProxyName", - "string", - sal_False, - sal_False, - SETTING_PROXY_MODE - }, - - { - SETTING_PROXY_HTTP_PORT, - "/system/http_proxy/port", - "org.openoffice.Inet/Settings/ooInetHTTPProxyPort", - "int", - sal_False, - sal_False, - SETTING_PROXY_MODE - }, - - { - SETTING_PROXY_HTTPS_HOST, - "/system/proxy/secure_host", - "org.openoffice.Inet/Settings/ooInetHTTPSProxyName", - "string", - sal_False, - sal_False, - SETTING_PROXY_MODE - }, - - { - SETTING_PROXY_HTTPS_PORT, - "/system/proxy/secure_port", - "org.openoffice.Inet/Settings/ooInetHTTPSProxyPort", - "int", - sal_False, - sal_False, - SETTING_PROXY_MODE - }, - - { - SETTING_PROXY_FTP_HOST, - "/system/proxy/ftp_host", - "org.openoffice.Inet/Settings/ooInetFTPProxyName", - "string", - sal_False, - sal_False, - SETTING_PROXY_MODE - }, - - { - SETTING_PROXY_FTP_PORT, - "/system/proxy/ftp_port", - "org.openoffice.Inet/Settings/ooInetFTPProxyPort", - "int", - sal_False, - sal_False, - SETTING_PROXY_MODE - }, - - { - SETTING_NO_PROXY_FOR, - "/system/http_proxy/ignore_hosts", - "org.openoffice.Inet/Settings/ooInetNoProxy", - "string", - sal_False, - sal_True, - SETTING_PROXY_MODE - }, -}; - -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue CommonConfigurationValuesList[] = -{ - { - SETTING_MAILER_PROGRAM, - "/desktop/gnome/url-handlers/mailto/command", - "org.openoffice.Office.Common/ExternalMailer/Program", - "string", - sal_False, - sal_True, - SETTINGS_LAST - }, - { - SETTING_SOURCEVIEWFONT_NAME, - "/desktop/gnome/interface/monospace_font_name", - "org.openoffice.Office.Common/Font/SourceViewFont/FontName", - "string", - sal_False, - sal_True, - SETTINGS_LAST - }, - { - SETTING_SOURCEVIEWFONT_HEIGHT, - "/desktop/gnome/interface/monospace_font_name", - "org.openoffice.Office.Common/Font/SourceViewFont/FontHeight", - "short", - sal_False, - sal_True, - SETTINGS_LAST - }, - -#ifdef ENABLE_LOCKDOWN - - { - SETTING_USE_SYSTEM_FILE_DIALOG, - "/apps/openoffice/use_system_file_dialog", - "org.openoffice.Office.Common/Misc/UseSystemFileDialog", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_DISABLE_UI_CUSTOMIZATION, - "/apps/openoffice/lockdown/disable_ui_customization", - "org.openoffice.Office.Common/Misc/DisableUICustomization", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_PRINTING_MODIFIES_DOCUMENT, - "/apps/openoffice/printing_modifies_doc", - "org.openoffice.Office.Common/Print/PrintingModifiesDocument", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_SHOW_ICONS_IN_MENUS, - "/apps/openoffice/show_menu_icons", - "org.openoffice.Office.Common/View/Menu/ShowIconsInMenues", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_SHOW_INACTIVE_MENUITEMS, - "/apps/openoffice/show_menu_inactive_items", - "org.openoffice.Office.Common/View/Menu/DontHideDisabledEntry", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_SHOW_FONT_PREVIEW, - "/apps/openoffice/show_font_preview", - "org.openoffice.Office.Common/Font/View/ShowFontBoxWYSIWYG", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_SHOW_FONT_HISTORY, - "/apps/openoffice/show_font_history", - "org.openoffice.Office.Common/Font/View/History", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_ENABLE_OPENGL, - "/apps/openoffice/use_opengl", - "org.openoffice.Office.Common/_3D_Engine/OpenGL", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_OPTIMIZE_OPENGL, - "/apps/openoffice/optimize_opengl", - "org.openoffice.Office.Common/_3D_Engine/OpenGL_Faster", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_USE_SYSTEM_FONT, - "/apps/openoffice/use_system_font", - "org.openoffice.Office.Common/Accessibility/IsSystemFont", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_USE_FONT_ANTI_ALIASING, - "/apps/openoffice/use_font_anti_aliasing", - "org.openoffice.Office.Common/View/FontAntiAliasing/Enabled", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_FONT_ANTI_ALIASING_MIN_PIXEL, - "/apps/openoffice/font_anti_aliasing_min_pixel", - "org.openoffice.Office.Common/View/FontAntiAliasing/MinPixelHeight", - "short", - sal_False, - sal_True, - SETTINGS_LAST - }, - - { - SETTING_WARN_CREATE_PDF, - "/apps/openoffice/lockdown/warn_info_create_pdf", - "org.openoffice.Office.Common/Security/Scripting/WarnCreatePDF", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_WARN_PRINT_DOC, - "/apps/openoffice/lockdown/warn_info_printing", - "org.openoffice.Office.Common/Security/Scripting/WarnPrintDoc", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_WARN_SAVEORSEND_DOC, - "/apps/openoffice/lockdown/warn_info_saving", - "org.openoffice.Office.Common/Security/Scripting/WarnSaveOrSendDoc", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_WARN_SIGN_DOC, - "/apps/openoffice/lockdown/warn_info_signing", - "org.openoffice.Office.Common/Security/Scripting/WarnSignDoc", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_REMOVE_PERSONAL_INFO, - "/apps/openoffice/lockdown/remove_personal_info_on_save", - "org.openoffice.Office.Common/Security/Scripting/RemovePersonalInfoOnSaving", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_RECOMMEND_PASSWORD, - "/apps/openoffice/lockdown/recommend_password_on_save", - "org.openoffice.Office.Common/Security/Scripting/RecommendPasswordProtection", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_UNDO_STEPS, - "/apps/openoffice/undo_steps", - "org.openoffice.Office.Common/Undo/Steps", - "int", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_SYMBOL_SET, - "/apps/openoffice/icon_size", - "org.openoffice.Office.Common/Misc/SymbolSet", - "short", - sal_False, - sal_True, - SETTINGS_LAST - }, - - { - SETTING_MACRO_SECURITY_LEVEL, - "/apps/openoffice/lockdown/macro_security_level", - "org.openoffice.Office.Common/Security/Scripting/MacroSecurityLevel", - "int", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_CREATE_BACKUP, - "/apps/openoffice/create_backup", - "org.openoffice.Office.Common/Save/Document/CreateBackup", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - - { - SETTING_WARN_ALIEN_FORMAT, - "/apps/openoffice/warn_alien_format", - "org.openoffice.Office.Common/Save/Document/WarnAlienFormat", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, - -#endif // ENABLE_LOCKDOWN - -}; - -static const ConfigurationValue PathsConfigurationValuesList[] = -{ - { - SETTING_WORK_DIRECTORY, - "/desktop/gnome/url-handlers/mailto/command", // dummy, needed for getTimestamp - "org.openoffice.Office.Paths/Variables/Work", - "string", - sal_False, - sal_True, - SETTING_WORK_DIRECTORY, // so that the existence of the dir can be checked - }, -}; - -#ifdef ENABLE_LOCKDOWN -static const char * SetupPreloadValuesList[] = -{ - "/apps/openoffice", - NULL -}; -#endif // ENABLE_LOCKDOWN - -#ifdef ENABLE_LOCKDOWN -static const char * RecoveryPreloadValuesList[] = -{ - "/apps/openoffice", - NULL -}; -#endif // ENABLE_LOCKDOWN - -#ifdef ENABLE_LOCKDOWN -static const char * UserProfilePreloadValuesList[] = -{ - NULL -}; -#endif // ENABLE_LOCKDOWN - -static const char * VCLPreloadValuesList[] = -{ - "/desktop/gnome/interface", -#ifdef ENABLE_LOCKDOWN - "/desktop/gnome/lockdown", -#endif // ENABLE_LOCKDOWN - NULL -}; - -static const char * InetPreloadValuesList[] = -{ - "/system/proxy", - "/system/http_proxy/host", - NULL -}; - -static const char * CommonPreloadValuesList[] = -{ - "/desktop/gnome/url-handlers/mailto", -#ifdef ENABLE_LOCKDOWN - "/apps/openoffice/lockdown", - "/apps/openoffice", -#endif // ENABLE_LOCKDOWN - NULL -}; - -static const char * PathsPreloadValuesList[] = -{ - NULL -}; - -//============================================================================== - -/* -void ONotificationThread::run() -{ - mLoop= NULL; - //Need to start a GMain loop for notifications to work - mLoop=g_main_loop_new(g_main_context_default(),FALSE); - g_main_loop_run(mLoop); -} ; - -*/ - -//------------------------------------------------------------------------------ - -GconfBackend* GconfBackend::mInstance= 0; - -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) - throw (backend::BackendAccessException) - : BackendBase(mMutex), m_xContext(xContext) -// , mNotificationThread(NULL) - - -{ -} - -//------------------------------------------------------------------------------ - -GconfBackend::~GconfBackend(void) { - - -// delete (mNotificationThread); - GconfBackend::mClient = NULL; - +#include "sal/config.h" + +#include <cstddef> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XPropertyChangeListener.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/XPropertySetInfo.hpp" +#include "com/sun/star/beans/XVetoableChangeListener.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "rtl/string.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/current_context.hxx" +#include "uno/lbnames.h" + +#include "gconfaccess.hxx" +#include "orbit.h" + +namespace { + +namespace css = com::sun::star; + +rtl::OUString SAL_CALL getServiceImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.backend.GconfBackend")); } -//------------------------------------------------------------------------------ - -GConfClient* GconfBackend::mClient= 0; - - -GConfClient* GconfBackend::getGconfClient() -{ - - if (mClient == NULL) - { - /* initialize glib object type library */ - g_type_init(); - - GError* aError = NULL; - if (!gconf_init(0, NULL, &aError)) - { - rtl::OUStringBuffer msg; - msg.appendAscii("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " ); - msg.appendAscii(aError->message); - - g_error_free(aError); - aError = NULL; - throw uno::RuntimeException(msg.makeStringAndClear(),NULL); - } - - mClient = gconf_client_get_default(); - if (!mClient) - { - throw uno::RuntimeException(rtl::OUString::createFromAscii - ("GconfBackend:GconfLayer: Cannot Initialize Gconf connection"),NULL); - } - } - - return mClient; +css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.GconfBackend")); + return css::uno::Sequence< rtl::OUString >(&name, 1); } -//------------------------------------------------------------------------------ - -uno::Reference<backend::XLayer> SAL_CALL GconfBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException) -{ - uno::Reference<backend::XLayer> xLayer; - - if( aComponent.equalsAscii("org.openoffice.Office.Common" ) ) - { - xLayer = new GconfLayer( m_xContext, - CommonConfigurationValuesList, - G_N_ELEMENTS( CommonConfigurationValuesList ), - CommonPreloadValuesList ); - } - else if( aComponent.equalsAscii("org.openoffice.Inet" ) ) - { - xLayer = new GconfLayer( m_xContext, - InetConfigurationValuesList, - G_N_ELEMENTS( InetConfigurationValuesList ), - InetPreloadValuesList ); - } - else if( aComponent.equalsAscii("org.openoffice.VCL" ) ) - { - xLayer = new GconfLayer( m_xContext, - VCLConfigurationValuesList, - G_N_ELEMENTS( VCLConfigurationValuesList ), - VCLPreloadValuesList ); - } - else if( aComponent.equalsAscii("org.openoffice.Office.Paths" ) ) - { - xLayer = new GconfLayer( m_xContext, - PathsConfigurationValuesList, - G_N_ELEMENTS( PathsConfigurationValuesList ), - PathsPreloadValuesList ); - } +class Service: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::beans::XPropertySet >, + private boost::noncopyable +{ +public: + Service(); + +private: + virtual ~Service() {} + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return getServiceImplementationName(); } + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return getServiceSupportedServiceNames(); } + + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } + + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + bool enabled_; +}; -#ifdef ENABLE_LOCKDOWN - else if( aComponent.equalsAscii("org.openoffice.UserProfile" ) ) - { - xLayer = new GconfLayer( m_xContext, - UserProfileConfigurationValuesList, - G_N_ELEMENTS( UserProfileConfigurationValuesList ), - UserProfilePreloadValuesList ); - } - else if( aComponent.equalsAscii("org.openoffice.Office.Recovery" ) ) - { - xLayer = new GconfLayer( m_xContext, - RecoveryConfigurationValuesList, - G_N_ELEMENTS( RecoveryConfigurationValuesList ), - RecoveryPreloadValuesList ); - } - else if( aComponent.equalsAscii("org.openoffice.Setup" ) ) - { - xLayer = new GconfLayer( m_xContext, - SetupConfigurationValuesList, - G_N_ELEMENTS( SetupConfigurationValuesList ), - SetupPreloadValuesList ); +Service::Service(): enabled_(false) { + css::uno::Reference< css::uno::XCurrentContext > context( + css::uno::getCurrentContext()); + if (context.is()) { + rtl::OUString desktop; + context->getValueByName( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>= + desktop; + enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("GNOME")) && + ((orbit_major_version == 2 && orbit_minor_version >= 8) || + orbit_major_version > 2); + // ORBit-2 versions < 2.8 cause a deadlock with the gtk+ VCL plugin } -#endif // ENABLE_LOCKDOWN - - return xLayer; } -//------------------------------------------------------------------------------ - -uno::Reference<backend::XUpdatableLayer> SAL_CALL -GconfBackend::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) +void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - throw lang::NoSupportException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("GconfBackend: No Update Operation allowed, Read Only access") ), - *this) ; -} - -//------------------------------------------------------------------------------ - -// currently not used -#if 0 -static void -keyChangedCallback(GConfClient* aClient, - guint aID, - GConfEntry* aEntry, - gpointer aBackend) -{ - - OSL_TRACE("In KeyChangedCallback Function"); - rtl::OUString aGconfKey= rtl::OUString::createFromAscii(aEntry->key); - GconfBackend * aGconfBe = (GconfBackend*) aBackend; - - aGconfBe->notifyListeners(aGconfKey); - + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); } -//------------------------------------------------------------------------------ - -void GconfBackend::notifyListeners(const rtl::OUString& /*aGconfKey*/) +css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { -/* - //look up associated component from Map using GconfKey - KeyMappingTable::iterator aIter; - rtl::OUString aComponent; - for( aIter= mKeyMap.begin(); aIter != mKeyMap.end(); aIter++) - { - if (aIter->second.mGconfName == aGconfKey) + for (std::size_t i = 0; i < gconfaccess::nConfigurationValues; ++i) { + if (PropertyName.equalsAscii( + gconfaccess::ConfigurationValues[i].OOoConfItem)) { - aComponent = aIter->first; - break; + return css::uno::makeAny( + enabled_ + ? gconfaccess::getValue(gconfaccess::ConfigurationValues[i]) + : css::beans::Optional< css::uno::Any >()); } - - } - - - //Need to store updated layer TimeStamp as Gconf library - //has no access to TimeStamp via its api - TimeValue aTimeValue ={0,0} ; - osl_getSystemTime(&aTimeValue); - - oslDateTime aLayerTS; - rtl::OUString aTimeStamp; - - if (osl_getDateTimeFromTimeValue(&aTimeValue, &aLayerTS)) { - sal_Char asciiStamp [20] ; - - sprintf(asciiStamp, "%04d%02d%02d%02d%02d%02dZ", - aLayerTS.Year, aLayerTS.Month, aLayerTS.Day, - aLayerTS.Hours, aLayerTS.Minutes, aLayerTS.Seconds) ; - aTimeStamp = rtl::OUString::createFromAscii(asciiStamp) ; - } - - - TSMappingTable::iterator aTSIter; - aTSIter = mTSMap.find(aComponent); - if (aTSIter == mTSMap.end()) - { - mTSMap.insert(TSMappingTable::value_type(aComponent,aTimeStamp)); - } - else - { - aTSIter->second = aTimeStamp; - } - typedef ListenerList::iterator LLIter; - typedef std::pair<LLIter, LLIter> BFRange; - BFRange aRange = mListenerList.equal_range(aComponent); - while (aRange.first != aRange.second) - { - LLIter cur = aRange.first++; - backend::ComponentChangeEvent aEvent; - aEvent.Component = aComponent; - aEvent.Source = *this; - cur->second->componentDataChanged(aEvent); - - } -*/ + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); } -#endif -//------------------------------------------------------------------------------ -void SAL_CALL GconfBackend::addChangesListener( - const uno::Reference<backend::XBackendChangesListener>& xListener, - const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( + css::uno::Reference< css::uno::XComponentContext > const &) { -/* - osl::MutexGuard aGuard(mMutex); - - GConfClient* aClient = getGconfClient(); - - ListenerList::iterator aIter; - aIter = mListenerList.find(aComponent); - if (aIter == mListenerList.end()) - { - typedef KeyMappingTable::iterator KMTIter; - typedef std::pair<KMTIter, KMTIter> BFRange; - - BFRange aRange = mKeyMap.equal_range(aComponent); - - while (aRange.first != aRange.second) - { - KMTIter cur = aRange.first++; - - sal_Int32 nIndex = cur->second.mGconfName.lastIndexOf('/'); - rtl::OUString aDirectory = cur->second.mGconfName.copy(0, nIndex); - rtl::OString aDirectoryStr= rtl::OUStringToOString(aDirectory, RTL_TEXTENCODING_ASCII_US); - GError* aError = NULL; - gconf_client_add_dir(aClient, - aDirectoryStr.getStr(), - GCONF_CLIENT_PRELOAD_NONE, - &aError); - - if(aError != NULL) - { - OSL_TRACE("GconfBackend:: Cannot register listener for Component %s", - rtl::OUStringToOString(aComponent, RTL_TEXTENCODING_ASCII_US).getStr() ); - } - - rtl::OString aKey = rtl::OUStringToOString(cur->second.mGconfName, - RTL_TEXTENCODING_ASCII_US); - - GConfClientNotifyFunc aNotifyFunc = &keyChangedCallback; - sal_uInt32 aID = gconf_client_notify_add( - aClient, - aKey.getStr(), - aNotifyFunc, - this, - NULL, - &aError); - if(aError != NULL) - { - OSL_TRACE("GconfBackend:: Cannot register listener for Component %s", - rtl::OUStringToOString(aComponent, RTL_TEXTENCODING_ASCII_US).getStr() ); - } - - - - } - - } -*/ - -/* - if (mNotificationThread == NULL) - { - - mNotificationThread = new ONotificationThread(); - - if ( mNotificationThread == NULL) - { - OSL_ENSURE(false,"Could not start Notification Thread "); - } - else - { - mNotificationThread->create(); - } - } -*/ - //Store listener in list - mListenerList.insert(ListenerList::value_type(aComponent, xListener)); - - + return static_cast< cppu::OWeakObject * >(new Service); } -//------------------------------------------------------------------------------ -void SAL_CALL GconfBackend::removeChangesListener( - const uno::Reference<backend::XBackendChangesListener>& /*xListener*/, - const rtl::OUString& /*aComponent*/) - throw (::com::sun::star::uno::RuntimeException) -{ -/* - osl::MutexGuard aGuard(mMutex); - GConfClient* aClient = GconfBackend::getGconfClient(); - ListenerList::iterator aIter; - aIter = mListenerList.find(aComponent); - if (aIter == mListenerList.end()) - { - - OSL_TRACE("GconfBackend:: Cannot deregister listener for Component %s - Listner not registered", - rtl::OUStringToOString(aComponent, RTL_TEXTENCODING_ASCII_US).getStr() ); - - typedef KeyMappingTable::iterator KMTIter; - typedef std::pair<KMTIter, KMTIter> BFRange; - - BFRange aRange = mKeyMap.equal_range(aComponent); - - while (aRange.first != aRange.second) - { - KMTIter cur = aRange.first++; - - sal_Int32 nIndex = cur->second.mGconfName.lastIndexOf('/'); - rtl::OUString aDirectory = cur->second.mGconfName.copy(0, nIndex); - rtl::OString aDirectoryStr= rtl::OUStringToOString(aDirectory, RTL_TEXTENCODING_ASCII_US); - GError* aError = NULL; - gconf_client_remove_dir(aClient, - aDirectoryStr.getStr(), - &aError); - if(aError != NULL) - { - OSL_TRACE("GconfBackend:: Cannot deRegister listener for Component %s", - rtl::OUStringToOString(aComponent, RTL_TEXTENCODING_ASCII_US).getStr() ); - } - } - } -*/ -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL GconfBackend::getBackendName(void) { - return rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.GconfBackend") ); -} - -//------------------------------------------------------------------------------ +static cppu::ImplementationEntry const services[] = { + { &createInstance, &getServiceImplementationName, + &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0, + 0 }, + { 0, 0, 0, 0, 0, 0 } +}; -rtl::OUString SAL_CALL GconfBackend::getImplementationName(void) - throw (uno::RuntimeException) -{ - return getBackendName() ; } -//------------------------------------------------------------------------------ - -uno::Sequence<rtl::OUString> SAL_CALL GconfBackend::getBackendServiceNames(void) +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) { - uno::Sequence<rtl::OUString> aServices(1) ; - aServices[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.GconfBackend")) ; - - return aServices ; + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); } -//------------------------------------------------------------------------------ - -sal_Bool SAL_CALL GconfBackend::supportsService(const rtl::OUString& aServiceName) - throw (uno::RuntimeException) +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) { - uno::Sequence< rtl::OUString > const svc = getBackendServiceNames(); - - for(sal_Int32 i = 0; i < svc.getLength(); ++i ) - if(svc[i] == aServiceName) - return true; - - return false; + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -//------------------------------------------------------------------------------ - -uno::Sequence<rtl::OUString> -SAL_CALL GconfBackend::getSupportedServiceNames(void) - throw (uno::RuntimeException) +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey) { - return getBackendServiceNames() ; + return component_writeInfoHelper(pServiceManager, pRegistryKey, services); } - -// --------------------------------------------------------------------------------------- - - diff --git a/shell/source/backends/gconfbe/gconfbackend.hxx b/shell/source/backends/gconfbe/gconfbackend.hxx deleted file mode 100644 index 849f7097d2c3..000000000000 --- a/shell/source/backends/gconfbe/gconfbackend.hxx +++ /dev/null @@ -1,223 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef GCONFBACKEND_HXX_ -#define GCONFBACKEND_HXX_ - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XSCHEMASUPPLIER_HPP_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#endif -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <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_ -#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> -#include <com/sun/star/configuration/backend/CannotConnectException.hpp> -#include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp> -#include <cppuhelper/compbase3.hxx> - -#ifndef INCLUDED_MAP -#include <map> -#define INCLUDED_MAP -#endif -//#ifndef _VOS_THREAD_HXX_ -//#include <vos/thread.hxx> -//#endif - -#include <gconf/gconf-client.h> - - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - - -/** 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 -{ - - -public: - ONotificationThread() - {} - - ~ONotificationThread() - { - g_main_loop_quit(mLoop); - } - -private: - virtual void SAL_CALL onTerminated() - { - delete this; - } - - virtual void SAL_CALL run(); - GMainLoop* mLoop; -}; - -*/ - -//------------------------------------------------------------------------------ -typedef cppu::WeakComponentImplHelper3<backend::XSingleLayerStratum, - backend::XBackendChangesNotifier, - lang::XServiceInfo> BackendBase ; - -/** - Implements the SingleLayerStratum service for gconf access. - */ -class GconfBackend : public BackendBase { - public : - - static GconfBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); - - // XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName( ) - 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) ; - - /** - Provides the implementation name. - - @return implementation name - */ - static rtl::OUString SAL_CALL getBackendName(void) ; - - /** - Provides the supported services names - - @return service names - */ - static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(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) ; - - virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL - 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); - - - virtual void SAL_CALL removeChangesListener( - const uno::Reference<backend::XBackendChangesListener>& xListener, - const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException); -// currently not used -#if 0 - //Notify all listener of component change - void notifyListeners(const rtl::OUString& aGconfKey); -#endif - protected: - /** - Service constructor from a service factory. - - @param xContext component context - */ - GconfBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); - - /** Destructor */ - ~GconfBackend(void) ; - - private: - - typedef uno::Reference<backend::XBackendChangesListener> ListenerRef; - typedef std::multimap<rtl::OUString,ListenerRef> ListenerList; - - /** Build Gconf/OO mapping table */ - void initializeMappingTable (); - - - /** 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 */ - ListenerList mListenerList; - - /**Connection to Gconf */ - static GConfClient* mClient; - -// ONotificationThread* mNotificationThread; -} ; - - -#endif // CONFIGMGR_LOCALBE_LOCALSINGLESTRATUM_HXX_ diff --git a/shell/source/backends/gconfbe/gconfbe.xml b/shell/source/backends/gconfbe/gconfbe.xml deleted file mode 100644 index 55eea1c1f6c9..000000000000 --- a/shell/source/backends/gconfbe/gconfbe.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name>gconfbe</module-name> - <component-description> - <author> Oliver Braun </author> - <name>com.sun.star.comp.configuration.backend.GconfBackend</name> - <description> The </description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>c++</language> - <status value="beta"/> - <supported-service>com.sun.star.comp.configuration.backend.GconfBackend</supported-service> - <service-dependency>...</service-dependency> - <type>com.sun.star.configuration.backend.XBackendChangesListener</type> - <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> - <type>com.sun.star.configuration.backend.XLayerHandler</type> - <type>com.sun.star.configuration.backend.XSingleLayerStratum</type> - <type>com.sun.star.lang.XMultiComponentFactory</type> - <type>com.sun.star.lang.XServiceInfo</type> - <type>com.sun.star.lang.XSingleComponentFactory</type> - <type>com.sun.star.lang.XTypeProvider</type> - <type>com.sun.star.uno.TypeClass</type> - <type>com.sun.star.uno.XAggregation</type> - <type>com.sun.star.uno.XComponentContext</type> - <type>com.sun.star.uno.XCurrentContext</type> - <type>com.sun.star.uno.XWeak</type> - <type>com.sun.star.registry.XRegistryKey</type> - </component-description> - <project-build-dependency>cppuhelper</project-build-dependency> - <project-build-dependency>cppu</project-build-dependency> - <project-build-dependency>sal</project-build-dependency> - <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency> - <runtime-module-dependency>cppu3</runtime-module-dependency> - <runtime-module-dependency>sal3</runtime-module-dependency> -</module-description> diff --git a/shell/source/backends/gconfbe/gconfbecdef.cxx b/shell/source/backends/gconfbe/gconfbecdef.cxx deleted file mode 100644 index 91714cd9cafc..000000000000 --- a/shell/source/backends/gconfbe/gconfbecdef.cxx +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "gconfbackend.hxx" -#include <com/sun/star/registry/XRegistryKey.hpp> - -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include <cppuhelper/implementationentry.hxx> -#endif // _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include <com/sun/star/uno/XComponentContext.hpp> -#include <rtl/ustrbuf.hxx> - -#include "uno/current_context.hxx" -#include <stdio.h> -#include "orbit.h" - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -//============================================================================== - -static uno::Reference<uno::XInterface> SAL_CALL createGconfBackend(const uno::Reference<uno::XComponentContext>& xContext) -{ - try { - uno::Reference< uno::XCurrentContext > xCurrentContext(uno::getCurrentContext()); - - if (xCurrentContext.is()) - { - uno::Any aValue = xCurrentContext->getValueByName( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "system.desktop-environment" ) ) ); - - rtl::OUString aDesktopEnvironment; - if ( (aValue >>= aDesktopEnvironment) && (aDesktopEnvironment.equalsAscii("GNOME")) ) - { - // ORBit-2 versions < 2.8 cause a deadlock with the gtk+ VCL plugin - if ( (orbit_major_version >= 2) && (orbit_minor_version >= 8) ) - { - return * GconfBackend::createInstance(xContext); - } - } - } - - return uno::Reference<uno::XInterface>(); - - } catch (uno::RuntimeException e) { - return uno::Reference<uno::XInterface>(); - } - -} - -//============================================================================== - -static const cppu::ImplementationEntry kImplementations_entries[] = -{ - { - createGconfBackend, - GconfBackend::getBackendName, - GconfBackend::getBackendServiceNames, - cppu::createSingleComponentFactory, - NULL, - 0 - }, - { NULL, NULL, NULL, NULL, NULL, 0 } -} ; -//------------------------------------------------------------------------------ - -extern "C" void SAL_CALL component_getImplementationEnvironment( - const sal_Char **aEnvTypeName, - uno_Environment **/*aEnvironment*/) { - *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; -} - -//------------------------------------------------------------------------------ - -extern "C" sal_Bool SAL_CALL component_writeInfo(void */*pServiceManager*/, - void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + GconfBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = GconfBackend::getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - return sal_True; - } - - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - - return sal_False; -} - -//------------------------------------------------------------------------------ - -extern "C" void *component_getFactory(const sal_Char *aImplementationName, - void *aServiceManager, - void *aRegistryKey) { - - return cppu::component_getFactoryHelper( - aImplementationName, - aServiceManager, - aRegistryKey, - kImplementations_entries) ; -} -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/gconfbe/gconflayer.hxx b/shell/source/backends/gconfbe/gconflayer.hxx deleted file mode 100644 index af9753b9179a..000000000000 --- a/shell/source/backends/gconfbe/gconflayer.hxx +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef GCONFLAYER_HXX_ -#define GCONFLAYER_HXX_ - -#include "gconfbackend.hxx" -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> - -#define GCONF_PROXY_MODE_KEY "/system/proxy/mode" -#define GCONF_AUTO_SAVE_KEY "/apps/openoffice/auto_save" - -enum ConfigurationSetting -{ - SETTING_PROXY_MODE, - SETTING_PROXY_HTTP_HOST, - SETTING_PROXY_HTTP_PORT, - SETTING_PROXY_HTTPS_HOST, - SETTING_PROXY_HTTPS_PORT, - SETTING_PROXY_FTP_HOST, - SETTING_PROXY_FTP_PORT, - SETTING_NO_PROXY_FOR, - SETTING_ENABLE_ACCESSIBILITY, - SETTING_MAILER_PROGRAM, - SETTING_WORK_DIRECTORY, - SETTING_SOURCEVIEWFONT_NAME, - SETTING_SOURCEVIEWFONT_HEIGHT, - SETTING_USER_GIVENNAME, - SETTING_USER_SURNAME, - -#ifdef ENABLE_LOCKDOWN - - SETTING_DISABLE_PRINTING, - SETTING_USE_SYSTEM_FILE_DIALOG, - SETTING_DISABLE_UI_CUSTOMIZATION, - SETTING_PRINTING_MODIFIES_DOCUMENT, - SETTING_SHOW_ICONS_IN_MENUS, - SETTING_SHOW_INACTIVE_MENUITEMS, - SETTING_SHOW_FONT_PREVIEW, - SETTING_SHOW_FONT_HISTORY, - SETTING_ENABLE_OPENGL, - SETTING_OPTIMIZE_OPENGL, - SETTING_SAVE_DOCUMENT_WINDOWS, - SETTING_SAVE_DOCUMENT_VIEW_INFO, - SETTING_USE_SYSTEM_FONT, - SETTING_USE_FONT_ANTI_ALIASING, - SETTING_FONT_ANTI_ALIASING_MIN_PIXEL, - SETTING_WARN_CREATE_PDF, - SETTING_WARN_PRINT_DOC, - SETTING_WARN_SAVEORSEND_DOC, - SETTING_WARN_SIGN_DOC, - SETTING_REMOVE_PERSONAL_INFO, - SETTING_RECOMMEND_PASSWORD, - SETTING_UNDO_STEPS, - SETTING_SYMBOL_SET, - SETTING_MACRO_SECURITY_LEVEL, - SETTING_CREATE_BACKUP, - SETTING_WARN_ALIEN_FORMAT, - SETTING_AUTO_SAVE, - SETTING_AUTO_SAVE_INTERVAL, - SETTING_WRITER_DEFAULT_DOC_FORMAT, - SETTING_IMPRESS_DEFAULT_DOC_FORMAT, - SETTING_CALC_DEFAULT_DOC_FORMAT, - -#endif // ENABLE_LOCKDOWN - - SETTINGS_LAST -}; - -struct ConfigurationValue -{ - const ConfigurationSetting nSettingId; - const gchar *GconfItem; - const char *OOoConfItem; - const char *OOoConfValueType; - const sal_Bool bLocked; - const sal_Bool bNeedsTranslation; - const ConfigurationSetting nDependsOn; -}; - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the Gconf values mapped into - the org.openoffice.* configuration component. - */ -class GconfLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - GconfLayer( const uno::Reference<uno::XComponentContext>& xContext, - const ConfigurationValue pConfigurationValuesList[], - const sal_Int32 nConfigurationValues, - const char * pPreloadValuesList[] ); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException ); - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~GconfLayer(void) {} - -private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber; - const ConfigurationValue* m_pConfigurationValuesList; - const sal_Int32 m_nConfigurationValues; - const char** m_pPreloadValuesList; - } ; - -#endif // GCONFLAYER diff --git a/shell/source/backends/gconfbe/makefile.mk b/shell/source/backends/gconfbe/makefile.mk index 9a17d3aeaeb5..a8d9b23aa9df 100644 --- a/shell/source/backends/gconfbe/makefile.mk +++ b/shell/source/backends/gconfbe/makefile.mk @@ -31,8 +31,7 @@ TARGET=gconfbe LIBTARGET=NO ENABLE_EXCEPTIONS=TRUE - -COMP1TYPELIST=$(TARGET) +VISIBILITY_HIDDEN=TRUE # --- Settings --- @@ -65,9 +64,8 @@ PKGCONFIG_LIBS!:=-Wl,--export-dynamic $(PKGCONFIG_LIBS) SLOFILES=\ - $(SLO)$/gconfbecdef.obj \ - $(SLO)$/gconfbackend.obj \ - $(SLO)$/gconflayer.obj + $(SLO)$/gconfaccess.obj \ + $(SLO)$/gconfbackend.obj SHL1NOCHECK=TRUE SHL1TARGET=$(TARGET)1.uno @@ -82,7 +80,6 @@ SHL1STDLIBS= \ SHL1STDLIBS+=$(PKGCONFIG_LIBS) -SHL1VERSIONMAP=exports.map SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME=$(SHL1TARGET) diff --git a/shell/source/backends/kde4be/exports.map b/shell/source/backends/kde4be/exports.map deleted file mode 100644 index ba501f9ae076..000000000000 --- a/shell/source/backends/kde4be/exports.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - - local: - *; -}; diff --git a/shell/source/backends/kde4be/kde4access.cxx b/shell/source/backends/kde4be/kde4access.cxx new file mode 100644 index 000000000000..336d2d4a458e --- /dev/null +++ b/shell/source/backends/kde4be/kde4access.cxx @@ -0,0 +1,319 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_shell.hxx" +#include "sal/config.h" + +#include "QFont" +#include "QString" +#include "kemailsettings.h" +#include "kglobalsettings.h" +#include "kprotocolmanager.h" + +#include "com/sun/star/uno/Any.hxx" +#include "cppu/unotype.hxx" +#include "osl/diagnose.h" +#include "osl/file.h" +#include "rtl/string.h" +#include "rtl/ustring.hxx" + +#include "kde4access.hxx" + +#define SPACE ' ' +#define COMMA ',' +#define SEMI_COLON ';' + +namespace kde4access { + +namespace { + +namespace css = com::sun::star ; +namespace uno = css::uno ; + +} + +css::beans::Optional< css::uno::Any > getValue(rtl::OUString const & id) { + if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ExternalMailer"))) { + KEMailSettings aEmailSettings; + QString aClientProgram; + ::rtl::OUString sClientProgram; + + aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); + if ( aClientProgram.isEmpty() ) + aClientProgram = "kmail"; + else + aClientProgram = aClientProgram.section(SPACE, 0, 0); + sClientProgram = (const sal_Unicode *) aClientProgram.utf16(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sClientProgram ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight"))) + { + QFont aFixedFont; + short nFontHeight; + + aFixedFont = KGlobalSettings::fixedFont(); + nFontHeight = aFixedFont.pointSize(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nFontHeight ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontName"))) + { + QFont aFixedFont; + QString aFontName; + :: rtl::OUString sFontName; + + aFixedFont = KGlobalSettings::fixedFont(); + aFontName = aFixedFont.family(); + sFontName = (const sal_Unicode *) aFontName.utf16(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sFontName ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport"))) + { + /* does not make much sense without an accessibility bridge */ + sal_Bool ATToolSupport = sal_False; + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WorkPathVariable"))) + { + QString aDocumentsDir( KGlobalSettings::documentPath() ); + rtl::OUString sDocumentsDir; + rtl::OUString sDocumentsURL; + if ( aDocumentsDir.endsWith(QChar('/')) ) + aDocumentsDir.truncate ( aDocumentsDir.length() - 1 ); + sDocumentsDir = (const sal_Unicode *) aDocumentsDir.utf16(); + osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData ); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sDocumentsURL ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName"))) + { + QString aFTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aFTPProxy = KProtocolManager::proxyFor( "FTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aFTPProxy = KProtocolManager::proxyForUrl( KUrl("ftp://ftp.openoffice.org") ); + break; + default: // No proxy is used + break; + } + if ( !aFTPProxy.isEmpty() ) + { + KUrl aProxy(aFTPProxy); + ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sProxy ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort"))) + { + QString aFTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aFTPProxy = KProtocolManager::proxyFor( "FTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aFTPProxy = KProtocolManager::proxyForUrl( KUrl("ftp://ftp.openoffice.org") ); + break; + default: // No proxy is used + break; + } + if ( !aFTPProxy.isEmpty() ) + { + KUrl aProxy(aFTPProxy); + sal_Int32 nPort = aProxy.port(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nPort ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName"))) + { + QString aHTTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPProxy = KProtocolManager::proxyForUrl( KUrl("http://http.openoffice.org") ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPProxy.isEmpty() ) + { + KUrl aProxy(aHTTPProxy); + ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sProxy ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort"))) + { + QString aHTTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPProxy = KProtocolManager::proxyForUrl( KUrl("http://http.openoffice.org") ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPProxy.isEmpty() ) + { + KUrl aProxy(aHTTPProxy); + sal_Int32 nPort = aProxy.port(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nPort ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName"))) + { + QString aHTTPSProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPSProxy = KProtocolManager::proxyForUrl( KUrl("https://https.openoffice.org") ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPSProxy.isEmpty() ) + { + KUrl aProxy(aHTTPSProxy); + ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sProxy ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort"))) + { + QString aHTTPSProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPSProxy = KProtocolManager::proxyForUrl( KUrl("https://https.openoffice.org") ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPSProxy.isEmpty() ) + { + KUrl aProxy(aHTTPSProxy); + sal_Int32 nPort = aProxy.port(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nPort ) ); + } + } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) { + QString aNoProxyFor; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables + aNoProxyFor = KProtocolManager::noProxyFor(); + break; + default: // No proxy is used + break; + } + if ( !aNoProxyFor.isEmpty() ) + { + ::rtl::OUString sNoProxyFor; + + aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON ); + sNoProxyFor = (const sal_Unicode *) aNoProxyFor.utf16(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sNoProxyFor ) ); + } + } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) { + int nProxyType; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables + nProxyType = 1; + break; + default: // No proxy is used + nProxyType = 0; + } + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( (sal_Int32) nProxyType ) ); + } else { + OSL_ASSERT(false); // this cannot happen + } + return css::beans::Optional< css::uno::Any >(); +} + +} diff --git a/shell/source/backends/kde4be/kde4access.hxx b/shell/source/backends/kde4be/kde4access.hxx new file mode 100644 index 000000000000..bfb7bc1ac945 --- /dev/null +++ b/shell/source/backends/kde4be/kde4access.hxx @@ -0,0 +1,47 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_KDE4BE_KDE4ACCESS_HXX +#define INCLUDED_SHELL_SOURCE_BACKENDS_KDE4BE_KDE4ACCESS_HXX + +#include "sal/config.h" + +#include "com/sun/star/beans/Optional.hpp" + +namespace com { namespace sun { namespace star { namespace uno { + class Any; +} } } } +namespace rtl { class OUString; } + +namespace kde4access { + +com::sun::star::beans::Optional< com::sun::star::uno::Any > getValue( + rtl::OUString const & id); + +} + +#endif diff --git a/shell/source/backends/kde4be/kde4backend.cxx b/shell/source/backends/kde4be/kde4backend.cxx index 28cfcd180d05..44ddb49bd025 100644 --- a/shell/source/backends/kde4be/kde4backend.cxx +++ b/shell/source/backends/kde4be/kde4backend.cxx @@ -1,155 +1,258 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + #include "precompiled_shell.hxx" +#include "sal/config.h" -#include "kde4backend.hxx" -#include "kde4commonlayer.hxx" -#include "kde4inetlayer.hxx" -#include "kde4vcllayer.hxx" -#include "kde4pathslayer.hxx" +#include "kapplication.h" -//------------------------------------------------------------------------------ +#include "boost/noncopyable.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XPropertyChangeListener.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/XPropertySetInfo.hpp" +#include "com/sun/star/beans/XVetoableChangeListener.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "rtl/string.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/current_context.hxx" +#include "uno/lbnames.h" -KDEBackend* KDEBackend::mInstance= 0; +#include "kde4access.hxx" -KDEBackend* KDEBackend::createInstance(const uno::Reference<uno::XComponentContext>& xContext) -{ - if (mInstance == 0) - { - mInstance = new KDEBackend (xContext); - } +namespace { + +namespace css = com::sun::star; - return mInstance; +rtl::OUString SAL_CALL getServiceImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.backend.KDE4Backend")); } -//------------------------------------------------------------------------------ +css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.KDE4Backend")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} -KDEBackend::KDEBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException) - : BackendBase(mMutex), m_xContext(xContext) +class Service: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::beans::XPropertySet >, + private boost::noncopyable { -} +public: + Service(); -//------------------------------------------------------------------------------ +private: + virtual ~Service() {} -KDEBackend::~KDEBackend(void) -{ -} + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return getServiceImplementationName(); } -//------------------------------------------------------------------------------ + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } -uno::Reference<backend::XLayer> SAL_CALL KDEBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /* aTimestamp */) - throw (backend::BackendAccessException, lang::IllegalArgumentException) -{ - uno::Reference<backend::XLayer> xLayer; + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return getServiceSupportedServiceNames(); } - if( aComponent.equalsAscii("org.openoffice.Office.Common" ) ) - { - xLayer = new KDECommonLayer(m_xContext); - } - else if( aComponent.equalsAscii("org.openoffice.Inet" ) ) - { - xLayer = new KDEInetLayer(m_xContext); - } - else if( aComponent.equalsAscii("org.openoffice.VCL" ) ) - { - xLayer = new KDEVCLLayer(m_xContext); - } - else if( aComponent.equalsAscii("org.openoffice.Office.Paths" ) ) - { - xLayer = new KDEPathsLayer(m_xContext); - } + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } - return xLayer; -} + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); -//------------------------------------------------------------------------------ + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); -uno::Reference<backend::XUpdatableLayer> SAL_CALL -KDEBackend::getUpdatableLayer(const rtl::OUString& /* aComponent */) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) -{ - throw lang::NoSupportException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("KDEBackend: No Update Operation allowed, Read Only access") ), - *this) ; -} + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -//------------------------------------------------------------------------------ + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -rtl::OUString SAL_CALL KDEBackend::getBackendName(void) -{ - return rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.KDE4Backend") ); -} + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -//------------------------------------------------------------------------------ + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -rtl::OUString SAL_CALL KDEBackend::getImplementationName(void) - throw (uno::RuntimeException) -{ - return getBackendName() ; -} + bool enabled_; +}; -//------------------------------------------------------------------------------ +Service::Service(): enabled_(false) { + css::uno::Reference< css::uno::XCurrentContext > context( + css::uno::getCurrentContext()); + if (context.is()) { + rtl::OUString desktop; + context->getValueByName( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>= + desktop; + enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE4")) && + KApplication::kApplication() != 0; + } +} -uno::Sequence<rtl::OUString> SAL_CALL KDEBackend::getBackendServiceNames(void) +void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - uno::Sequence<rtl::OUString> aServices(1) ; - aServices[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.KDE4Backend")) ; - - return aServices ; + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); } -//------------------------------------------------------------------------------ +css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) + { + return css::uno::makeAny( + enabled_ + ? kde4access::getValue(PropertyName) + : css::beans::Optional< css::uno::Any >()); + } + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); +} -sal_Bool SAL_CALL KDEBackend::supportsService(const rtl::OUString& aServiceName) - throw (uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( + css::uno::Reference< css::uno::XComponentContext > const &) { - uno::Sequence< rtl::OUString > const svc = getBackendServiceNames(); + return static_cast< cppu::OWeakObject * >(new Service); +} - for(sal_Int32 i = 0; i < svc.getLength(); ++i ) - if(svc[i] == aServiceName) - return true; +static cppu::ImplementationEntry const services[] = { + { &createInstance, &getServiceImplementationName, + &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0, + 0 }, + { 0, 0, 0, 0, 0, 0 } +}; - return false; } -//------------------------------------------------------------------------------ +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) +{ + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); +} -uno::Sequence<rtl::OUString> -SAL_CALL KDEBackend::getSupportedServiceNames(void) - throw (uno::RuntimeException) +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) { - return getBackendServiceNames() ; + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -// --------------------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey) +{ + return component_writeInfoHelper(pServiceManager, pRegistryKey, services); +} diff --git a/shell/source/backends/kde4be/kde4backend.hxx b/shell/source/backends/kde4be/kde4backend.hxx deleted file mode 100644 index ed0658c07c25..000000000000 --- a/shell/source/backends/kde4be/kde4backend.hxx +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#pragma once - -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> -#include <com/sun/star/configuration/backend/CannotConnectException.hpp> -#include <cppuhelper/compbase2.hxx> - -#ifndef INCLUDED_MAP -#include <map> -#define INCLUDED_MAP -#endif - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - - -//------------------------------------------------------------------------------ -typedef cppu::WeakComponentImplHelper2<backend::XSingleLayerStratum, - lang::XServiceInfo> BackendBase ; - -/** - Implements the SingleLayerStratum service for KDE access. - */ -class KDEBackend : public BackendBase { - public : - - static KDEBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); - - // XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName( ) - 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) ; - - /** - Provides the implementation name. - - @return implementation name - */ - static rtl::OUString SAL_CALL getBackendName(void) ; - - /** - Provides the supported services names - - @return service names - */ - static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ; - - //XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL - 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) ; - - protected: - /** - Service constructor from a service factory. - - @param xContext component context - */ - KDEBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); - - /** Destructor */ - ~KDEBackend(void) ; - - private: - - /** Build KDE/OO mapping table */ - void initializeMappingTable (); - - - /** The component context */ - uno::Reference<uno::XComponentContext> m_xContext; - - /** Mutex for reOOurces protection */ - osl::Mutex mMutex ; - - static KDEBackend* mInstance; -}; diff --git a/shell/source/backends/kde4be/kde4be.xml b/shell/source/backends/kde4be/kde4be.xml deleted file mode 100644 index ea2d9be6dd6b..000000000000 --- a/shell/source/backends/kde4be/kde4be.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name>kde4be</module-name> - <component-description> - <author> Éric Bischoff </author> - <name>com.sun.star.comp.configuration.backend.KDE4Backend</name> - <description> The KDE4 configuration backend </description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>c++</language> - <status value="beta"/> - <supported-service>com.sun.star.comp.configuration.backend.KDE4Backend</supported-service> - <service-dependency>...</service-dependency> - <type>com.sun.star.configuration.backend.XBackendChangesListener</type> - <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> - <type>com.sun.star.configuration.backend.XLayerHandler</type> - <type>com.sun.star.configuration.backend.XSingleLayerStratum</type> - <type>com.sun.star.lang.XMultiComponentFactory</type> - <type>com.sun.star.lang.XServiceInfo</type> - <type>com.sun.star.lang.XSingleComponentFactory</type> - <type>com.sun.star.lang.XTypeProvider</type> - <type>com.sun.star.uno.TypeClass</type> - <type>com.sun.star.uno.XAggregation</type> - <type>com.sun.star.uno.XComponentContext</type> - <type>com.sun.star.uno.XCurrentContext</type> - <type>com.sun.star.uno.XWeak</type> - <type>com.sun.star.registry.XRegistryKey</type> - </component-description> - <project-build-dependency>cppuhelper</project-build-dependency> - <project-build-dependency>cppu</project-build-dependency> - <project-build-dependency>sal</project-build-dependency> - <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency> - <runtime-module-dependency>cppu3</runtime-module-dependency> - <runtime-module-dependency>sal3</runtime-module-dependency> -</module-description> diff --git a/shell/source/backends/kde4be/kde4becdef.cxx b/shell/source/backends/kde4be/kde4becdef.cxx deleted file mode 100644 index 189d7ff80d61..000000000000 --- a/shell/source/backends/kde4be/kde4becdef.cxx +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "kde4backend.hxx" - -#include <kapplication.h> - -#include <cppuhelper/implementationentry.hxx> - -#include <com/sun/star/registry/XRegistryKey.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> - -#include "uno/current_context.hxx" - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -//============================================================================== - -static uno::Reference<uno::XInterface> SAL_CALL createKDEBackend(const uno::Reference<uno::XComponentContext>& xContext) -{ - try { - uno::Reference< uno::XCurrentContext > xCurrentContext(uno::getCurrentContext()); - - if (xCurrentContext.is()) - { - uno::Any aValue = xCurrentContext->getValueByName( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "system.desktop-environment" ) ) ); - - rtl::OUString aDesktopEnvironment; - if ( (aValue >>= aDesktopEnvironment) && (aDesktopEnvironment.equalsAscii("KDE")) && (KApplication::kApplication() != NULL) ) - return * KDEBackend::createInstance(xContext); - } - - return uno::Reference<uno::XInterface>(); - - } catch (uno::RuntimeException e) { - return uno::Reference<uno::XInterface>(); - } - -} - -//============================================================================== - -static const cppu::ImplementationEntry kImplementations_entries[] = -{ - { - createKDEBackend, - KDEBackend::getBackendName, - KDEBackend::getBackendServiceNames, - cppu::createSingleComponentFactory, - NULL, - 0 - }, - { NULL, NULL, NULL, NULL, NULL, 0 } -} ; -//------------------------------------------------------------------------------ - -extern "C" void SAL_CALL component_getImplementationEnvironment( - const sal_Char **aEnvTypeName, - uno_Environment **) { - *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; -} - -//------------------------------------------------------------------------------ - -extern "C" sal_Bool SAL_CALL component_writeInfo(void *, - void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + KDEBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = KDEBackend::getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - return sal_True; - } - - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - - return sal_False; -} - -//------------------------------------------------------------------------------ - -extern "C" void *component_getFactory(const sal_Char *aImplementationName, - void *aServiceManager, - void *aRegistryKey) { - - return cppu::component_getFactoryHelper( - aImplementationName, - aServiceManager, - aRegistryKey, - kImplementations_entries) ; -} -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/kde4be/kde4commonlayer.cxx b/shell/source/backends/kde4be/kde4commonlayer.cxx deleted file mode 100644 index c0d1cbf70b43..000000000000 --- a/shell/source/backends/kde4be/kde4commonlayer.cxx +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -#include "kde4commonlayer.hxx" - -#include <kemailsettings.h> -#include <kglobalsettings.h> - -#include <QFont> - -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#define SPACE ' ' - -//============================================================================== - -KDECommonLayer::KDECommonLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDECommonLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(3); - sal_Int32 nProperties = 0; - - // Email client settings - KEMailSettings aEmailSettings; - QString aClientProgram; - ::rtl::OUString sClientProgram; - - aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); - if ( aClientProgram.isEmpty() ) - aClientProgram = "kmail"; - else - aClientProgram = aClientProgram.section(SPACE, 0, 0); - sClientProgram = (const sal_Unicode *) aClientProgram.utf16(); - - 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( sClientProgram ); - - // Source code font settings - QFont aFixedFont; - QString aFontName; - :: rtl::OUString sFontName; - short nFontHeight; - - aFixedFont = KGlobalSettings::fixedFont(); - aFontName = aFixedFont.family(); - sFontName = (const sal_Unicode *) aFontName.utf16(); - nFontHeight = aFixedFont.pointSize(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontName") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sFontName ); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontHeight") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "short" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( nFontHeight ); - - if( nProperties > 0 ) - { - aPropInfoList.realloc(nProperties); - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDECommonLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - KEMailSettings aEmailSettings; - QString aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); - aClientProgram = aClientProgram.section(SPACE, 0, 0); - - QString aFixedFont = KGlobalSettings::fixedFont().toString(); - - ::rtl::OUString sTimeStamp, - sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) ); - - sTimeStamp = (const sal_Unicode *) aClientProgram.utf16(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aFixedFont.utf16(); - - return sTimeStamp; -} diff --git a/shell/source/backends/kde4be/kde4commonlayer.hxx b/shell/source/backends/kde4be/kde4commonlayer.hxx deleted file mode 100644 index 9ce4cd4dc962..000000000000 --- a/shell/source/backends/kde4be/kde4commonlayer.hxx +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "kde4backend.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.Office.Common configuration component. - */ -class KDECommonLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDECommonLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDECommonLayer(void) {} - - private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; -}; diff --git a/shell/source/backends/kde4be/kde4inetlayer.cxx b/shell/source/backends/kde4be/kde4inetlayer.cxx deleted file mode 100644 index 7382d7a089b0..000000000000 --- a/shell/source/backends/kde4be/kde4inetlayer.cxx +++ /dev/null @@ -1,252 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -#include <kprotocolmanager.h> - -#include "kde4inetlayer.hxx" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#define COMMA ',' -#define SEMI_COLON ';' - -//============================================================================== - -KDEInetLayer::KDEInetLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDEInetLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(8); - sal_Int32 nProperties = 0; - - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - setProxy(aPropInfoList, nProperties, 1, - KProtocolManager::noProxyFor(), - KProtocolManager::proxyFor( "HTTP" ), - KProtocolManager::proxyFor( "FTP" ), - KProtocolManager::proxyFor( "HTTPS" )); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - setProxy(aPropInfoList, nProperties, 1, - KProtocolManager::noProxyFor(), - KProtocolManager::proxyForUrl( KUrl("http://www.openoffice.org") ), - KProtocolManager::proxyForUrl( KUrl("ftp://ftp.openoffice.org") ), - KProtocolManager::proxyForUrl( KUrl("https://www.openoffice.org") )); - break; - default: // No proxy is used - setProxy(aPropInfoList, nProperties, 0); - } - - if ( nProperties > 0 ) - { - aPropInfoList.realloc(nProperties); - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDEInetLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - QString aProxyType, aNoProxyFor, aHTTPProxy, aHTTPSProxy, aFTPProxy; - - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: - aProxyType = '1'; - aNoProxyFor = KProtocolManager::noProxyFor(); - aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); - aHTTPProxy = KProtocolManager::proxyFor( "HTTPS" ); - aFTPProxy = KProtocolManager::proxyFor( "FTP" ); - break; - case KProtocolManager::PACProxy: - case KProtocolManager::WPADProxy: - case KProtocolManager::EnvVarProxy: - aProxyType = '1'; - aNoProxyFor = KProtocolManager::noProxyFor(); - aHTTPProxy = KProtocolManager::proxyForUrl( KUrl("http://www.openoffice.org") ); - aHTTPSProxy = KProtocolManager::proxyForUrl( KUrl("https://www.openoffice.org") ); - aFTPProxy = KProtocolManager::proxyForUrl( KUrl("ftp://ftp.openoffice.org") ); - break; - default: - aProxyType = '0'; - } - - ::rtl::OUString sTimeStamp, - sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) ); - - sTimeStamp = (const sal_Unicode *) aProxyType.utf16(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aNoProxyFor.utf16(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aHTTPProxy.utf16(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aHTTPSProxy.utf16(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aFTPProxy.utf16(); - - return sTimeStamp; -} - -//------------------------------------------------------------------------------ - -void SAL_CALL KDEInetLayer::setProxy - (uno::Sequence<backend::PropertyInfo> &aPropInfoList, sal_Int32 &nProperties, - int nProxyType, const QString &aNoProxy, const QString &aHTTPProxy, const QString &aFTPProxy, const QString &aHTTPSProxy ) const -{ - 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) nProxyType ); - - if (nProxyType == 0) return; - - if ( !aNoProxy.isEmpty() ) - { - QString aNoProxyFor(aNoProxy); - ::rtl::OUString sNoProxyFor; - - aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON ); - sNoProxyFor = (const sal_Unicode *) aNoProxyFor.utf16(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetNoProxy") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sNoProxyFor ); - } - - if ( !aHTTPProxy.isEmpty() ) - { - KUrl aProxy(aHTTPProxy); - ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16(); - sal_Int32 nPort = aProxy.port(); - - 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( sProxy ); - - 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( nPort ); - } - - if ( !aHTTPSProxy.isEmpty() ) - { - KUrl aProxy(aHTTPSProxy); - ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16(); - sal_Int32 nPort = aProxy.port(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyName") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sProxy ); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyPort") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "int" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( nPort ); - } - - if ( !aFTPProxy.isEmpty() ) - { - KUrl aProxy(aFTPProxy); - ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16(); - sal_Int32 nPort = aProxy.port(); - - 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( sProxy ); - - 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( nPort ); - } -} - diff --git a/shell/source/backends/kde4be/kde4inetlayer.hxx b/shell/source/backends/kde4be/kde4inetlayer.hxx deleted file mode 100644 index 64d00fec45fc..000000000000 --- a/shell/source/backends/kde4be/kde4inetlayer.hxx +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include <QString> - -#include "kde4backend.hxx" - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.Inet configuration component. - */ -class KDEInetLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDEInetLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDEInetLayer(void) {} - -private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - - void SAL_CALL setProxy - (uno::Sequence<backend::PropertyInfo> &aPropInfoList, sal_Int32 &nProperties, - int nProxyType, const QString &aNoProxyfor = QString(), - const QString &aHTTPProxy = QString(), const QString &aFTPProxy = QString(), const QString &aHTTPSProxy = QString()) const; -}; diff --git a/shell/source/backends/kde4be/kde4pathslayer.cxx b/shell/source/backends/kde4be/kde4pathslayer.cxx deleted file mode 100644 index cf6eb052d0bb..000000000000 --- a/shell/source/backends/kde4be/kde4pathslayer.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -#include "kde4pathslayer.hxx" - -#include <QString> -#include <kglobalsettings.h> - -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> - -#include <osl/security.hxx> -#include <osl/file.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -#define SPACE ' ' - -//============================================================================== - -KDEPathsLayer::KDEPathsLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDEPathsLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(1); - sal_Int32 nProperties = 0; - - QString aDocumentsDir( KGlobalSettings::documentPath() ); - rtl::OUString sDocumentsDir; - rtl::OUString sDocumentsURL; - if ( aDocumentsDir.endsWith(QChar('/')) ) - aDocumentsDir.truncate ( aDocumentsDir.length() - 1 ); - sDocumentsDir = (const sal_Unicode *) aDocumentsDir.utf16(); - osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData ); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Paths/Variables/Work") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sDocumentsURL ); - - if( nProperties > 0 ) - { - aPropInfoList.realloc(nProperties); - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDEPathsLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - ::rtl::OUString sTimeStamp, - sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) ); - - QString aDocumentsDir; - aDocumentsDir = KGlobalSettings::documentPath(); - - sTimeStamp += (const sal_Unicode *) aDocumentsDir.utf16(); - - return sTimeStamp; -} diff --git a/shell/source/backends/kde4be/kde4pathslayer.hxx b/shell/source/backends/kde4be/kde4pathslayer.hxx deleted file mode 100644 index bc09b0f027db..000000000000 --- a/shell/source/backends/kde4be/kde4pathslayer.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#pragma once - -#include "kde4backend.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/util/XTimeStamped.hpp> - -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.Office.Paths configuration component. - */ -class KDEPathsLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDEPathsLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDEPathsLayer(void) {} - - private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; -}; diff --git a/shell/source/backends/kde4be/kde4vcllayer.cxx b/shell/source/backends/kde4be/kde4vcllayer.cxx deleted file mode 100644 index a3a9f32dba74..000000000000 --- a/shell/source/backends/kde4be/kde4vcllayer.cxx +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -#include "kde4vcllayer.hxx" - -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -//============================================================================== - -KDEVCLLayer::KDEVCLLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDEVCLLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(1); - -/* - Commenting out, does not make much sense without an accessibility bridge -=========================================================================== -#if defined(QT_ACCESSIBILITY_SUPPORT) -// Accessibility tools under Qt for UNIX are available starting with Qt 4.0 - int nVersionMajor = 0; - const char *q = qVersion(); // "3.1.0" for example - while ('0' <= *q && *q <= '9') - nVersionMajor = nVersionMajor * 10 + *q++ - '0'; - sal_Bool ATToolSupport = (sal_Bool) (nVersionMajor >= 4); -#else - sal_Bool ATToolSupport = sal_False; -#endif -=========================================================================== - End of commented out section -*/ sal_Bool ATToolSupport = sal_False; - - aPropInfoList[0].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.VCL/Settings/Accessibility/EnableATToolSupport") ); - aPropInfoList[0].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value = uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ); - - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDEVCLLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - ::rtl::OUString sTimeStamp( - RTL_CONSTASCII_USTRINGPARAM( "FALSE" ) ); - - return sTimeStamp; -} diff --git a/shell/source/backends/kde4be/kde4vcllayer.hxx b/shell/source/backends/kde4be/kde4vcllayer.hxx deleted file mode 100644 index 16036ee89122..000000000000 --- a/shell/source/backends/kde4be/kde4vcllayer.hxx +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "kde4backend.hxx" - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#include <com/sun/star/util/XTimeStamped.hpp> - -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.VCL configuration component. - */ -class KDEVCLLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDEVCLLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDEVCLLayer(void) {} - - private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; -}; diff --git a/shell/source/backends/kde4be/makefile.mk b/shell/source/backends/kde4be/makefile.mk index cc7a51ab0f3c..1f9093a95aee 100644 --- a/shell/source/backends/kde4be/makefile.mk +++ b/shell/source/backends/kde4be/makefile.mk @@ -31,11 +31,7 @@ TARGET=kde4be LIBTARGET=NO ENABLE_EXCEPTIONS=TRUE - -COMP1TYPELIST=$(TARGET) -COMPRDB=$(SOLARBINDIR)$/types.rdb -UNOUCROUT=$(OUT)$/inc$/$(TARGET) -INCPRE=$(UNOUCROUT) +VISIBILITY_HIDDEN=TRUE # --- Settings --- @@ -60,12 +56,8 @@ CFLAGS+=$(KDE4_CFLAGS) # --- Files --- SLOFILES=\ - $(SLO)$/kde4backend.obj \ - $(SLO)$/kde4commonlayer.obj \ - $(SLO)$/kde4inetlayer.obj \ - $(SLO)$/kde4vcllayer.obj \ - $(SLO)$/kde4pathslayer.obj \ - $(SLO)$/kde4becdef.obj + $(SLO)$/kde4access.obj \ + $(SLO)$/kde4backend.obj SHL1NOCHECK=TRUE SHL1TARGET=$(TARGET)1.uno @@ -78,8 +70,7 @@ SHL1STDLIBS= \ $(CPPULIB) \ $(SALLIB) \ $(KDE4_LIBS) -lkio - -SHL1VERSIONMAP=exports.map + SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME=$(SHL1TARGET) diff --git a/shell/source/backends/kdebe/exports.map b/shell/source/backends/kdebe/exports.map deleted file mode 100644 index ba501f9ae076..000000000000 --- a/shell/source/backends/kdebe/exports.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - - local: - *; -}; diff --git a/shell/source/backends/kdebe/kdeaccess.cxx b/shell/source/backends/kdebe/kdeaccess.cxx new file mode 100644 index 000000000000..618d74b5eacf --- /dev/null +++ b/shell/source/backends/kdebe/kdeaccess.cxx @@ -0,0 +1,315 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_shell.hxx" +#include "sal/config.h" + +#include "com/sun/star/uno/Any.hxx" +#include "cppu/unotype.hxx" +#include "osl/diagnose.h" +#include "osl/file.h" +#include "rtl/string.h" +#include "rtl/ustring.hxx" + +#include "kde_headers.h" + +#include "kdeaccess.hxx" + +#define SPACE ' ' +#define COMMA ',' +#define SEMI_COLON ';' + +namespace kdeaccess { + +namespace { + +namespace css = com::sun::star ; +namespace uno = css::uno ; + +} + +css::beans::Optional< css::uno::Any > getValue(rtl::OUString const & id) { + if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ExternalMailer"))) { + KEMailSettings aEmailSettings; + QString aClientProgram; + ::rtl::OUString sClientProgram; + + aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); + if ( aClientProgram.isEmpty() ) + aClientProgram = "kmail"; + else + aClientProgram = aClientProgram.section(SPACE, 0, 0); + sClientProgram = (const sal_Unicode *) aClientProgram.ucs2(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sClientProgram ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight"))) + { + QFont aFixedFont; + short nFontHeight; + + aFixedFont = KGlobalSettings::fixedFont(); + nFontHeight = aFixedFont.pointSize(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nFontHeight ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontName"))) + { + QFont aFixedFont; + QString aFontName; + :: rtl::OUString sFontName; + + aFixedFont = KGlobalSettings::fixedFont(); + aFontName = aFixedFont.family(); + sFontName = (const sal_Unicode *) aFontName.ucs2(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sFontName ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport"))) + { + /* does not make much sense without an accessibility bridge */ + sal_Bool ATToolSupport = sal_False; + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WorkPathVariable"))) + { + QString aDocumentsDir( KGlobalSettings::documentPath() ); + rtl::OUString sDocumentsDir; + rtl::OUString sDocumentsURL; + if ( aDocumentsDir.endsWith(QChar('/')) ) + aDocumentsDir.truncate ( aDocumentsDir.length() - 1 ); + sDocumentsDir = (const sal_Unicode *) aDocumentsDir.ucs2(); + osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData ); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sDocumentsURL ) ); + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName"))) + { + QString aFTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aFTPProxy = KProtocolManager::proxyFor( "FTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" ); + break; + default: // No proxy is used + break; + } + if ( !aFTPProxy.isEmpty() ) + { + KURL aProxy(aFTPProxy); + ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sProxy ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort"))) + { + QString aFTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aFTPProxy = KProtocolManager::proxyFor( "FTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" ); + break; + default: // No proxy is used + break; + } + if ( !aFTPProxy.isEmpty() ) + { + KURL aProxy(aFTPProxy); + sal_Int32 nPort = aProxy.port(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nPort ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName"))) + { + QString aHTTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPProxy.isEmpty() ) + { + KURL aProxy(aHTTPProxy); + ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sProxy ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort"))) + { + QString aHTTPProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPProxy.isEmpty() ) + { + KURL aProxy(aHTTPProxy); + sal_Int32 nPort = aProxy.port(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nPort ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName"))) + { + QString aHTTPSProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPSProxy.isEmpty() ) + { + KURL aProxy(aHTTPSProxy); + ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sProxy ) ); + } + } else if (id.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort"))) + { + QString aHTTPSProxy; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" ); + break; + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables +// In such cases, the proxy address is not stored in KDE, but determined dynamically. +// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... +// The best we can do here is to ask the current value for a given address. + aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" ); + break; + default: // No proxy is used + break; + } + if ( !aHTTPSProxy.isEmpty() ) + { + KURL aProxy(aHTTPSProxy); + sal_Int32 nPort = aProxy.port(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nPort ) ); + } + } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) { + QString aNoProxyFor; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables + aNoProxyFor = KProtocolManager::noProxyFor(); + break; + default: // No proxy is used + break; + } + if ( !aNoProxyFor.isEmpty() ) + { + ::rtl::OUString sNoProxyFor; + + aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON ); + sNoProxyFor = (const sal_Unicode *) aNoProxyFor.ucs2(); + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( sNoProxyFor ) ); + } + } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) { + int nProxyType; + switch ( KProtocolManager::proxyType() ) + { + case KProtocolManager::ManualProxy: // Proxies are manually configured + case KProtocolManager::PACProxy: // A proxy configuration URL has been given + case KProtocolManager::WPADProxy: // A proxy should be automatically discovered + case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables + nProxyType = 1; + break; + default: // No proxy is used + nProxyType = 0; + } + return css::beans::Optional< css::uno::Any >( + true, uno::makeAny( (sal_Int32) nProxyType ) ); + } else { + OSL_ASSERT(false); // this cannot happen + } + return css::beans::Optional< css::uno::Any >(); +} + +} diff --git a/shell/source/backends/kdebe/kdeaccess.hxx b/shell/source/backends/kdebe/kdeaccess.hxx new file mode 100644 index 000000000000..36a22e23db9a --- /dev/null +++ b/shell/source/backends/kdebe/kdeaccess.hxx @@ -0,0 +1,47 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_KDEBE_KDEACCESS_HXX +#define INCLUDED_SHELL_SOURCE_BACKENDS_KDEBE_KDEACCESS_HXX + +#include "sal/config.h" + +#include "com/sun/star/beans/Optional.hpp" + +namespace com { namespace sun { namespace star { namespace uno { + class Any; +} } } } +namespace rtl { class OUString; } + +namespace kdeaccess { + +com::sun::star::beans::Optional< com::sun::star::uno::Any > getValue( + rtl::OUString const & id); + +} + +#endif diff --git a/shell/source/backends/kdebe/kdebackend.cxx b/shell/source/backends/kdebe/kdebackend.cxx index edf88212a9af..53a00cf35987 100644 --- a/shell/source/backends/kdebe/kdebackend.cxx +++ b/shell/source/backends/kdebe/kdebackend.cxx @@ -1,155 +1,258 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + #include "precompiled_shell.hxx" +#include "sal/config.h" -#include "kdebackend.hxx" -#include "kdecommonlayer.hxx" -#include "kdeinetlayer.hxx" -#include "kdevcllayer.hxx" -#include "kdepathslayer.hxx" +#include "boost/noncopyable.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XPropertyChangeListener.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/XPropertySetInfo.hpp" +#include "com/sun/star/beans/XVetoableChangeListener.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "rtl/string.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/current_context.hxx" +#include "uno/lbnames.h" -//------------------------------------------------------------------------------ +#include "kde_headers.h" -KDEBackend* KDEBackend::mInstance= 0; +#include "kdeaccess.hxx" -KDEBackend* KDEBackend::createInstance(const uno::Reference<uno::XComponentContext>& xContext) -{ - if (mInstance == 0) - { - mInstance = new KDEBackend (xContext); - } +namespace { + +namespace css = com::sun::star; - return mInstance; +rtl::OUString SAL_CALL getServiceImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.backend.KDEBackend")); } -//------------------------------------------------------------------------------ +css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.backend.KDEBackend")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} -KDEBackend::KDEBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException) - : BackendBase(mMutex), m_xContext(xContext) +class Service: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::beans::XPropertySet >, + private boost::noncopyable { -} +public: + Service(); -//------------------------------------------------------------------------------ +private: + virtual ~Service() {} -KDEBackend::~KDEBackend(void) -{ -} + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return getServiceImplementationName(); } -//------------------------------------------------------------------------------ + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } -uno::Reference<backend::XLayer> SAL_CALL KDEBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /* aTimestamp */) - throw (backend::BackendAccessException, lang::IllegalArgumentException) -{ - uno::Reference<backend::XLayer> xLayer; + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return getServiceSupportedServiceNames(); } - if( aComponent.equalsAscii("org.openoffice.Office.Common" ) ) - { - xLayer = new KDECommonLayer(m_xContext); - } - else if( aComponent.equalsAscii("org.openoffice.Inet" ) ) - { - xLayer = new KDEInetLayer(m_xContext); - } - else if( aComponent.equalsAscii("org.openoffice.VCL" ) ) - { - xLayer = new KDEVCLLayer(m_xContext); - } - else if( aComponent.equalsAscii("org.openoffice.Office.Paths" ) ) - { - xLayer = new KDEPathsLayer(m_xContext); - } + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } - return xLayer; -} + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); -//------------------------------------------------------------------------------ + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); -uno::Reference<backend::XUpdatableLayer> SAL_CALL -KDEBackend::getUpdatableLayer(const rtl::OUString& /* aComponent */) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) -{ - throw lang::NoSupportException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("KDEBackend: No Update Operation allowed, Read Only access") ), - *this) ; -} + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -//------------------------------------------------------------------------------ + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -rtl::OUString SAL_CALL KDEBackend::getBackendName(void) -{ - return rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.KDEBackend") ); -} + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -//------------------------------------------------------------------------------ + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} -rtl::OUString SAL_CALL KDEBackend::getImplementationName(void) - throw (uno::RuntimeException) -{ - return getBackendName() ; -} + bool enabled_; +}; -//------------------------------------------------------------------------------ +Service::Service(): enabled_(false) { + css::uno::Reference< css::uno::XCurrentContext > context( + css::uno::getCurrentContext()); + if (context.is()) { + rtl::OUString desktop; + context->getValueByName( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>= + desktop; + enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE")) && + KApplication::kApplication() != 0; + } +} -uno::Sequence<rtl::OUString> SAL_CALL KDEBackend::getBackendServiceNames(void) +void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - uno::Sequence<rtl::OUString> aServices(1) ; - aServices[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.KDEBackend")) ; - - return aServices ; + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); } -//------------------------------------------------------------------------------ +css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) || + PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) + { + return css::uno::makeAny( + enabled_ + ? kdeaccess::getValue(PropertyName) + : css::beans::Optional< css::uno::Any >()); + } + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); +} -sal_Bool SAL_CALL KDEBackend::supportsService(const rtl::OUString& aServiceName) - throw (uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( + css::uno::Reference< css::uno::XComponentContext > const &) { - uno::Sequence< rtl::OUString > const svc = getBackendServiceNames(); + return static_cast< cppu::OWeakObject * >(new Service); +} - for(sal_Int32 i = 0; i < svc.getLength(); ++i ) - if(svc[i] == aServiceName) - return true; +static cppu::ImplementationEntry const services[] = { + { &createInstance, &getServiceImplementationName, + &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0, + 0 }, + { 0, 0, 0, 0, 0, 0 } +}; - return false; } -//------------------------------------------------------------------------------ +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) +{ + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); +} -uno::Sequence<rtl::OUString> -SAL_CALL KDEBackend::getSupportedServiceNames(void) - throw (uno::RuntimeException) +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) { - return getBackendServiceNames() ; + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -// --------------------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey) +{ + return component_writeInfoHelper(pServiceManager, pRegistryKey, services); +} diff --git a/shell/source/backends/kdebe/kdebackend.hxx b/shell/source/backends/kdebe/kdebackend.hxx deleted file mode 100644 index 23e8d148bb33..000000000000 --- a/shell/source/backends/kdebe/kdebackend.hxx +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef KDEBACKEND_HXX_ -#define KDEBACKEND_HXX_ - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XSCHEMASUPPLIER_HPP_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#endif -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> -#include <com/sun/star/configuration/backend/CannotConnectException.hpp> -#include <cppuhelper/compbase2.hxx> - -#ifndef INCLUDED_MAP -#include <map> -#define INCLUDED_MAP -#endif - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - - -//------------------------------------------------------------------------------ -typedef cppu::WeakComponentImplHelper2<backend::XSingleLayerStratum, - lang::XServiceInfo> BackendBase ; - -/** - Implements the SingleLayerStratum service for KDE access. - */ -class KDEBackend : public BackendBase { - public : - - static KDEBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); - - // XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName( ) - 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) ; - - /** - Provides the implementation name. - - @return implementation name - */ - static rtl::OUString SAL_CALL getBackendName(void) ; - - /** - Provides the supported services names - - @return service names - */ - static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ; - - //XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL - 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) ; - - protected: - /** - Service constructor from a service factory. - - @param xContext component context - */ - KDEBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); - - /** Destructor */ - ~KDEBackend(void) ; - - private: - - /** Build KDE/OO mapping table */ - void initializeMappingTable (); - - - /** The component context */ - uno::Reference<uno::XComponentContext> m_xContext; - - /** Mutex for reOOurces protection */ - osl::Mutex mMutex ; - - static KDEBackend* mInstance; -}; - -#endif // CONFIGMGR_LOCALBE_LOCALSINGLESTRATUM_HXX_ diff --git a/shell/source/backends/kdebe/kdebe.xml b/shell/source/backends/kdebe/kdebe.xml deleted file mode 100644 index edb1beb0698e..000000000000 --- a/shell/source/backends/kdebe/kdebe.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name>kdebe</module-name> - <component-description> - <author> Éric Bischoff </author> - <name>com.sun.star.comp.configuration.backend.KDEBackend</name> - <description> The KDE configuration backend </description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>c++</language> - <status value="beta"/> - <supported-service>com.sun.star.comp.configuration.backend.KDEBackend</supported-service> - <service-dependency>...</service-dependency> - <type>com.sun.star.configuration.backend.XBackendChangesListener</type> - <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> - <type>com.sun.star.configuration.backend.XLayerHandler</type> - <type>com.sun.star.configuration.backend.XSingleLayerStratum</type> - <type>com.sun.star.lang.XMultiComponentFactory</type> - <type>com.sun.star.lang.XServiceInfo</type> - <type>com.sun.star.lang.XSingleComponentFactory</type> - <type>com.sun.star.lang.XTypeProvider</type> - <type>com.sun.star.uno.TypeClass</type> - <type>com.sun.star.uno.XAggregation</type> - <type>com.sun.star.uno.XComponentContext</type> - <type>com.sun.star.uno.XCurrentContext</type> - <type>com.sun.star.uno.XWeak</type> - <type>com.sun.star.registry.XRegistryKey</type> - </component-description> - <project-build-dependency>cppuhelper</project-build-dependency> - <project-build-dependency>cppu</project-build-dependency> - <project-build-dependency>sal</project-build-dependency> - <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency> - <runtime-module-dependency>cppu3</runtime-module-dependency> - <runtime-module-dependency>sal3</runtime-module-dependency> -</module-description> diff --git a/shell/source/backends/kdebe/kdebecdef.cxx b/shell/source/backends/kdebe/kdebecdef.cxx deleted file mode 100644 index 2201a7f27dda..000000000000 --- a/shell/source/backends/kdebe/kdebecdef.cxx +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "kdebackend.hxx" -#include <com/sun/star/registry/XRegistryKey.hpp> - -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include <cppuhelper/implementationentry.hxx> -#endif -#include <com/sun/star/uno/XComponentContext.hpp> -#include "kde_headers.h" - -#include "uno/current_context.hxx" - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -//============================================================================== - -static uno::Reference<uno::XInterface> SAL_CALL createKDEBackend(const uno::Reference<uno::XComponentContext>& xContext) -{ - try { - uno::Reference< uno::XCurrentContext > xCurrentContext(uno::getCurrentContext()); - - if (xCurrentContext.is()) - { - uno::Any aValue = xCurrentContext->getValueByName( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "system.desktop-environment" ) ) ); - - rtl::OUString aDesktopEnvironment; - if ( (aValue >>= aDesktopEnvironment) && (aDesktopEnvironment.equalsAscii("KDE")) && (KApplication::kApplication() != NULL) ) - return * KDEBackend::createInstance(xContext); - } - - return uno::Reference<uno::XInterface>(); - - } catch (uno::RuntimeException e) { - return uno::Reference<uno::XInterface>(); - } - -} - -//============================================================================== - -static const cppu::ImplementationEntry kImplementations_entries[] = -{ - { - createKDEBackend, - KDEBackend::getBackendName, - KDEBackend::getBackendServiceNames, - cppu::createSingleComponentFactory, - NULL, - 0 - }, - { NULL, NULL, NULL, NULL, NULL, 0 } -} ; -//------------------------------------------------------------------------------ - -extern "C" void SAL_CALL component_getImplementationEnvironment( - const sal_Char **aEnvTypeName, - uno_Environment **) { - *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; -} - -//------------------------------------------------------------------------------ - -extern "C" sal_Bool SAL_CALL component_writeInfo(void *, - void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + KDEBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = KDEBackend::getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - return sal_True; - } - - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - - return sal_False; -} - -//------------------------------------------------------------------------------ - -extern "C" void *component_getFactory(const sal_Char *aImplementationName, - void *aServiceManager, - void *aRegistryKey) { - - return cppu::component_getFactoryHelper( - aImplementationName, - aServiceManager, - aRegistryKey, - kImplementations_entries) ; -} -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/kdebe/kdecommonlayer.cxx b/shell/source/backends/kdebe/kdecommonlayer.cxx deleted file mode 100644 index 6e8d0d630e04..000000000000 --- a/shell/source/backends/kdebe/kdecommonlayer.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "kdecommonlayer.hxx" -#include "kde_headers.h" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/uno/Sequence.hxx> - -#define SPACE ' ' - -//============================================================================== - -KDECommonLayer::KDECommonLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDECommonLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(3); - sal_Int32 nProperties = 0; - - // Email client settings - KEMailSettings aEmailSettings; - QString aClientProgram; - ::rtl::OUString sClientProgram; - - aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); - if ( aClientProgram.isEmpty() ) - aClientProgram = "kmail"; - else - aClientProgram = aClientProgram.section(SPACE, 0, 0); - sClientProgram = (const sal_Unicode *) aClientProgram.ucs2(); - - 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( sClientProgram ); - - // Source code font settings - QFont aFixedFont; - QString aFontName; - :: rtl::OUString sFontName; - short nFontHeight; - - aFixedFont = KGlobalSettings::fixedFont(); - aFontName = aFixedFont.family(); - sFontName = (const sal_Unicode *) aFontName.ucs2(); - nFontHeight = aFixedFont.pointSize(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontName") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sFontName ); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontHeight") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "short" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( nFontHeight ); - - if( nProperties > 0 ) - { - aPropInfoList.realloc(nProperties); - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDECommonLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - KEMailSettings aEmailSettings; - QString aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); - aClientProgram = aClientProgram.section(SPACE, 0, 0); - - QString aFixedFont = KGlobalSettings::fixedFont().toString(); - - ::rtl::OUString sTimeStamp, - sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) ); - - sTimeStamp = (const sal_Unicode *) aClientProgram.ucs2(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aFixedFont.ucs2(); - - return sTimeStamp; -} diff --git a/shell/source/backends/kdebe/kdecommonlayer.hxx b/shell/source/backends/kdebe/kdecommonlayer.hxx deleted file mode 100644 index e61661589145..000000000000 --- a/shell/source/backends/kdebe/kdecommonlayer.hxx +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef KDECOMMONLAYER_HXX_ -#define KDECOMMONLAYER_HXX_ - -#include "kdebackend.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.Office.Common configuration component. - */ -class KDECommonLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDECommonLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDECommonLayer(void) {} - - private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - } ; - -#endif // KDECOMMONLAYER diff --git a/shell/source/backends/kdebe/kdeinetlayer.cxx b/shell/source/backends/kdebe/kdeinetlayer.cxx deleted file mode 100644 index 231204191663..000000000000 --- a/shell/source/backends/kdebe/kdeinetlayer.cxx +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "kdeinetlayer.hxx" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/uno/Sequence.hxx> - -#define COMMA ',' -#define SEMI_COLON ';' - -//============================================================================== - -KDEInetLayer::KDEInetLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDEInetLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(8); - sal_Int32 nProperties = 0; - - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - setProxy(aPropInfoList, nProperties, 1, - KProtocolManager::noProxyFor(), - KProtocolManager::proxyFor( "HTTP" ), - KProtocolManager::proxyFor( "FTP" ), - KProtocolManager::proxyFor( "HTTPS" )); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - setProxy(aPropInfoList, nProperties, 1, - KProtocolManager::noProxyFor(), - KProtocolManager::proxyForURL( "http://www.openoffice.org" ), - KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" ), - KProtocolManager::proxyForURL( "https://www.openoffice.org" )); - break; - default: // No proxy is used - setProxy(aPropInfoList, nProperties, 0); - } - - if ( nProperties > 0 ) - { - aPropInfoList.realloc(nProperties); - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDEInetLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - QString aProxyType, aNoProxyFor, aHTTPProxy, aHTTPSProxy, aFTPProxy; - - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: - aProxyType = '1'; - aNoProxyFor = KProtocolManager::noProxyFor(); - aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); - aHTTPProxy = KProtocolManager::proxyFor( "HTTPS" ); - aFTPProxy = KProtocolManager::proxyFor( "FTP" ); - break; - case KProtocolManager::PACProxy: - case KProtocolManager::WPADProxy: - case KProtocolManager::EnvVarProxy: - aProxyType = '1'; - aNoProxyFor = KProtocolManager::noProxyFor(); - aHTTPProxy = KProtocolManager::proxyForURL( "http://www.openoffice.org" ); - aHTTPSProxy = KProtocolManager::proxyForURL( "https://www.openoffice.org" ); - aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" ); - break; - default: - aProxyType = '0'; - } - - ::rtl::OUString sTimeStamp, - sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) ); - - sTimeStamp = (const sal_Unicode *) aProxyType.ucs2(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aNoProxyFor.ucs2(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aHTTPProxy.ucs2(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aHTTPSProxy.ucs2(); - sTimeStamp += sep; - sTimeStamp += (const sal_Unicode *) aFTPProxy.ucs2(); - - return sTimeStamp; -} - -//------------------------------------------------------------------------------ - -void SAL_CALL KDEInetLayer::setProxy - (uno::Sequence<backend::PropertyInfo> &aPropInfoList, sal_Int32 &nProperties, - int nProxyType, const QString &aNoProxy, const QString &aHTTPProxy, const QString &aFTPProxy, const QString &aHTTPSProxy ) const -{ - 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) nProxyType ); - - if (nProxyType == 0) return; - - if ( !aNoProxy.isEmpty() ) - { - QString aNoProxyFor(aNoProxy); - ::rtl::OUString sNoProxyFor; - - aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON ); - sNoProxyFor = (const sal_Unicode *) aNoProxyFor.ucs2(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetNoProxy") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sNoProxyFor ); - } - - if ( !aHTTPProxy.isEmpty() ) - { - KURL aProxy(aHTTPProxy); - ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2(); - sal_Int32 nPort = aProxy.port(); - - 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( sProxy ); - - 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( nPort ); - } - - if ( !aHTTPSProxy.isEmpty() ) - { - KURL aProxy(aHTTPSProxy); - ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2(); - sal_Int32 nPort = aProxy.port(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyName") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sProxy ); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyPort") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "int" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( nPort ); - } - - if ( !aFTPProxy.isEmpty() ) - { - KURL aProxy(aFTPProxy); - ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2(); - sal_Int32 nPort = aProxy.port(); - - 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( sProxy ); - - 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( nPort ); - } -} - diff --git a/shell/source/backends/kdebe/kdeinetlayer.hxx b/shell/source/backends/kdebe/kdeinetlayer.hxx deleted file mode 100755 index 1a7427b1cb2c..000000000000 --- a/shell/source/backends/kdebe/kdeinetlayer.hxx +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef KDEINETLAYER_HXX_ -#define KDEINETLAYER_HXX_ - -#include "kdebackend.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> -#include <kde_headers.h> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.Inet configuration component. - */ -class KDEInetLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDEInetLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDEInetLayer(void) {} - -private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - - void SAL_CALL setProxy - (uno::Sequence<backend::PropertyInfo> &aPropInfoList, sal_Int32 &nProperties, - int nProxyType, const QString &aNoProxyfor = QString(), - const QString &aHTTPProxy = QString(), const QString &aFTPProxy = QString(), const QString &aHTTPSProxy = QString()) const; - } ; - -#endif // KDEINETLAYER diff --git a/shell/source/backends/kdebe/kdepathslayer.cxx b/shell/source/backends/kdebe/kdepathslayer.cxx deleted file mode 100644 index 29d779cfdfc1..000000000000 --- a/shell/source/backends/kdebe/kdepathslayer.cxx +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "kdepathslayer.hxx" -#include "kde_headers.h" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <osl/security.hxx> -#include <osl/file.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -#define SPACE ' ' - -//============================================================================== - -KDEPathsLayer::KDEPathsLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDEPathsLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(1); - sal_Int32 nProperties = 0; - - QString aDocumentsDir( KGlobalSettings::documentPath() ); - rtl::OUString sDocumentsDir; - rtl::OUString sDocumentsURL; - if ( aDocumentsDir.endsWith(QChar('/')) ) - aDocumentsDir.truncate ( aDocumentsDir.length() - 1 ); - sDocumentsDir = (const sal_Unicode *) aDocumentsDir.ucs2(); - osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData ); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Paths/Variables/Work") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( sDocumentsURL ); - - if( nProperties > 0 ) - { - aPropInfoList.realloc(nProperties); - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDEPathsLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - ::rtl::OUString sTimeStamp, - sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) ); - - QString aDocumentsDir; - aDocumentsDir = KGlobalSettings::documentPath(); - - sTimeStamp += (const sal_Unicode *) aDocumentsDir.ucs2(); - - return sTimeStamp; -} diff --git a/shell/source/backends/kdebe/kdepathslayer.hxx b/shell/source/backends/kdebe/kdepathslayer.hxx deleted file mode 100644 index 5ee289aeb68a..000000000000 --- a/shell/source/backends/kdebe/kdepathslayer.hxx +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef KDEPATHSLAYER_HXX_ -#define KDEPATHSLAYER_HXX_ - -#include "kdebackend.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.Office.Paths configuration component. - */ -class KDEPathsLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDEPathsLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDEPathsLayer(void) {} - - private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - } ; - -#endif // KDEPATHSLAYER diff --git a/shell/source/backends/kdebe/kdevcllayer.cxx b/shell/source/backends/kdebe/kdevcllayer.cxx deleted file mode 100644 index 3fa08b46ff33..000000000000 --- a/shell/source/backends/kdebe/kdevcllayer.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "kdevcllayer.hxx" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/uno/Sequence.hxx> -#include "kde_headers.h" - -//============================================================================== - -KDEVCLLayer::KDEVCLLayer(const uno::Reference<uno::XComponentContext>& xContext) -{ - //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 SAL_CALL KDEVCLLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, lang::NullPointerException, - lang::WrappedTargetException, uno::RuntimeException) -{ - if( ! m_xLayerContentDescriber.is() ) - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service" - ) ), static_cast < backend::XLayer * > (this) ); - } - - uno::Sequence<backend::PropertyInfo> aPropInfoList(1); - -/* - Commenting out, does not make much sense without an accessibility bridge -=========================================================================== -#if defined(QT_ACCESSIBILITY_SUPPORT) -// Accessibility tools under Qt for UNIX are available starting with Qt 4.0 - int nVersionMajor = 0; - const char *q = qVersion(); // "3.1.0" for example - while ('0' <= *q && *q <= '9') - nVersionMajor = nVersionMajor * 10 + *q++ - '0'; - sal_Bool ATToolSupport = (sal_Bool) (nVersionMajor >= 4); -#else - sal_Bool ATToolSupport = sal_False; -#endif -=========================================================================== - End of commented out section -*/ sal_Bool ATToolSupport = sal_False; - - aPropInfoList[0].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.VCL/Settings/Accessibility/EnableATToolSupport") ); - aPropInfoList[0].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value = uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ); - - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL KDEVCLLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // Return the value as timestamp to avoid regenerating the binary cache - // on each office launch. - - ::rtl::OUString sTimeStamp( - RTL_CONSTASCII_USTRINGPARAM( "FALSE" ) ); - - return sTimeStamp; -} diff --git a/shell/source/backends/kdebe/kdevcllayer.hxx b/shell/source/backends/kdebe/kdevcllayer.hxx deleted file mode 100644 index 4b3a50e5c4c8..000000000000 --- a/shell/source/backends/kdebe/kdevcllayer.hxx +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef KDEVCLLAYER_HXX_ -#define KDEVCLLAYER_HXX_ - -#include "kdebackend.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interface for the KDE values mapped into - the org.openoffice.VCL configuration component. - */ -class KDEVCLLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - KDEVCLLayer(const uno::Reference<uno::XComponentContext>& xContext); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - protected: - - /** Destructor */ - ~KDEVCLLayer(void) {} - - private : - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - } ; - -#endif // KDEVCLLAYER diff --git a/shell/source/backends/kdebe/makefile.mk b/shell/source/backends/kdebe/makefile.mk index 7bf8d53568b5..b63e2332624f 100644 --- a/shell/source/backends/kdebe/makefile.mk +++ b/shell/source/backends/kdebe/makefile.mk @@ -31,11 +31,7 @@ TARGET=kdebe LIBTARGET=NO ENABLE_EXCEPTIONS=TRUE - -COMP1TYPELIST=$(TARGET) -COMPRDB=$(SOLARBINDIR)$/types.rdb -UNOUCROUT=$(OUT)$/inc$/$(TARGET) -INCPRE=$(UNOUCROUT) +VISIBILITY_HIDDEN=TRUE # --- Settings --- @@ -60,12 +56,8 @@ CFLAGS+=$(KDE_CFLAGS) # --- Files --- SLOFILES=\ - $(SLO)$/kdebackend.obj \ - $(SLO)$/kdecommonlayer.obj \ - $(SLO)$/kdeinetlayer.obj \ - $(SLO)$/kdevcllayer.obj \ - $(SLO)$/kdepathslayer.obj \ - $(SLO)$/kdebecdef.obj + $(SLO)$/kdeaccess.obj \ + $(SLO)$/kdebackend.obj SHL1NOCHECK=TRUE SHL1TARGET=$(TARGET)1.uno @@ -77,9 +69,8 @@ SHL1LINKFLAGS+=$(KDE_LIBS) -lkio SHL1STDLIBS= \ $(CPPUHELPERLIB) \ $(CPPULIB) \ - $(SALLIB) - -SHL1VERSIONMAP=exports.map + $(SALLIB) \ + SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME=$(SHL1TARGET) diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx index c67d4f836d9e..1335d4a7fa50 100644 --- a/shell/source/backends/localebe/localebackend.cxx +++ b/shell/source/backends/localebe/localebackend.cxx @@ -29,9 +29,7 @@ #include "precompiled_shell.hxx" #include "localebackend.hxx" -#include "localelayer.hxx" -#include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp> -#include <uno/current_context.hxx> +#include <com/sun/star/beans/Optional.hpp> #include <osl/time.h> #include <stdio.h> @@ -226,11 +224,7 @@ rtl::OUString ImplGetLocale(LCID lcid) // ------------------------------------------------------------------------------- -LocaleBackend::LocaleBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException) : - ::cppu::WeakImplHelper2 < backend::XSingleLayerStratum, lang::XServiceInfo > (), - m_xContext(xContext) - +LocaleBackend::LocaleBackend() { } @@ -242,11 +236,9 @@ LocaleBackend::~LocaleBackend(void) //------------------------------------------------------------------------------ -LocaleBackend* LocaleBackend::createInstance( - const uno::Reference<uno::XComponentContext>& xContext -) +LocaleBackend* LocaleBackend::createInstance() { - return new LocaleBackend(xContext); + return new LocaleBackend; } // --------------------------------------------------------------------------------------- @@ -288,61 +280,45 @@ rtl::OUString LocaleBackend::getSystemLocale(void) } //------------------------------------------------------------------------------ -rtl::OUString LocaleBackend::createTimeStamp() +void LocaleBackend::setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - // the time stamp is free text, so just returning the values here. - return getLocale() + getUILocale() + getSystemLocale(); + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); } -//------------------------------------------------------------------------------ - -uno::Reference<backend::XLayer> SAL_CALL LocaleBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException) +css::uno::Any LocaleBackend::getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - - uno::Sequence<rtl::OUString> aComps( getSupportedComponents() ); - if( aComponent.equals( aComps[0]) ) + if (PropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Locale"))) { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, css::uno::makeAny(getLocale()))); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SystemLocale"))) { - if( ! m_xSystemLayer.is() ) - { - uno::Sequence<backend::PropertyInfo> aPropInfoList(3); - - aPropInfoList[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.System/L10N/UILocale") ); - aPropInfoList[0].Type = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value = uno::makeAny( getUILocale() ); - - aPropInfoList[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.System/L10N/Locale") ); - aPropInfoList[1].Type = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" )); - aPropInfoList[1].Protected = sal_False; - aPropInfoList[1].Value = uno::makeAny( getLocale() ); - - aPropInfoList[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.System/L10N/SystemLocale") ); - aPropInfoList[2].Type = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" )); - aPropInfoList[2].Protected = sal_False; - aPropInfoList[2].Value = uno::makeAny( getSystemLocale() ); - - m_xSystemLayer = new LocaleLayer(aPropInfoList, createTimeStamp(), m_xContext); - } - - return m_xSystemLayer; + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, css::uno::makeAny(getSystemLocale()))); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("UILocale"))) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, css::uno::makeAny(getUILocale()))); + } else { + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); } - - return uno::Reference<backend::XLayer>(); -} - -//------------------------------------------------------------------------------ - -uno::Reference<backend::XUpdatableLayer> SAL_CALL -LocaleBackend::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) -{ - throw lang::NoSupportException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "LocaleBackend: No Update Operation allowed, Read Only access") ), - *this) ; } //------------------------------------------------------------------------------ @@ -363,10 +339,8 @@ rtl::OUString SAL_CALL LocaleBackend::getImplementationName(void) uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getBackendServiceNames(void) { - uno::Sequence<rtl::OUString> aServiceNameList(2); + uno::Sequence<rtl::OUString> aServiceNameList(1); aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.LocaleBackend")) ; - aServiceNameList[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; - return aServiceNameList ; } @@ -391,16 +365,3 @@ uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getSupportedServiceNames(vo { return getBackendServiceNames() ; } - -// --------------------------------------------------------------------------------------- - -uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getSupportedComponents(void) -{ - uno::Sequence<rtl::OUString> aSupportedComponentList(1); - aSupportedComponentList[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.System" ) - ); - - return aSupportedComponentList; -} - diff --git a/shell/source/backends/localebe/localebackend.hxx b/shell/source/backends/localebe/localebackend.hxx index bfb89c6d06da..29950a3df913 100644 --- a/shell/source/backends/localebe/localebackend.hxx +++ b/shell/source/backends/localebe/localebackend.hxx @@ -28,10 +28,8 @@ #ifndef _FIXEDVALUEBACKEND_HXX_ #define _FIXEDVALUEBACKEND_HXX_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp> #include <cppuhelper/implbase2.hxx> #include <rtl/string.hxx> @@ -39,19 +37,14 @@ namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -/** - Implements the SingleLayerStratum service. - */ class LocaleBackend : public ::cppu::WeakImplHelper2 < - backend::XSingleLayerStratum, + css::beans::XPropertySet, lang::XServiceInfo > { public : - static LocaleBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); + static LocaleBackend* createInstance(); // XServiceInfo virtual rtl::OUString SAL_CALL @@ -78,45 +71,70 @@ class LocaleBackend : public ::cppu::WeakImplHelper2 < @return service names */ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ; - /** - Provides the supported component nodes - - @return supported component nodes - */ - static uno::Sequence<rtl::OUString> SAL_CALL getSupportedComponents(void) ; - - //XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL - 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) ; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } + + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + protected: /** Service constructor from a service factory. @param xContext component context */ - LocaleBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); + LocaleBackend(); /** Destructor */ ~LocaleBackend(void) ; private: - - uno::Reference<uno::XComponentContext> m_xContext ; - uno::Reference<backend::XLayer> m_xSystemLayer ; - - // Returns a time stamp in the appropriate format - // for configuration layers. - static rtl::OUString createTimeStamp(void); - // Returns the user locale static rtl::OUString getLocale(void); diff --git a/shell/source/backends/localebe/localebe.xml b/shell/source/backends/localebe/localebe.xml index fb6823b43a05..3c22a4970881 100644 --- a/shell/source/backends/localebe/localebe.xml +++ b/shell/source/backends/localebe/localebe.xml @@ -10,7 +10,6 @@ <language>c++</language> <status value="beta"/> <supported-service>com.sun.star.comp.configuration.backend.LocaleBackend</supported-service> - <supported-service>com.sun.star.comp.configuration.backend.PlatformBackend</supported-service> <service-dependency>...</service-dependency> <type>com.sun.star.configuration.backend.XBackendChangesListener</type> <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> diff --git a/shell/source/backends/localebe/localebecdef.cxx b/shell/source/backends/localebe/localebecdef.cxx index e5ff65318200..576501e4da9f 100644 --- a/shell/source/backends/localebe/localebecdef.cxx +++ b/shell/source/backends/localebe/localebecdef.cxx @@ -29,7 +29,6 @@ #include "precompiled_shell.hxx" #include <localebackend.hxx> -#include <com/sun/star/registry/XRegistryKey.hpp> #ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ #include <cppuhelper/implementationentry.hxx> @@ -39,14 +38,13 @@ namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace backend = css::configuration::backend ; //------------------------------------------------------------------------------ static uno::Reference<uno::XInterface> SAL_CALL createLocaleBackend( - const uno::Reference<uno::XComponentContext>& xContext){ + const uno::Reference<uno::XComponentContext>&){ - return * LocaleBackend::createInstance(xContext); + return * LocaleBackend::createInstance(); } //------------------------------------------------------------------------------ @@ -74,41 +72,9 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( //------------------------------------------------------------------------------ -extern "C" sal_Bool SAL_CALL component_writeInfo(void * /*pServiceManager*/, void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + LocaleBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = LocaleBackend::getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - // Register supported components - uno::Reference<XRegistryKey> xComponentKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/DATA/SupportedComponents") ) - ); - - xComponentKey->setAsciiListValue( LocaleBackend::getSupportedComponents() ); - - return sal_True; - } - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - return sal_False; +extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) { + return cppu::component_writeInfoHelper( + pServiceManager, pRegistryKey, kImplementations_entries); } //------------------------------------------------------------------------------ diff --git a/shell/source/backends/localebe/localelayer.cxx b/shell/source/backends/localebe/localelayer.cxx deleted file mode 100644 index a353478ac836..000000000000 --- a/shell/source/backends/localebe/localelayer.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "localelayer.hxx" - -//------------------------------------------------------------------------------ - -LocaleLayer::LocaleLayer( const uno::Sequence<backend::PropertyInfo>& aPropInfoList, - const rtl::OUString& aTimestamp, - const uno::Reference<uno::XComponentContext>& xContext) - : m_aTimestamp(aTimestamp), m_aPropInfoList(aPropInfoList) -{ - //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 SAL_CALL LocaleLayer::readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - - if (m_xLayerContentDescriber.is()) - { - m_xLayerContentDescriber->describeLayer(xHandler, m_aPropInfoList); - } - else - { - OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL LocaleLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - return m_aTimestamp; -} - -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/localebe/localelayer.hxx b/shell/source/backends/localebe/localelayer.hxx deleted file mode 100644 index 69b305079d33..000000000000 --- a/shell/source/backends/localebe/localelayer.hxx +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _LOCALELAYER_HXX_ -#define _LOCALELAYER_HXX_ - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <cppuhelper/implbase2.hxx> - - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interfaces for fixed values - */ - -class LocaleLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ - public : - /** - Constructor given the requested component name - - @param aPropInfoListyMap Gconf->OO key map - @param aCompoentName Requested Component Name - @param sTimestamp timestamp indicating last modifictaion - */ - LocaleLayer(const uno::Sequence<backend::PropertyInfo>& aPropInfoList, - const rtl::OUString& aTimestamp, - const uno::Reference<uno::XComponentContext>& xContext); - - /** Destructor */ - ~LocaleLayer(void) {} - - // XLayer - virtual void SAL_CALL readData(const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - private : - - rtl::OUString m_aTimestamp ; - rtl::OUString m_aComponent ; - - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - uno::Sequence<backend::PropertyInfo> m_aPropInfoList ; -} ; - -#endif // _LOCALELAYER_HXX_ diff --git a/shell/source/backends/localebe/makefile.mk b/shell/source/backends/localebe/makefile.mk index 51a95344aa1f..8a05be4cb351 100644 --- a/shell/source/backends/localebe/makefile.mk +++ b/shell/source/backends/localebe/makefile.mk @@ -45,9 +45,8 @@ DLLPRE = SLOFILES=\ $(SLO)$/localebecdef.obj \ - $(SLO)$/localebackend.obj \ - $(SLO)$/localelayer.obj - + $(SLO)$/localebackend.obj + SHL1TARGET=$(TARGET)1.uno SHL1OBJS=$(SLOFILES) SHL1DEF=$(MISC)$/$(SHL1TARGET).def diff --git a/shell/source/backends/macbe/macbackend.cxx b/shell/source/backends/macbe/macbackend.cxx index 499696cea54c..b07afb2e6701 100644 --- a/shell/source/backends/macbe/macbackend.cxx +++ b/shell/source/backends/macbe/macbackend.cxx @@ -28,18 +28,140 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_shell.hxx" +// For MAXHOSTNAMELEN constant +#include <sys/param.h> + +#include <premac.h> +#include <SystemConfiguration/SystemConfiguration.h> +#include <Foundation/NSPathUtilities.h> +#include <postmac.h> + #include "macbackend.hxx" -#include "macbelayer.hxx" -#include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp> -#include <uno/current_context.hxx> -#define MACBE_INET_COMPONENT "org.openoffice.Inet" -#define MACBE_PATHS_COMPONENT "org.openoffice.Office.Paths" +#include "com/sun/star/beans/Optional.hpp" +#include "rtl/ustrbuf.hxx" +#include "osl/file.h" + +#define SPACE ' ' +#define SEMI_COLON ';' + +typedef struct +{ + rtl::OUString Server; + sal_Int32 Port; +} ProxyEntry; + +typedef enum { + sHTTP, + sHTTPS, + sFTP +} ServiceType; + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace // private +{ + +/* + * Returns current proxy settings for selected service type (HTTP or + * FTP) as a C string (in the buffer specified by host and hostSize) + * and a port number. + */ + +bool GetProxySetting(ServiceType sType, char *host, size_t hostSize, UInt16 *port) +{ + bool result; + CFDictionaryRef proxyDict; + CFNumberRef enableNum; + int enable; + CFStringRef hostStr; + CFNumberRef portNum; + int portInt; + + proxyDict = SCDynamicStoreCopyProxies(NULL); + + if (!proxyDict) + return false; + + CFStringRef proxiesEnable; + CFStringRef proxiesProxy; + CFStringRef proxiesPort; + + switch ( sType ) + { + case sHTTP : proxiesEnable = kSCPropNetProxiesHTTPEnable; + proxiesProxy = kSCPropNetProxiesHTTPProxy; + proxiesPort = kSCPropNetProxiesHTTPPort; + break; + case sHTTPS: proxiesEnable = kSCPropNetProxiesHTTPSEnable; + proxiesProxy = kSCPropNetProxiesHTTPSProxy; + proxiesPort = kSCPropNetProxiesHTTPSPort; + break; + default: proxiesEnable = kSCPropNetProxiesFTPEnable; + proxiesProxy = kSCPropNetProxiesFTPProxy; + proxiesPort = kSCPropNetProxiesFTPPort; + break; + } + // Proxy enabled? + enableNum = (CFNumberRef) CFDictionaryGetValue( proxyDict, + proxiesEnable ); + + result = (enableNum != NULL) && (CFGetTypeID(enableNum) == CFNumberGetTypeID()); + + if (result) + result = CFNumberGetValue(enableNum, kCFNumberIntType, &enable) && (enable != 0); + + // Proxy enabled -> get hostname + if (result) + { + hostStr = (CFStringRef) CFDictionaryGetValue( proxyDict, + proxiesProxy ); + + result = (hostStr != NULL) && (CFGetTypeID(hostStr) == CFStringGetTypeID()); + } + + if (result) + result = CFStringGetCString(hostStr, host, (CFIndex) hostSize, kCFStringEncodingASCII); + + // Get proxy port + if (result) + { + portNum = (CFNumberRef) CFDictionaryGetValue( proxyDict, + proxiesPort ); + + result = (portNum != NULL) && (CFGetTypeID(portNum) == CFNumberGetTypeID()); + } + else + { + CFRelease(proxyDict); + return false; + } + + if (result) + result = CFNumberGetValue(portNum, kCFNumberIntType, &portInt); + + if (result) + *port = (UInt16) portInt; + + if (proxyDict) + CFRelease(proxyDict); + + if (!result) + { + *host = 0; + *port = 0; + } + + return result; +} -MacOSXBackend::MacOSXBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException) : - ::cppu::WeakImplHelper2 < backend::XSingleLayerStratum, lang::XServiceInfo > (), - m_xContext(xContext) +} // end private namespace + +//------------------------------------------------------------------------------ + +MacOSXBackend::MacOSXBackend() { } @@ -51,46 +173,282 @@ MacOSXBackend::~MacOSXBackend(void) //------------------------------------------------------------------------------ -MacOSXBackend* MacOSXBackend::createInstance(const uno::Reference<uno::XComponentContext>& xContext) +MacOSXBackend* MacOSXBackend::createInstance() { - return new MacOSXBackend(xContext); + return new MacOSXBackend; } // --------------------------------------------------------------------------------------- -uno::Reference<backend::XLayer> SAL_CALL MacOSXBackend::getLayer(const rtl::OUString& aComponent, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException) -{ - if( aComponent.equalsAscii( MACBE_INET_COMPONENT ) ) - { - if( ! m_xSystemLayer.is() ) - m_xSystemLayer = new MacOSXLayer( m_xContext ); +rtl::OUString CFStringToOUString(const CFStringRef sOrig) { + CFRetain(sOrig); - return m_xSystemLayer; - } - else if( aComponent.equalsAscii( MACBE_PATHS_COMPONENT ) ) - { - if( ! m_xPathLayer.is() ) - m_xPathLayer = new MacOSXPathLayer( m_xContext ); - return m_xPathLayer; - } + CFIndex nStringLen = CFStringGetLength(sOrig)+1; + + // Allocate a c string buffer + char sBuffer[nStringLen]; + + CFStringGetCString(sOrig, sBuffer, nStringLen, kCFStringEncodingASCII); + + CFRelease(sOrig); - return uno::Reference<backend::XLayer>(); + return rtl::OUString::createFromAscii((sal_Char*)sBuffer); } -//------------------------------------------------------------------------------ +rtl::OUString GetOUString( NSString* pStr ) +{ + if( ! pStr ) + return rtl::OUString(); + int nLen = [pStr length]; + if( nLen == 0 ) + return rtl::OUString(); + + rtl::OUStringBuffer aBuf( nLen+1 ); + aBuf.setLength( nLen ); + [pStr getCharacters: const_cast<sal_Unicode*>(aBuf.getStr())]; + return aBuf.makeStringAndClear(); +} -uno::Reference<backend::XUpdatableLayer> SAL_CALL - MacOSXBackend::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) +void MacOSXBackend::setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - throw lang::NoSupportException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "MacOSXBackend: No Update Operation allowed, Read Only access") ), - *this); + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); +} - return NULL; +css::uno::Any MacOSXBackend::getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WorkPathVariable"))) + { + rtl::OUString aDocDir; + NSArray* pPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, true ); + if( pPaths && [pPaths count] > 0 ) + { + aDocDir = GetOUString( [pPaths objectAtIndex: 0] ); + + rtl::OUString aDocURL; + if( aDocDir.getLength() > 0 && + osl_getFileURLFromSystemPath( aDocDir.pData, &aDocURL.pData ) == osl_File_E_None ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, css::uno::makeAny( aDocURL ) ) ); + } + else + { + OSL_TRACE( "user documents list contains empty file path or conversion failed" ); + } + } + else + { + OSL_TRACE( "Got nil or empty list of user document directories" ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName"))) + { + ProxyEntry aFtpProxy; + + char host[MAXHOSTNAMELEN]; + UInt16 port; + bool retVal; + + retVal = GetProxySetting(sFTP, host, 100, &port); + + if (retVal) + { + aFtpProxy.Server = rtl::OUString::createFromAscii( host ); + } + + // ftp proxy name + if( aFtpProxy.Server.getLength() > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( aFtpProxy.Server ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort"))) + { + ProxyEntry aFtpProxy; + + char host[MAXHOSTNAMELEN]; + UInt16 port; + bool retVal; + + retVal = GetProxySetting(sFTP, host, 100, &port); + + if (retVal) + { + aFtpProxy.Port = port; + } + + // ftp proxy port + if( aFtpProxy.Port > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( aFtpProxy.Port ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName"))) + { + ProxyEntry aHttpProxy; + + char host[MAXHOSTNAMELEN]; + UInt16 port; + bool retVal; + + retVal = GetProxySetting(sHTTP, host, 100, &port); + + if (retVal) + { + aHttpProxy.Server = rtl::OUString::createFromAscii( host ); + } + + // http proxy name + if( aHttpProxy.Server.getLength() > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( aHttpProxy.Server ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort"))) + { + ProxyEntry aHttpProxy; + + char host[MAXHOSTNAMELEN]; + UInt16 port; + bool retVal; + + retVal = GetProxySetting(sHTTP, host, 100, &port); + + if (retVal) + { + aHttpProxy.Port = port; + } + + // http proxy port + if( aHttpProxy.Port > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( aHttpProxy.Port ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName"))) + { + ProxyEntry aHttpsProxy; + + char host[MAXHOSTNAMELEN]; + UInt16 port; + bool retVal; + + retVal = GetProxySetting(sHTTPS, host, 100, &port); + + if (retVal) + { + aHttpsProxy.Server = rtl::OUString::createFromAscii( host ); + } + + // https proxy name + if( aHttpsProxy.Server.getLength() > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( aHttpsProxy.Server ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort"))) + { + ProxyEntry aHttpsProxy; + + char host[MAXHOSTNAMELEN]; + UInt16 port; + bool retVal; + + retVal = GetProxySetting(sHTTPS, host, 100, &port); + + if (retVal) + { + aHttpsProxy.Port = port; + } + + // https proxy port + if( aHttpsProxy.Port > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( aHttpsProxy.Port ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) + { + // override default for ProxyType, which is "0" meaning "No proxies". + sal_Int32 nProperties = 1; + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, uno::makeAny( nProperties ) ) ); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) + { + rtl::OUString aProxyBypassList; + + CFArrayRef rExceptionsList; + CFDictionaryRef rProxyDict = SCDynamicStoreCopyProxies(NULL); + + if (!rProxyDict) + rExceptionsList = false; + else + rExceptionsList = (CFArrayRef) CFDictionaryGetValue(rProxyDict, kSCPropNetProxiesExceptionsList); + + if (rExceptionsList) + { + for (CFIndex idx = 0; idx < CFArrayGetCount(rExceptionsList); idx++) + { + CFStringRef rException = (CFStringRef) CFArrayGetValueAtIndex(rExceptionsList, idx); + + if (idx>0) + aProxyBypassList += rtl::OUString::createFromAscii( ";" ); + + aProxyBypassList += CFStringToOUString(rException); + } + } + + if (rProxyDict) + CFRelease(rProxyDict); + + // fill proxy bypass list + if( aProxyBypassList.getLength() > 0 ) + { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, + uno::makeAny( aProxyBypassList.replace( SPACE, SEMI_COLON ) ) ) ); + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); + } else { + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); + } } //------------------------------------------------------------------------------ @@ -112,9 +470,8 @@ rtl::OUString SAL_CALL MacOSXBackend::getImplementationName(void) uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getBackendServiceNames(void) { - uno::Sequence<rtl::OUString> aServiceNameList(2); + uno::Sequence<rtl::OUString> aServiceNameList(1); aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.MacOSXBackend")); - aServiceNameList[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")); return aServiceNameList; } @@ -140,15 +497,3 @@ uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getSupportedServiceNames(vo { return getBackendServiceNames(); } - -// --------------------------------------------------------------------------------------- - -uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getSupportedComponents(void) -{ - uno::Sequence<rtl::OUString> aSupportedComponentList(2); - aSupportedComponentList[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( MACBE_INET_COMPONENT ) ); - aSupportedComponentList[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( MACBE_PATHS_COMPONENT ) ); - - return aSupportedComponentList; -} - diff --git a/shell/source/backends/macbe/macbackend.hxx b/shell/source/backends/macbe/macbackend.hxx index 5c477d1a73e5..de4f9eee1ff6 100644 --- a/shell/source/backends/macbe/macbackend.hxx +++ b/shell/source/backends/macbe/macbackend.hxx @@ -28,10 +28,8 @@ #ifndef _MACBACKEND_HXX_ #define _MACBACKEND_HXX_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp> #include <cppuhelper/implbase2.hxx> #include <rtl/string.hxx> @@ -41,18 +39,13 @@ namespace css = com::sun::star; namespace uno = css::uno; namespace lang = css::lang; -namespace backend = css::configuration::backend; - -/** - Implements the SingleLayerStratum service. - */ -class MacOSXBackend : public ::cppu::WeakImplHelper2 <backend::XSingleLayerStratum, lang::XServiceInfo > +class MacOSXBackend : public ::cppu::WeakImplHelper2 <css::beans::XPropertySet, lang::XServiceInfo > { public: - static MacOSXBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); + static MacOSXBackend* createInstance(); // XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() @@ -78,19 +71,56 @@ public: */ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void); - /** - Provides the supported component nodes - - @return supported component nodes - */ - static uno::Sequence<rtl::OUString> SAL_CALL getSupportedComponents(void); - - // XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL 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); + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } + + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} protected: @@ -99,18 +129,10 @@ protected: @param xContext component context */ - MacOSXBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); + MacOSXBackend(); /** Destructor */ ~MacOSXBackend(void); - -private: - - uno::Reference<uno::XComponentContext> m_xContext; - uno::Reference<backend::XLayer> m_xSystemLayer; - uno::Reference<backend::XLayer> m_xPathLayer; - }; #endif // _MACBACKEND_HXX_ diff --git a/shell/source/backends/macbe/macbe.xml b/shell/source/backends/macbe/macbe.xml index 85854250cfe3..7cee5bb14de5 100644 --- a/shell/source/backends/macbe/macbe.xml +++ b/shell/source/backends/macbe/macbe.xml @@ -10,7 +10,6 @@ <language>c++</language> <status value="beta"/> <supported-service>com.sun.star.comp.configuration.backend.MacOSXBackend</supported-service> - <supported-service>com.sun.star.comp.configuration.backend.PlatformBackend</supported-service> <service-dependency>...</service-dependency> <type>com.sun.star.configuration.backend.XBackendChangesListener</type> <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> diff --git a/shell/source/backends/macbe/macbecdef.cxx b/shell/source/backends/macbe/macbecdef.cxx index 82fae97dbdbe..18cf2806c16b 100644 --- a/shell/source/backends/macbe/macbecdef.cxx +++ b/shell/source/backends/macbe/macbecdef.cxx @@ -39,14 +39,13 @@ namespace css = com::sun::star; namespace uno = css::uno; namespace lang = css::lang; -namespace backend = css::configuration::backend; //------------------------------------------------------------------------------ static uno::Reference<uno::XInterface> SAL_CALL createMacOSXBackend( - const uno::Reference<uno::XComponentContext>& xContext) + const uno::Reference<uno::XComponentContext>&) { - return * MacOSXBackend::createInstance(xContext); + return * MacOSXBackend::createInstance(); } //------------------------------------------------------------------------------ @@ -74,41 +73,9 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( //------------------------------------------------------------------------------ -extern "C" sal_Bool SAL_CALL component_writeInfo(void * /*pServiceManager*/, void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + MacOSXBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = MacOSXBackend::getBackendServiceNames(); - for (sal_Int32 i = 0; i < sServiceNames.getLength(); ++ i) - xServicesKey->createKey(sServiceNames[i]); - - // Register supported components - uno::Reference<XRegistryKey> xComponentKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/DATA/SupportedComponents") ) - ); - - xComponentKey->setAsciiListValue( MacOSXBackend::getSupportedComponents() ); - - return sal_True; - } - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - return sal_False; +extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) { + return cppu::component_writeInfoHelper( + pServiceManager, pRegistryKey, kImplementations_entries); } //------------------------------------------------------------------------------ diff --git a/shell/source/backends/macbe/macbelayer.cxx b/shell/source/backends/macbe/macbelayer.cxx deleted file mode 100644 index 113f7f964f54..000000000000 --- a/shell/source/backends/macbe/macbelayer.cxx +++ /dev/null @@ -1,440 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -// For MAXHOSTNAMELEN constant -#include <sys/param.h> - -#include <premac.h> -#include <SystemConfiguration/SystemConfiguration.h> -#include <Foundation/NSPathUtilities.h> -#include <postmac.h> - -#include "macbelayer.hxx" - -#include "rtl/ustrbuf.hxx" -#include "osl/file.h" - -#define SPACE ' ' -#define SEMI_COLON ';' - -typedef struct -{ - rtl::OUString Server; - sal_Int32 Port; -} ProxyEntry; - -typedef enum { - sHTTP, - sHTTPS, - sFTP -} ServiceType; - -//------------------------------------------------------------------------ -// helper functions -//------------------------------------------------------------------------ - -namespace // private -{ - -/* - * Returns current proxy settings for selected service type (HTTP or - * FTP) as a C string (in the buffer specified by host and hostSize) - * and a port number. - */ - -bool GetProxySetting(ServiceType sType, char *host, size_t hostSize, UInt16 *port) -{ - bool result; - CFDictionaryRef proxyDict; - CFNumberRef enableNum; - int enable; - CFStringRef hostStr; - CFNumberRef portNum; - int portInt; - - proxyDict = SCDynamicStoreCopyProxies(NULL); - - if (!proxyDict) - return false; - - CFStringRef proxiesEnable; - CFStringRef proxiesProxy; - CFStringRef proxiesPort; - - switch ( sType ) - { - case sHTTP : proxiesEnable = kSCPropNetProxiesHTTPEnable; - proxiesProxy = kSCPropNetProxiesHTTPProxy; - proxiesPort = kSCPropNetProxiesHTTPPort; - break; - case sHTTPS: proxiesEnable = kSCPropNetProxiesHTTPSEnable; - proxiesProxy = kSCPropNetProxiesHTTPSProxy; - proxiesPort = kSCPropNetProxiesHTTPSPort; - break; - default: proxiesEnable = kSCPropNetProxiesFTPEnable; - proxiesProxy = kSCPropNetProxiesFTPProxy; - proxiesPort = kSCPropNetProxiesFTPPort; - break; - } - // Proxy enabled? - enableNum = (CFNumberRef) CFDictionaryGetValue( proxyDict, - proxiesEnable ); - - result = (enableNum != NULL) && (CFGetTypeID(enableNum) == CFNumberGetTypeID()); - - if (result) - result = CFNumberGetValue(enableNum, kCFNumberIntType, &enable) && (enable != 0); - - // Proxy enabled -> get hostname - if (result) - { - hostStr = (CFStringRef) CFDictionaryGetValue( proxyDict, - proxiesProxy ); - - result = (hostStr != NULL) && (CFGetTypeID(hostStr) == CFStringGetTypeID()); - } - - if (result) - result = CFStringGetCString(hostStr, host, (CFIndex) hostSize, kCFStringEncodingASCII); - - // Get proxy port - if (result) - { - portNum = (CFNumberRef) CFDictionaryGetValue( proxyDict, - proxiesPort ); - - result = (portNum != NULL) && (CFGetTypeID(portNum) == CFNumberGetTypeID()); - } - else - { - CFRelease(proxyDict); - return false; - } - - if (result) - result = CFNumberGetValue(portNum, kCFNumberIntType, &portInt); - - if (result) - *port = (UInt16) portInt; - - if (proxyDict) - CFRelease(proxyDict); - - if (!result) - { - *host = 0; - *port = 0; - } - - return result; -} - -} // end private namespace - -//------------------------------------------------------------------------------ - -MacOSXLayer::MacOSXLayer( const uno::Reference<uno::XComponentContext>& xContext) -{ - //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"); - } - -} - -//------------------------------------------------------------------------------ - -rtl::OUString CFStringToOUString(const CFStringRef sOrig) { - CFRetain(sOrig); - - CFIndex nStringLen = CFStringGetLength(sOrig)+1; - - // Allocate a c string buffer - char sBuffer[nStringLen]; - - CFStringGetCString(sOrig, sBuffer, nStringLen, kCFStringEncodingASCII); - - CFRelease(sOrig); - - return rtl::OUString::createFromAscii((sal_Char*)sBuffer); -} - -void SAL_CALL MacOSXLayer::readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - - if (m_xLayerContentDescriber.is()) - { - rtl::OUString aProxyBypassList; - - CFArrayRef rExceptionsList; - CFDictionaryRef rProxyDict = SCDynamicStoreCopyProxies(NULL); - - if (!rProxyDict) - rExceptionsList = false; - else - rExceptionsList = (CFArrayRef) CFDictionaryGetValue(rProxyDict, kSCPropNetProxiesExceptionsList); - - if (rExceptionsList) - { - for (CFIndex idx = 0; idx < CFArrayGetCount(rExceptionsList); idx++) - { - CFStringRef rException = (CFStringRef) CFArrayGetValueAtIndex(rExceptionsList, idx); - - if (idx>0) - aProxyBypassList += rtl::OUString::createFromAscii( ";" ); - - aProxyBypassList += CFStringToOUString(rException); - } - } - - if (rProxyDict) - CFRelease(rProxyDict); - - // override default for ProxyType, which is "0" meaning "No proxies". - // CAUTION: if you add properties, please increase the sequence size here ! - uno::Sequence<backend::PropertyInfo> aPropInfoList(8); - sal_Int32 nProperties = 1; - - aPropInfoList[0].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetProxyType") ); - aPropInfoList[0].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "int" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value = uno::makeAny( nProperties ); - - // fill proxy bypass list - if( aProxyBypassList.getLength() > 0 ) - { - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetNoProxy") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( aProxyBypassList.replace( SPACE, SEMI_COLON ) ); - } - - ProxyEntry aHttpProxy; - ProxyEntry aHttpsProxy; - ProxyEntry aFtpProxy; - - char host[MAXHOSTNAMELEN]; - UInt16 port; - bool retVal; - - retVal = GetProxySetting(sHTTP, host, 100, &port); - - if (retVal) - { - aHttpProxy.Server = rtl::OUString::createFromAscii( host ); - aHttpProxy.Port = port; - } - - retVal = GetProxySetting(sHTTPS, host, 100, &port); - - if (retVal) - { - aHttpsProxy.Server = rtl::OUString::createFromAscii( host ); - aHttpsProxy.Port = port; - } - - retVal = GetProxySetting(sFTP, host, 100, &port); - - if (retVal) - { - aFtpProxy.Server = rtl::OUString::createFromAscii( host ); - aFtpProxy.Port = port; - } - - // http proxy name - if( aHttpProxy.Server.getLength() > 0 ) - { - 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( aHttpProxy.Server ); - } - - // http proxy port - if( aHttpProxy.Port > 0 ) - { - 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( aHttpProxy.Port ); - } - - // https proxy name - if( aHttpsProxy.Server.getLength() > 0 ) - { - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyName") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( aHttpsProxy.Server ); - } - - // https proxy port - if( aHttpsProxy.Port > 0 ) - { - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyPort") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "int" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( aHttpsProxy.Port ); - } - - // ftp proxy name - if( aFtpProxy.Server.getLength() > 0 ) - { - 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( aFtpProxy.Server ); - } - - // ftp proxy port - if( aFtpProxy.Port > 0 ) - { - 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( aFtpProxy.Port ); - } - - // resize the property info list appropriately - aPropInfoList.realloc(nProperties); - - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } - else - { - OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL MacOSXLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - // FIXME: Always new timestamp!? - rtl::OUString aTimestamp = rtl::OUString::valueOf( time(NULL) ); - - return aTimestamp; -} - -//------------------------------------------------------------------------------ - -rtl::OUString GetOUString( NSString* pStr ) -{ - if( ! pStr ) - return rtl::OUString(); - int nLen = [pStr length]; - if( nLen == 0 ) - return rtl::OUString(); - - rtl::OUStringBuffer aBuf( nLen+1 ); - aBuf.setLength( nLen ); - [pStr getCharacters: const_cast<sal_Unicode*>(aBuf.getStr())]; - return aBuf.makeStringAndClear(); -} - -void SAL_CALL MacOSXPathLayer::readData( - const uno::Reference<backend::XLayerHandler>& i_xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - if (m_xLayerContentDescriber.is()) - { - rtl::OUString aDocDir; - NSArray* pPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, true ); - if( pPaths && [pPaths count] > 0 ) - { - aDocDir = GetOUString( [pPaths objectAtIndex: 0] ); - - rtl::OUString aDocURL; - if( aDocDir.getLength() > 0 && - osl_getFileURLFromSystemPath( aDocDir.pData, &aDocURL.pData ) == osl_File_E_None ) - { - uno::Sequence<backend::PropertyInfo> aPropInfoList(1); - - aPropInfoList[0].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Paths/Variables/Work" ) ); - aPropInfoList[0].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value <<= aDocURL; - - m_xLayerContentDescriber->describeLayer(i_xHandler, aPropInfoList); - } - else - { - OSL_TRACE( "user documents list contains empty file path or conversion failed" ); - } - } - else - { - OSL_TRACE( "Got nil or empty list of user document directories" ); - } - } - else - { - OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); - } -} - diff --git a/shell/source/backends/macbe/macbelayer.hxx b/shell/source/backends/macbe/macbelayer.hxx deleted file mode 100644 index 06e80632da50..000000000000 --- a/shell/source/backends/macbe/macbelayer.hxx +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _MACBELAYER_HXX_ -#define _MACBELAYER_HXX_ - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <cppuhelper/implbase2.hxx> - -namespace css = com::sun::star; -namespace uno = css::uno; -namespace lang = css::lang; -namespace backend = css::configuration::backend; -namespace util = css::util; - -/** - Implementation of the XLayer interfaces for fixed values - */ - -class MacOSXLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ -public: - - /** - Constructor given the requested component name - - @param aTimestamp timestamp indicating last modifictaion - */ - MacOSXLayer(const uno::Reference<uno::XComponentContext>& xContext); - - /** Destructor */ - virtual ~MacOSXLayer(void) {} - - // XLayer - virtual void SAL_CALL readData(const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException); - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - -protected: - - rtl::OUString m_aComponent; - - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber; - -}; - -class MacOSXPathLayer : public MacOSXLayer -{ - public: - MacOSXPathLayer(const uno::Reference<uno::XComponentContext>& i_xContext) : - MacOSXLayer( i_xContext ) {} - virtual ~MacOSXPathLayer() {} - - // XLayer - virtual void SAL_CALL readData(const uno::Reference<backend::XLayerHandler>& i_xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException); -}; - -#endif // _MACBELAYER_HXX_ diff --git a/shell/source/backends/macbe/makefile.mk b/shell/source/backends/macbe/makefile.mk index 1d5d68a1f615..7b42c8c577ce 100644 --- a/shell/source/backends/macbe/makefile.mk +++ b/shell/source/backends/macbe/makefile.mk @@ -54,8 +54,7 @@ CFLAGSCXX+=$(OBJCXXFLAGS) SLOFILES= \ $(SLO)$/macbecdef.obj \ - $(SLO)$/macbackend.obj \ - $(SLO)$/macbelayer.obj + $(SLO)$/macbackend.obj SHL1TARGET=$(TARGET)1.uno SHL1OBJS=$(SLOFILES) diff --git a/shell/source/backends/wininetbe/makefile.mk b/shell/source/backends/wininetbe/makefile.mk index fd87b9268475..0401cb88b7dd 100644 --- a/shell/source/backends/wininetbe/makefile.mk +++ b/shell/source/backends/wininetbe/makefile.mk @@ -46,9 +46,8 @@ DLLPRE = SLOFILES=\ $(SLO)$/wininetbecdef.obj \ - $(SLO)$/wininetbackend.obj \ - $(SLO)$/wininetlayer.obj - + $(SLO)$/wininetbackend.obj + SHL1TARGET=$(TARGET)1.uno SHL1OBJS=$(SLOFILES) SHL1DEF=$(MISC)$/$(SHL1TARGET).def diff --git a/shell/source/backends/wininetbe/wininetbackend.cxx b/shell/source/backends/wininetbe/wininetbackend.cxx index 0734b2cbba3a..e28bab3affe4 100644 --- a/shell/source/backends/wininetbe/wininetbackend.cxx +++ b/shell/source/backends/wininetbe/wininetbackend.cxx @@ -28,76 +28,331 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_shell.hxx" +#include "rtl/ustrbuf.hxx" + #include "wininetbackend.hxx" -#include "wininetlayer.hxx" -#include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp> -#include <uno/current_context.hxx> + +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include <windows.h> +#include <wininet.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif #define WININET_DLL_NAME "wininet.dll" +#define EQUAL_SIGN '=' +#define COLON ':' +#define SPACE ' ' +#define SEMI_COLON ';' -WinInetBackend::WinInetBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException) : - ::cppu::WeakImplHelper2 < backend::XSingleLayerStratum, lang::XServiceInfo > (), - m_xContext(xContext) -{ - m_hWinInetDll = LoadLibrary( WININET_DLL_NAME ); -} +namespace { -//------------------------------------------------------------------------------ +struct Library { + HMODULE module; -WinInetBackend::~WinInetBackend(void) -{ - if ( m_hWinInetDll ) - FreeLibrary( m_hWinInetDll ); -} + Library(HMODULE theModule): module(theModule) {} -//------------------------------------------------------------------------------ + ~Library() { if (module) FreeLibrary(module); } +}; -WinInetBackend* WinInetBackend::createInstance( - const uno::Reference<uno::XComponentContext>& xContext -) -{ - return new WinInetBackend(xContext); } -// --------------------------------------------------------------------------------------- +typedef struct +{ + rtl::OUString Server; + rtl::OUString Port; +} ProxyEntry; + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ -uno::Reference<backend::XLayer> SAL_CALL WinInetBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException) +namespace // private { + ProxyEntry ReadProxyEntry(const rtl::OUString& aProxy, sal_Int32& i) + { + ProxyEntry aProxyEntry; - if( aComponent.equals( getSupportedComponents()[0]) ) + aProxyEntry.Server = aProxy.getToken( 0, COLON, i ); + if ( i > -1 ) + aProxyEntry.Port = aProxy.getToken( 0, COLON, i ); + + return aProxyEntry; + } + + ProxyEntry FindProxyEntry(const rtl::OUString& aProxyList, const rtl::OUString& aType) { - if( ! m_xSystemLayer.is() && m_hWinInetDll ) + sal_Int32 nIndex = 0; + + do { - WinInetLayer::InternetQueryOption_Proc_T lpfnInternetQueryOption = - reinterpret_cast< WinInetLayer::InternetQueryOption_Proc_T >( - GetProcAddress( m_hWinInetDll, "InternetQueryOptionA" ) ); + // get the next token, e.g. ftp=server:port + rtl::OUString nextToken = aProxyList.getToken( 0, SPACE, nIndex ); + + // split the next token again into the parts separated + // through '=', e.g. ftp=server:port -> ftp and server:port + sal_Int32 i = 0; + if( nextToken.indexOf( EQUAL_SIGN ) > -1 ) + { + if( aType.equals( nextToken.getToken( 0, EQUAL_SIGN, i ) ) ) + return ReadProxyEntry(nextToken, i); + } + else if( aType.getLength() == 0) + return ReadProxyEntry(nextToken, i); + + } while ( nIndex >= 0 ); + + return ProxyEntry(); + } - if( lpfnInternetQueryOption ) - m_xSystemLayer = new WinInetLayer(lpfnInternetQueryOption, m_xContext); - } +} // end private namespace + +//------------------------------------------------------------------------------ + +WinInetBackend::WinInetBackend() +{ + Library hWinInetDll( LoadLibrary( WININET_DLL_NAME ) ); + if( hWinInetDll.module ) + { + typedef BOOL ( WINAPI *InternetQueryOption_Proc_T )( HINTERNET, DWORD, LPVOID, LPDWORD ); - return m_xSystemLayer; + InternetQueryOption_Proc_T lpfnInternetQueryOption = + reinterpret_cast< InternetQueryOption_Proc_T >( + GetProcAddress( hWinInetDll.module, "InternetQueryOptionA" ) ); + if (lpfnInternetQueryOption) + { + LPINTERNET_PROXY_INFO lpi = NULL; + + // query for the neccessary space + DWORD dwLength = 0; + BOOL bRet = lpfnInternetQueryOption( + NULL, + INTERNET_OPTION_PROXY, + (LPVOID)lpi, + &dwLength ); + + // allocate sufficient space on the heap + // insufficient space on the heap results + // in a stack overflow exception, we assume + // this never happens, because of the relatively + // small amount of memory we need + // _alloca is nice because it is fast and we don't + // have to free the allocated memory, it will be + // automatically done + lpi = reinterpret_cast< LPINTERNET_PROXY_INFO >( + _alloca( dwLength ) ); + + bRet = lpfnInternetQueryOption( + NULL, + INTERNET_OPTION_PROXY, + (LPVOID)lpi, + &dwLength ); + + // if a proxy is disabled, InternetQueryOption returns + // an empty proxy list, so we don't have to check if + // proxy is enabled or not + + rtl::OUString aProxyList = rtl::OUString::createFromAscii( lpi->lpszProxy ); + rtl::OUString aProxyBypassList = rtl::OUString::createFromAscii( lpi->lpszProxyBypass ); + + // override default for ProxyType, which is "0" meaning "No proxies". + sal_Int32 nProperties = 1; + + valueProxyType_.IsPresent = true; + valueProxyType_.Value <<= nProperties; + + // fill proxy bypass list + if( aProxyBypassList.getLength() > 0 ) + { + rtl::OUStringBuffer aReverseList; + sal_Int32 nIndex = 0; + do + { + rtl::OUString aToken = aProxyBypassList.getToken( 0, SPACE, nIndex ); + if ( aProxyList.indexOf( aToken ) == -1 ) + { + if ( aReverseList.getLength() ) + { + aReverseList.insert( 0, sal_Unicode( SEMI_COLON ) ); + aReverseList.insert( 0, aToken ); + } + else + aReverseList = aToken; + } + } + while ( nIndex >= 0 ); + + aProxyBypassList = aReverseList.makeStringAndClear(); + + valueNoProxy_.IsPresent = true; + valueNoProxy_.Value <<= aProxyBypassList.replace( SPACE, SEMI_COLON ); + } + + if( aProxyList.getLength() > 0 ) + { + //------------------------------------------------- + // this implementation follows the algorithm + // of the internet explorer + // if there are type-dependent proxy settings + // and type independent proxy settings in the + // registry the internet explorer chooses the + // type independent proxy for all settings + // e.g. imagine the following registry entry + // ftp=server:port;http=server:port;server:port + // the last token server:port is type independent + // so the ie chooses this proxy server + + // if there is no port specified for a type independent + // server the ie uses the port of an http server if + // there is one and it has a port + //------------------------------------------------- + + ProxyEntry aTypeIndepProxy = FindProxyEntry( aProxyList, rtl::OUString()); + ProxyEntry aHttpProxy = FindProxyEntry( aProxyList, rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "http" ) ) ); + ProxyEntry aHttpsProxy = FindProxyEntry( aProxyList, rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "https" ) ) ); + + ProxyEntry aFtpProxy = FindProxyEntry( aProxyList, rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "ftp" ) ) ); + + if( aTypeIndepProxy.Server.getLength() ) + { + aHttpProxy.Server = aTypeIndepProxy.Server; + aHttpsProxy.Server = aTypeIndepProxy.Server; + aFtpProxy.Server = aTypeIndepProxy.Server; + + if( aTypeIndepProxy.Port.getLength() ) + { + aHttpProxy.Port = aTypeIndepProxy.Port; + aHttpsProxy.Port = aTypeIndepProxy.Port; + aFtpProxy.Port = aTypeIndepProxy.Port; + } + else + { + aFtpProxy.Port = aHttpProxy.Port; + aHttpsProxy.Port = aHttpProxy.Port; + } + } + + // http proxy name + if( aHttpProxy.Server.getLength() > 0 ) + { + valueHttpProxyName_.IsPresent = true; + valueHttpProxyName_.Value <<= aHttpProxy.Server; + } + + // http proxy port + if( aHttpProxy.Port.getLength() > 0 ) + { + valueHttpProxyPort_.IsPresent = true; + valueHttpProxyPort_.Value <<= aHttpProxy.Port.toInt32(); + } + + // https proxy name + if( aHttpsProxy.Server.getLength() > 0 ) + { + valueHttpsProxyName_.IsPresent = true; + valueHttpsProxyName_.Value <<= aHttpsProxy.Server; + } + + // https proxy port + if( aHttpsProxy.Port.getLength() > 0 ) + { + valueHttpsProxyPort_.IsPresent = true; + valueHttpsProxyPort_.Value <<= aHttpsProxy.Port.toInt32(); + } + + // ftp proxy name + if( aFtpProxy.Server.getLength() > 0 ) + { + valueFtpProxyName_.IsPresent = true; + valueFtpProxyName_.Value <<= aFtpProxy.Server; + } + + // ftp proxy port + if( aFtpProxy.Port.getLength() > 0 ) + { + valueFtpProxyPort_.IsPresent = true; + valueFtpProxyPort_.Value <<= aFtpProxy.Port.toInt32(); + } + } + } } +} - return uno::Reference<backend::XLayer>(); +//------------------------------------------------------------------------------ + +WinInetBackend::~WinInetBackend(void) +{ } //------------------------------------------------------------------------------ -uno::Reference<backend::XUpdatableLayer> SAL_CALL -WinInetBackend::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) +WinInetBackend* WinInetBackend::createInstance() { - throw lang::NoSupportException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "WinInetBackend: No Update Operation allowed, Read Only access") ), - *this) ; + return new WinInetBackend; +} + +// --------------------------------------------------------------------------------------- - return NULL; +void WinInetBackend::setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); +} + +css::uno::Any WinInetBackend::getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName"))) + { + return css::uno::makeAny(valueFtpProxyName_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort"))) + { + return css::uno::makeAny(valueFtpProxyPort_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName"))) + { + return css::uno::makeAny(valueHttpProxyName_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort"))) + { + return css::uno::makeAny(valueHttpProxyPort_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName"))) + { + return css::uno::makeAny(valueHttpsProxyName_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort"))) + { + return css::uno::makeAny(valueHttpsProxyPort_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) + { + return css::uno::makeAny(valueNoProxy_); + } else if (PropertyName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) + { + return css::uno::makeAny(valueProxyType_); + } else { + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); + } } //------------------------------------------------------------------------------ @@ -118,9 +373,8 @@ rtl::OUString SAL_CALL WinInetBackend::getImplementationName(void) uno::Sequence<rtl::OUString> SAL_CALL WinInetBackend::getBackendServiceNames(void) { - uno::Sequence<rtl::OUString> aServiceNameList(2); + uno::Sequence<rtl::OUString> aServiceNameList(1); aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.WinInetBackend")) ; - aServiceNameList[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; return aServiceNameList ; } @@ -146,16 +400,3 @@ uno::Sequence<rtl::OUString> SAL_CALL WinInetBackend::getSupportedServiceNames(v { return getBackendServiceNames() ; } - -// --------------------------------------------------------------------------------------- - -uno::Sequence<rtl::OUString> SAL_CALL WinInetBackend::getSupportedComponents(void) -{ - uno::Sequence<rtl::OUString> aSupportedComponentList(1); - aSupportedComponentList[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet" ) - ); - - return aSupportedComponentList; -} - diff --git a/shell/source/backends/wininetbe/wininetbackend.hxx b/shell/source/backends/wininetbe/wininetbackend.hxx index d624d2cefb10..5fe4d5625a9a 100644 --- a/shell/source/backends/wininetbe/wininetbackend.hxx +++ b/shell/source/backends/wininetbe/wininetbackend.hxx @@ -28,38 +28,23 @@ #ifndef _FIXEDVALUEBACKEND_HXX_ #define _FIXEDVALUEBACKEND_HXX_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/Optional.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp> #include <cppuhelper/implbase2.hxx> #include <rtl/string.hxx> -#if defined _MSC_VER -#pragma warning(push, 1) -#endif -#include <windows.h> -#include <wininet.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif - namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -/** - Implements the SingleLayerStratum service. - */ class WinInetBackend : public ::cppu::WeakImplHelper2 < - backend::XSingleLayerStratum, + css::beans::XPropertySet, lang::XServiceInfo > { public : - static WinInetBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); + static WinInetBackend* createInstance(); // XServiceInfo virtual rtl::OUString SAL_CALL @@ -86,43 +71,86 @@ class WinInetBackend : public ::cppu::WeakImplHelper2 < @return service names */ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ; - /** - Provides the supported component nodes - - @return supported component nodes - */ - static uno::Sequence<rtl::OUString> SAL_CALL getSupportedComponents(void) ; - - //XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL - 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) ; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } + + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + protected: /** Service constructor from a service factory. @param xContext component context */ - WinInetBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); + WinInetBackend(); /** Destructor */ ~WinInetBackend(void) ; private: - - uno::Reference<uno::XComponentContext> m_xContext ; - uno::Reference<backend::XLayer> m_xSystemLayer ; - - // The wininet.dll module handle - HMODULE m_hWinInetDll; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueProxyType_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueNoProxy_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueHttpProxyName_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueHttpProxyPort_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueHttpsProxyName_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueHttpsProxyPort_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueFtpProxyName_; + com::sun::star::beans::Optional< com::sun::star::uno::Any > + valueFtpProxyPort_; } ; diff --git a/shell/source/backends/wininetbe/wininetbe.xml b/shell/source/backends/wininetbe/wininetbe.xml index 42364deba3cb..1bf4bd2cd053 100644 --- a/shell/source/backends/wininetbe/wininetbe.xml +++ b/shell/source/backends/wininetbe/wininetbe.xml @@ -10,7 +10,6 @@ <language>c++</language> <status value="beta"/> <supported-service>com.sun.star.comp.configuration.backend.Win32Backend</supported-service> - <supported-service>com.sun.star.comp.configuration.backend.PlatformBackend</supported-service> <service-dependency>...</service-dependency> <type>com.sun.star.configuration.backend.XBackendChangesListener</type> <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type> diff --git a/shell/source/backends/wininetbe/wininetbecdef.cxx b/shell/source/backends/wininetbe/wininetbecdef.cxx index 1a941429a3ec..862600009e30 100644 --- a/shell/source/backends/wininetbe/wininetbecdef.cxx +++ b/shell/source/backends/wininetbe/wininetbecdef.cxx @@ -39,14 +39,13 @@ namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace backend = css::configuration::backend ; //------------------------------------------------------------------------------ static uno::Reference<uno::XInterface> SAL_CALL createWinInetBackend( - const uno::Reference<uno::XComponentContext>& xContext){ + const uno::Reference<uno::XComponentContext>&){ - return * WinInetBackend::createInstance(xContext); + return * WinInetBackend::createInstance(); } //------------------------------------------------------------------------------ @@ -74,41 +73,9 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( //------------------------------------------------------------------------------ -extern "C" sal_Bool SAL_CALL component_writeInfo(void * /*pServiceManager*/, void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + WinInetBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = WinInetBackend::getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - // Register supported components - uno::Reference<XRegistryKey> xComponentKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/DATA/SupportedComponents") ) - ); - - xComponentKey->setAsciiListValue( WinInetBackend::getSupportedComponents() ); - - return sal_True; - } - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - return sal_False; +extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) { + return cppu::component_writeInfoHelper( + pServiceManager, pRegistryKey, kImplementations_entries); } //------------------------------------------------------------------------------ diff --git a/shell/source/backends/wininetbe/wininetlayer.cxx b/shell/source/backends/wininetbe/wininetlayer.cxx deleted file mode 100644 index df00abe0081b..000000000000 --- a/shell/source/backends/wininetbe/wininetlayer.cxx +++ /dev/null @@ -1,374 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" - -#ifndef _WININETLAYER_HXX_ -#include "wininetlayer.hxx" -#endif - -#include <malloc.h> - -#include <rtl/ustrbuf.hxx> - -#define EQUAL_SIGN '=' -#define COLON ':' -#define SPACE ' ' -#define SEMI_COLON ';' - -typedef struct -{ - rtl::OUString Server; - rtl::OUString Port; -} ProxyEntry; - -//------------------------------------------------------------------------ -// helper functions -//------------------------------------------------------------------------ - -namespace // private -{ - ProxyEntry ReadProxyEntry(const rtl::OUString& aProxy, sal_Int32& i) - { - ProxyEntry aProxyEntry; - - aProxyEntry.Server = aProxy.getToken( 0, COLON, i ); - if ( i > -1 ) - aProxyEntry.Port = aProxy.getToken( 0, COLON, i ); - - return aProxyEntry; - } - - ProxyEntry FindProxyEntry(const rtl::OUString& aProxyList, const rtl::OUString& aType) - { - sal_Int32 nIndex = 0; - - do - { - // get the next token, e.g. ftp=server:port - rtl::OUString nextToken = aProxyList.getToken( 0, SPACE, nIndex ); - - // split the next token again into the parts separated - // through '=', e.g. ftp=server:port -> ftp and server:port - sal_Int32 i = 0; - if( nextToken.indexOf( EQUAL_SIGN ) > -1 ) - { - if( aType.equals( nextToken.getToken( 0, EQUAL_SIGN, i ) ) ) - return ReadProxyEntry(nextToken, i); - } - else if( aType.getLength() == 0) - return ReadProxyEntry(nextToken, i); - - } while ( nIndex >= 0 ); - - return ProxyEntry(); - } - -} // end private namespace - -//------------------------------------------------------------------------------ - -WinInetLayer::WinInetLayer( InternetQueryOption_Proc_T lpfnInternetQueryOption, - const uno::Reference<uno::XComponentContext>& xContext) - : m_lpfnInternetQueryOption(lpfnInternetQueryOption) -{ - //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 SAL_CALL WinInetLayer::readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - - if (m_xLayerContentDescriber.is() && m_lpfnInternetQueryOption) - { - LPINTERNET_PROXY_INFO lpi = NULL; - - // query for the neccessary space - DWORD dwLength = 0; - BOOL bRet = m_lpfnInternetQueryOption( - NULL, - INTERNET_OPTION_PROXY, - (LPVOID)lpi, - &dwLength ); - - // allocate sufficient space on the heap - // insufficient space on the heap results - // in a stack overflow exception, we assume - // this never happens, because of the relatively - // small amount of memory we need - // _alloca is nice because it is fast and we don't - // have to free the allocated memory, it will be - // automatically done - lpi = reinterpret_cast< LPINTERNET_PROXY_INFO >( - _alloca( dwLength ) ); - - bRet = m_lpfnInternetQueryOption( - NULL, - INTERNET_OPTION_PROXY, - (LPVOID)lpi, - &dwLength ); - - // if a proxy is disabled, InternetQueryOption returns - // an empty proxy list, so we don't have to check if - // proxy is enabled or not - - rtl::OUString aProxyList = rtl::OUString::createFromAscii( lpi->lpszProxy ); - rtl::OUString aProxyBypassList = rtl::OUString::createFromAscii( lpi->lpszProxyBypass ); - - // override default for ProxyType, which is "0" meaning "No proxies". - uno::Sequence<backend::PropertyInfo> aPropInfoList(8); - sal_Int32 nProperties = 1; - - aPropInfoList[0].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetProxyType") ); - aPropInfoList[0].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "int" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value = uno::makeAny( nProperties ); - - // fill proxy bypass list - if( aProxyBypassList.getLength() > 0 ) - { - rtl::OUStringBuffer aReverseList; - sal_Int32 nIndex = 0; - do - { - rtl::OUString aToken = aProxyBypassList.getToken( 0, SPACE, nIndex ); - if ( aProxyList.indexOf( aToken ) == -1 ) - { - if ( aReverseList.getLength() ) - { - aReverseList.insert( 0, sal_Unicode( SEMI_COLON ) ); - aReverseList.insert( 0, aToken ); - } - else - aReverseList = aToken; - } - } - while ( nIndex >= 0 ); - - aProxyBypassList = aReverseList.makeStringAndClear(); - - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetNoProxy") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( aProxyBypassList.replace( SPACE, SEMI_COLON ) ); - } - - if( aProxyList.getLength() > 0 ) - { - //------------------------------------------------- - // this implementation follows the algorithm - // of the internet explorer - // if there are type-dependent proxy settings - // and type independent proxy settings in the - // registry the internet explorer chooses the - // type independent proxy for all settings - // e.g. imagine the following registry entry - // ftp=server:port;http=server:port;server:port - // the last token server:port is type independent - // so the ie chooses this proxy server - - // if there is no port specified for a type independent - // server the ie uses the port of an http server if - // there is one and it has a port - //------------------------------------------------- - - ProxyEntry aTypeIndepProxy = FindProxyEntry( aProxyList, rtl::OUString()); - ProxyEntry aHttpProxy = FindProxyEntry( aProxyList, rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "http" ) ) ); - ProxyEntry aHttpsProxy = FindProxyEntry( aProxyList, rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "https" ) ) ); - - ProxyEntry aFtpProxy = FindProxyEntry( aProxyList, rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "ftp" ) ) ); - - if( aTypeIndepProxy.Server.getLength() ) - { - aHttpProxy.Server = aTypeIndepProxy.Server; - aHttpsProxy.Server = aTypeIndepProxy.Server; - aFtpProxy.Server = aTypeIndepProxy.Server; - - if( aTypeIndepProxy.Port.getLength() ) - { - aHttpProxy.Port = aTypeIndepProxy.Port; - aHttpsProxy.Port = aTypeIndepProxy.Port; - aFtpProxy.Port = aTypeIndepProxy.Port; - } - else - { - aFtpProxy.Port = aHttpProxy.Port; - aHttpsProxy.Port = aHttpProxy.Port; - } - } - - // http proxy name - if( aHttpProxy.Server.getLength() > 0 ) - { - 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( aHttpProxy.Server ); - } - - // http proxy port - if( aHttpProxy.Port.getLength() > 0 ) - { - 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( aHttpProxy.Port.toInt32() ); - } - - // https proxy name - if( aHttpsProxy.Server.getLength() > 0 ) - { - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyName") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( aHttpsProxy.Server ); - } - - // https proxy port - if( aHttpsProxy.Port.getLength() > 0 ) - { - aPropInfoList[nProperties].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings/ooInetHTTPSProxyPort") ); - aPropInfoList[nProperties].Type = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "int" ) ); - aPropInfoList[nProperties].Protected = sal_False; - aPropInfoList[nProperties++].Value = uno::makeAny( aHttpsProxy.Port.toInt32() ); - } - - // ftp proxy name - if( aFtpProxy.Server.getLength() > 0 ) - { - 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( aFtpProxy.Server ); - } - - // ftp proxy port - if( aFtpProxy.Port.getLength() > 0 ) - { - 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( aFtpProxy.Port.toInt32() ); - } - } - - // resize the property info list appropriately - aPropInfoList.realloc(nProperties); - - m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList); - } - else - { - OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL WinInetLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - rtl::OUString aTimestamp; - - if (m_lpfnInternetQueryOption) - { - LPINTERNET_PROXY_INFO lpi = NULL; - - // query for the neccessary space - DWORD dwLength = 0; - BOOL bRet = m_lpfnInternetQueryOption( - NULL, - INTERNET_OPTION_PROXY, - (LPVOID)lpi, - &dwLength ); - - // allocate sufficient space on the heap - // insufficient space on the heap results - // in a stack overflow exception, we assume - // this never happens, because of the relatively - // small amount of memory we need - // _alloca is nice because it is fast and we don't - // have to free the allocated memory, it will be - // automatically done - lpi = reinterpret_cast< LPINTERNET_PROXY_INFO >( - _alloca( dwLength ) ); - - bRet = m_lpfnInternetQueryOption( - NULL, - INTERNET_OPTION_PROXY, - (LPVOID)lpi, - &dwLength ); - - aTimestamp = rtl::OUString::createFromAscii( lpi->lpszProxy ); - aTimestamp += rtl::OUString::createFromAscii( lpi->lpszProxyBypass ); - } - - return aTimestamp; -} - -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/wininetbe/wininetlayer.hxx b/shell/source/backends/wininetbe/wininetlayer.hxx deleted file mode 100644 index 761e174d1df5..000000000000 --- a/shell/source/backends/wininetbe/wininetlayer.hxx +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _WinInetLayer_HXX_ -#define _WinInetLayer_HXX_ - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <cppuhelper/implbase2.hxx> - -#if defined _MSC_VER -#pragma warning(push, 1) -#endif -#include <windows.h> -#include <wininet.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interfaces for fixed values - */ - -class WinInetLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ - public : - typedef BOOL ( WINAPI *InternetQueryOption_Proc_T )( HINTERNET, DWORD, LPVOID, LPDWORD ); - - /** - Constructor given the requested component name - - @param lpfnInternetQueryOption function pointer into wininet.dll - @param aTimestamp timestamp indicating last modifictaion - */ - WinInetLayer(InternetQueryOption_Proc_T lpfnInternetQueryOption, - const uno::Reference<uno::XComponentContext>& xContext); - - /** Destructor */ - ~WinInetLayer(void) {} - - // XLayer - virtual void SAL_CALL readData(const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - private : - - rtl::OUString m_aComponent ; - - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - - // The InternetQueryOption function pointer - InternetQueryOption_Proc_T m_lpfnInternetQueryOption; -} ; - -#endif // _WinInetLayer_HXX_ |