From 48df5d3811b284973b6ea988eb537f4f6ec3cb89 Mon Sep 17 00:00:00 2001 From: sb Date: Wed, 30 Sep 2009 09:14:44 +0200 Subject: #i101955# adapted desktop and gconf platform backends to new interface (gconf still needs support for ENABLE_LOCKDOWN-only Setup/Office/Factories .xcu entries), more to come; regcomplazy consequently no longer needs to support [Data] sections --- officecfg/registry/data/org/openoffice/Inet.xcu | 64 +- .../registry/data/org/openoffice/Office/Common.xcu | 125 ++- .../registry/data/org/openoffice/Office/Paths.xcu | 9 +- .../data/org/openoffice/Office/Recovery.xcu | 44 + .../data/org/openoffice/Office/makefile.mk | 7 +- officecfg/registry/data/org/openoffice/System.xcu | 1 - .../registry/data/org/openoffice/UserProfile.xcu | 7 + officecfg/registry/data/org/openoffice/VCL.xcu | 8 +- officecfg/registry/data/org/openoffice/makefile.mk | 8 +- officecfg/util/data_val.xsl | 3 - shell/source/backends/desktopbe/desktopbackend.cxx | 248 +++++ shell/source/backends/desktopbe/desktopbe.xml | 37 - shell/source/backends/desktopbe/desktopbe1-ucd.txt | 3 - shell/source/backends/desktopbe/desktopbecdef.cxx | 205 ---- shell/source/backends/desktopbe/exports.map | 10 - shell/source/backends/desktopbe/makefile.mk | 66 +- shell/source/backends/gconfbe/exports.map | 10 - shell/source/backends/gconfbe/gconfaccess.cxx | 850 +++++++++++++++ shell/source/backends/gconfbe/gconfaccess.hxx | 119 +++ shell/source/backends/gconfbe/gconfbackend.cxx | 1124 +++----------------- shell/source/backends/gconfbe/gconfbackend.hxx | 225 ---- shell/source/backends/gconfbe/gconfbe.xml | 35 - shell/source/backends/gconfbe/gconfbecdef.cxx | 151 --- shell/source/backends/gconfbe/gconflayer.cxx | 564 ---------- shell/source/backends/gconfbe/gconflayer.hxx | 133 --- shell/source/backends/gconfbe/makefile.mk | 9 +- 26 files changed, 1670 insertions(+), 2395 deletions(-) create mode 100644 officecfg/registry/data/org/openoffice/Office/Recovery.xcu create mode 100644 shell/source/backends/desktopbe/desktopbackend.cxx delete mode 100644 shell/source/backends/desktopbe/desktopbe.xml delete mode 100644 shell/source/backends/desktopbe/desktopbecdef.cxx delete mode 100644 shell/source/backends/desktopbe/exports.map delete mode 100644 shell/source/backends/gconfbe/exports.map create mode 100644 shell/source/backends/gconfbe/gconfaccess.cxx create mode 100644 shell/source/backends/gconfbe/gconfaccess.hxx delete mode 100644 shell/source/backends/gconfbe/gconfbackend.hxx delete mode 100644 shell/source/backends/gconfbe/gconfbe.xml delete mode 100644 shell/source/backends/gconfbe/gconfbecdef.cxx delete mode 100644 shell/source/backends/gconfbe/gconflayer.cxx delete mode 100644 shell/source/backends/gconfbe/gconflayer.hxx diff --git a/officecfg/registry/data/org/openoffice/Inet.xcu b/officecfg/registry/data/org/openoffice/Inet.xcu index bb3fa8e1a618..07afec58085c 100644 --- a/officecfg/registry/data/org/openoffice/Inet.xcu +++ b/officecfg/registry/data/org/openoffice/Inet.xcu @@ -29,10 +29,72 @@ * ************************************************************************ --> - + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index c9747dc9dea0..fcbb1601d05e 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -103,6 +103,27 @@ 13 + + + + + + + + + + + + + + + + @@ -541,18 +562,32 @@ - - false + + false + true + + + true + + + + + + @@ -565,6 +600,36 @@ true + + + + + + + + + + + + + + + + + + + + + @@ -576,4 +641,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu index b979f0f097c3..c16dfeef624d 100644 --- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu @@ -226,6 +226,13 @@ - + + + + + + diff --git a/officecfg/registry/data/org/openoffice/Office/Recovery.xcu b/officecfg/registry/data/org/openoffice/Office/Recovery.xcu new file mode 100644 index 000000000000..bd6aab12361b --- /dev/null +++ b/officecfg/registry/data/org/openoffice/Office/Recovery.xcu @@ -0,0 +1,44 @@ + + + + + + + + + + + + + diff --git a/officecfg/registry/data/org/openoffice/Office/makefile.mk b/officecfg/registry/data/org/openoffice/Office/makefile.mk index 50b67954aeef..c27c5d7dfc8f 100644 --- a/officecfg/registry/data/org/openoffice/Office/makefile.mk +++ b/officecfg/registry/data/org/openoffice/Office/makefile.mk @@ -78,6 +78,8 @@ MODULEFILES= \ Common-base.xcu \ Common-math.xcu \ Common-unx.xcu \ + Common-unixdesktop.xcu \ + Common-gconflockdown.xcu \ Common-macosx.xcu \ Common-wnt.xcu \ Common-UseOOoFileDialogs.xcu \ @@ -88,6 +90,7 @@ MODULEFILES= \ Common-korea.xcu \ Paths-macosx.xcu \ Paths-unxwnt.xcu \ + Paths-unixdesktop.xcu \ Writer-cjk.xcu \ Writer-defaultfontarial.xcu \ Writer-directcursor.xcu \ @@ -100,8 +103,8 @@ MODULEFILES= \ Embedding-math.xcu \ Embedding-base.xcu \ Embedding-writer.xcu \ - UI-brand.xcu - + UI-brand.xcu \ + Recovery-gconflockdown.xcu LOCALIZEDFILES= \ Accelerators.xcu \ diff --git a/officecfg/registry/data/org/openoffice/System.xcu b/officecfg/registry/data/org/openoffice/System.xcu index 53d8e4ead960..ef7c008d3830 100644 --- a/officecfg/registry/data/org/openoffice/System.xcu +++ b/officecfg/registry/data/org/openoffice/System.xcu @@ -28,7 +28,6 @@ * for a copy of the LGPLv3 License. **********************************************************************--> - diff --git a/officecfg/registry/data/org/openoffice/UserProfile.xcu b/officecfg/registry/data/org/openoffice/UserProfile.xcu index 69def88b1a53..632753bc3c7a 100644 --- a/officecfg/registry/data/org/openoffice/UserProfile.xcu +++ b/officecfg/registry/data/org/openoffice/UserProfile.xcu @@ -37,5 +37,12 @@ + + + + + + diff --git a/officecfg/registry/data/org/openoffice/VCL.xcu b/officecfg/registry/data/org/openoffice/VCL.xcu index 90d4bcd8b8cf..29b32149c337 100644 --- a/officecfg/registry/data/org/openoffice/VCL.xcu +++ b/officecfg/registry/data/org/openoffice/VCL.xcu @@ -1,4 +1,4 @@ - + - + false + false + diff --git a/officecfg/registry/data/org/openoffice/makefile.mk b/officecfg/registry/data/org/openoffice/makefile.mk index c4739df22ee9..97b52b3a9d44 100644 --- a/officecfg/registry/data/org/openoffice/makefile.mk +++ b/officecfg/registry/data/org/openoffice/makefile.mk @@ -49,6 +49,9 @@ XCUFILES= \ MODULEFILES= \ Inet-defaultsearchengine.xcu \ + Inet-macosx.xcu \ + Inet-unixdesktop.xcu \ + Inet-wnt.xcu \ Setup-brand.xcu \ Setup-writer.xcu \ Setup-calc.xcu \ @@ -57,7 +60,10 @@ MODULEFILES= \ Setup-base.xcu \ Setup-math.xcu \ Setup-report.xcu \ - Setup-start.xcu + Setup-start.xcu \ + UserProfile-gconflockdown.xcu \ + VCL-gconflockdown.xcu \ + VCL-unixdesktop.xcu LOCALIZEDFILES=Setup.xcu diff --git a/officecfg/util/data_val.xsl b/officecfg/util/data_val.xsl index bdf7c1ba2546..d22814dd19f5 100644 --- a/officecfg/util/data_val.xsl +++ b/officecfg/util/data_val.xsl @@ -206,9 +206,6 @@ ERROR: Property '' has multiple values for module and locale ! - - ERROR: Property '' has values both with and without module. This is currently not supported. Please contact jb@openoffice.org, if you need this! - ATTENTION: Property '' has different values for different modules. Make sure the modules are mutually exclusive! diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx new file mode 100644 index 000000000000..bdc45e737687 --- /dev/null +++ b/shell/source/backends/desktopbe/desktopbackend.cxx @@ -0,0 +1,248 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* 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 +* +* for a copy of the LGPLv3 License. +************************************************************************/ + +#include "precompiled_shell.hxx" +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/container/XNameAccess.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/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "cppu/unotype.hxx" +#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::container::XNameAccess >, + 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::Type SAL_CALL getElementType() + throw (css::uno::RuntimeException) + { return cppu::UnoType< cppu::UnoVoidType >::get(); } + + virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException) + { return true; } + + virtual css::uno::Any SAL_CALL getByName(rtl::OUString const & aName) + throw ( + css::container::NoSuchElementException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getElementNames() + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasByName(rtl::OUString const & aName) + throw (css::uno::RuntimeException); +}; + +css::uno::Any Default::getByName(rtl::OUString const & aName) + throw ( + css::container::NoSuchElementException, + css::lang::WrappedTargetException, css::uno::RuntimeException) +{ + if (!hasByName(aName)) { + throw css::container::NoSuchElementException( + aName, static_cast< cppu::OWeakObject * >(this)); + } + return css::uno::makeAny(cppu::UnoType< cppu::UnoVoidType >::get()); +} + +css::uno::Sequence< rtl::OUString > Default::getElementNames() + throw (css::uno::RuntimeException) +{ + css::uno::Sequence< rtl::OUString > names(13); + names[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("EnableATToolSupport")); + names[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ExternalMailer")); + names[2] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("SourceViewFontHeight")); + names[3] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SourceViewFontName")); + names[4] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkPathVariable")); + names[5] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")); + names[6] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")); + names[7] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")); + names[8] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")); + names[9] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyName")); + names[10] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyPort")); + names[11] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy")); + names[12] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")); + return names; +} + +sal_Bool Default::hasByName(rtl::OUString const & aName) + throw (css::uno::RuntimeException) +{ + css::uno::Sequence< rtl::OUString > names(getElementNames()); + for (sal_Int32 i = 0; i < names.getLength(); ++i) { + if (aName == names[i]) { + return true; + } + } + return false; +} + +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"))); + } //TODO: KDE4? + 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 @@ - - - - desktopbe - - Jan Holesovsky - com.sun.star.comp.configuration.backend.DesktopBackend - The shared gconf/KDE backend; will load GconfBackend or - KDEBackend depending on the desktop environment. - com.sun.star.loader.SharedLibrary - c++ - - com.sun.star.comp.configuration.backend.DesktopBackend - com.sun.star.comp.configuration.backend.PlatformBackend - ... - com.sun.star.configuration.backend.XBackendChangesListener - com.sun.star.configuration.backend.XBackendChangesNotifier - com.sun.star.configuration.backend.XLayerHandler - com.sun.star.configuration.backend.XSingleLayerStratum - com.sun.star.lang.XMultiComponentFactory - com.sun.star.lang.XServiceInfo - com.sun.star.lang.XSingleComponentFactory - com.sun.star.lang.XTypeProvider - com.sun.star.uno.TypeClass - com.sun.star.uno.XAggregation - com.sun.star.uno.XComponentContext - com.sun.star.uno.XCurrentContext - com.sun.star.uno.XWeak - com.sun.star.registry.XRegistryKey - - cppuhelper - cppu - sal - cppuhelper3$(COM) - cppu3 - sal3 - 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 2ae366bfcc94..000000000000 --- a/shell/source/backends/desktopbe/desktopbecdef.cxx +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: desktopbecdef.cxx,v $ - * $Revision: 1.4 $ - * - * 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 - * - * 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 -#endif -#include - -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include -#endif -#include - -#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 SAL_CALL createDesktopBackend(const uno::Reference& 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::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(); -} - -static rtl::OUString SAL_CALL getBackendName(void) { - return rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.DesktopBackend") ); -} - -static uno::Sequence SAL_CALL getBackendServiceNames(void) -{ - uno::Sequence 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 SAL_CALL getSupportedComponents(void) -{ - const sal_Int32 nComponents = 7; - - uno::Sequence 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 sServiceNames = getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - // Register supported components - uno::Reference 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 b6bcd3d95905..cc56e321296f 100644 --- a/shell/source/backends/desktopbe/makefile.mk +++ b/shell/source/backends/desktopbe/makefile.mk @@ -1,14 +1,13 @@ #************************************************************************* -# # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. +# +# Copyright 2009 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ +# $RCSfile: makefile,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # # This file is part of OpenOffice.org. # @@ -26,50 +25,31 @@ # version 3 along with OpenOffice.org. If not, see # # for a copy of the LGPLv3 License. -# -#************************************************************************* -PRJ=..$/..$/.. - -PRJNAME=shell -TARGET=desktopbe +#***********************************************************************/ -LIBTARGET=NO -ENABLE_EXCEPTIONS=TRUE +PRJ = ../../.. +PRJNAME = shell +TARGET = desktopbe -COMP1TYPELIST=$(TARGET) -COMPRDB=$(SOLARBINDIR)$/types.rdb -UNOUCROUT=$(OUT)$/inc$/$(TARGET) -INCPRE=$(UNOUCROUT) +ENABLE_EXCEPTIONS = TRUE +VISIBILITY_HIDDEN = TRUE -# --- Settings --- +.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/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx new file mode 100644 index 000000000000..8391eda712fa --- /dev/null +++ b/shell/source/backends/gconfbe/gconfaccess.cxx @@ -0,0 +1,850 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* 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 +* +* for a copy of the LGPLv3 License. +************************************************************************/ + +#include "precompiled_shell.hxx" +#include "sal/config.h" + +#include + +#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" + +#define GCONF_PROXY_MODE_KEY "/system/proxy/mode" +#define GCONF_AUTO_SAVE_KEY "/apps/openoffice/auto_save" + +namespace gconfaccess { + +namespace { + +namespace css = com::sun::star ; +namespace uno = css::uno ; +using namespace rtl; + +GConfClient* getGconfClient() +{ + static GConfClient* mClient= 0; + 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); + } + + 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) +{ + char *config_home; + char *p; + int relative; + bool bError = false; + + osl::Security aSecurity; + oslFileHandle handle; + OUString aHomeDirURL; + OUString aDocumentsDirURL; + OUString aConfigFileURL; + OUStringBuffer aUserDirBuf; + + if (!aSecurity.getHomeDir( aHomeDirURL ) ) + { + osl::FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii("/tmp"), aDocumentsDirURL); + return aDocumentsDirURL; + } + + config_home = getenv ("XDG_CONFIG_HOME"); + if (config_home == NULL || config_home[0] == 0) + { + aConfigFileURL = OUString(aHomeDirURL); + aConfigFileURL += OUString::createFromAscii( "/.config/user-dirs.dirs" ); + } + else + { + aConfigFileURL = OUString::createFromAscii(config_home); + aConfigFileURL += OUString::createFromAscii( "/user-dirs.dirs" ); + } + + if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read)) + { + rtl::ByteSequence seq; + while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq)) + { + /* Remove newline at end */ + int len = seq.getLength(); + if(len>0 && seq[len-1] == '\n') + seq[len-1] = 0; + + p = (char *)seq.getArray(); + + while (*p == ' ' || *p == '\t') + p++; + + if (strncmp (p, "XDG_", 4) != 0) + continue; + p += 4; + if (strncmp (p, type, strlen (type)) != 0) + continue; + p += strlen (type); + if (strncmp (p, "_DIR", 4) != 0) + continue; + p += 4; + + while (*p == ' ' || *p == '\t') + p++; + + if (*p != '=') + continue; + p++; + + while (*p == ' ' || *p == '\t') + p++; + + if (*p != '"') + continue; + p++; + + relative = 0; + if (strncmp (p, "$HOME/", 6) == 0) + { + p += 6; + relative = 1; + } + else if (*p != '/') + continue; + + if (relative) + { + aUserDirBuf = OUStringBuffer(aHomeDirURL); + aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) ); + } + else + { + aUserDirBuf = OUStringBuffer(); + } + + while (*p && *p != '"') + { + if ((*p == '\\') && (*(p+1) != 0)) + p++; + aUserDirBuf.append((sal_Unicode)*p++); + } + } + osl_closeFile(handle); + } + else + bError = true; + + if (aUserDirBuf.getLength()>0 && !bError) + { + aDocumentsDirURL = aUserDirBuf.makeStringAndClear(); + osl::Directory aDocumentsDir( aDocumentsDirURL ); + if( osl::FileBase::E_None == aDocumentsDir.open() ) + return aDocumentsDirURL; + } + + /* Special case desktop for historical compatibility */ + if (strcmp (type, "DESKTOP") == 0) + { + aUserDirBuf = OUStringBuffer(aHomeDirURL); + aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) ); + return aUserDirBuf.makeStringAndClear(); + } + else + { + aUserDirBuf = OUStringBuffer(aHomeDirURL); + aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) ); + return aUserDirBuf.makeStringAndClear(); + } +} + +//------------------------------------------------------------------------------ + +uno::Any makeAnyOfGconfValue( GConfValue *aGconfValue ) +{ + switch( aGconfValue->type ) + { + case GCONF_VALUE_BOOL: + return uno::makeAny( (sal_Bool) gconf_value_get_bool( aGconfValue ) ); + + case GCONF_VALUE_INT: + return uno::makeAny( (sal_Int32) gconf_value_get_int( aGconfValue ) ); + + case GCONF_VALUE_STRING: + return uno::makeAny( OStringToOUString( rtl::OString( + gconf_value_get_string(aGconfValue) ), RTL_TEXTENCODING_UTF8 ) ); + + default: + fprintf( stderr, "makeAnyOfGconfValue: Type not handled.\n" ); + break; + } + + return uno::Any(); +} + +//------------------------------------------------------------------------------ + +static void splitFontName( GConfValue *aGconfValue, rtl::OUString &rName, sal_Int16 &rHeight) +{ + rtl::OString aFont( gconf_value_get_string( aGconfValue ) ); + aFont.trim(); + sal_Int32 nIdx = aFont.lastIndexOf( ' ' ); + if (nIdx < 1) { // urk + rHeight = 12; + nIdx = aFont.getLength(); + } else { + rtl::OString aSize = aFont.copy( nIdx + 1 ); + rHeight = static_cast( aSize.toInt32() ); + } + + rName = rtl::OStringToOUString( aFont.copy( 0, nIdx ), RTL_TEXTENCODING_UTF8 ); +} + +//------------------------------------------------------------------------------ + +uno::Any translateToOOo( const ConfigurationValue aValue, GConfValue *aGconfValue ) +{ + + switch( aValue.nSettingId ) + { + case SETTING_PROXY_MODE: + { + rtl::OUString aProxyMode; + uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); + aOriginalValue >>= aProxyMode; + + if( aProxyMode.equals( rtl::OUString::createFromAscii( "manual" ) ) ) + return uno::makeAny( (sal_Int32) 1 ); + else if( aProxyMode.equals( rtl::OUString::createFromAscii( "none" ) ) ) + return uno::makeAny( (sal_Int32) 0 ); + } + break; + + case SETTING_NO_PROXY_FOR: + { + rtl::OStringBuffer aBuffer; + if( (GCONF_VALUE_LIST == aGconfValue->type) && (GCONF_VALUE_STRING == gconf_value_get_list_type(aGconfValue)) ) + { + GSList * list = gconf_value_get_list(aGconfValue); + for(; list; list = g_slist_next(list)) + { + aBuffer.append(gconf_value_get_string((GConfValue *) list->data)); + aBuffer.append(";"); + } + // Remove trailing ";" + aBuffer.setLength(aBuffer.getLength()-1); + return uno::makeAny(rtl::OStringToOUString(aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); + } + else + g_warning( "unexpected type for ignore_hosts" ); + } + break; + + case SETTING_MAILER_PROGRAM: + { + rtl::OUString aMailer; + uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); + aOriginalValue >>= aMailer; + sal_Int32 nIndex = 0; + return uno::makeAny( aMailer.getToken( 0, ' ', nIndex ) ); + } + +#ifdef ENABLE_LOCKDOWN + // "short" values need to be returned a sal_Int16 + case SETTING_FONT_ANTI_ALIASING_MIN_PIXEL: + case SETTING_SYMBOL_SET: + { + sal_Int32 nShortValue; + uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); + aOriginalValue >>= nShortValue; + return uno::makeAny( (sal_Int16) nShortValue ); + } + break; +#endif // ENABLE_LOCKDOWN + + // "boolean" values that need a string to be returned + case SETTING_ENABLE_ACCESSIBILITY: +#ifdef ENABLE_LOCKDOWN + case SETTING_DISABLE_PRINTING: +#endif // ENABLE_LOCKDOWN + { + sal_Bool bBooleanValue = false; + uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); + aOriginalValue >>= bBooleanValue; + return uno::makeAny( rtl::OUString::valueOf( (sal_Bool) bBooleanValue ) ); + } + + case SETTING_WORK_DIRECTORY: + { + rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS"); + + return uno::makeAny( aDocumentsDirURL ); + } + + case SETTING_USER_GIVENNAME: + { + rtl::OUString aCompleteName( rtl::OStringToOUString( + g_get_real_name(), osl_getThreadTextEncoding() ) ); + sal_Int32 nIndex = 0; + rtl::OUString aGivenName; + do + aGivenName = aCompleteName.getToken( 0, ' ', nIndex ); + while ( nIndex == 0 ); + + return uno::makeAny( aGivenName ); + + } + + case SETTING_USER_SURNAME: + { + rtl::OUString aCompleteName( rtl::OStringToOUString( + g_get_real_name(), osl_getThreadTextEncoding() ) ); + sal_Int32 nIndex = 0; + rtl::OUString aSurname; + do + aSurname = aCompleteName.getToken( 0, ' ', nIndex ); + while ( nIndex >= 0 ); + + return uno::makeAny( aSurname ); + } + + case SETTING_SOURCEVIEWFONT_NAME: + case SETTING_SOURCEVIEWFONT_HEIGHT: + { + rtl::OUString aName; + sal_Int16 nHeight; + + splitFontName (aGconfValue, aName, nHeight); + if (aValue.nSettingId == SETTING_SOURCEVIEWFONT_NAME) + return uno::makeAny( aName ); + else + return uno::makeAny( nHeight ); + } + + + default: + fprintf( stderr, "Unhandled setting to translate.\n" ); + break; + } + + return uno::Any(); +} + +//------------------------------------------------------------------------------ + +sal_Bool SAL_CALL isDependencySatisfied( GConfClient* aClient, const ConfigurationValue aValue ) +{ + switch( aValue.nDependsOn ) + { + case SETTING_PROXY_MODE: + { + GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_PROXY_MODE_KEY, NULL ); + + if ( aGconfValue != NULL ) + { + bool bOk = g_strcasecmp( "manual", gconf_value_get_string( aGconfValue ) ) == 0; + gconf_value_free( aGconfValue ); + if (bOk) return sal_True; + } + } + break; + + case SETTING_WORK_DIRECTORY: + { + rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS"); + osl::Directory aDocumentsDir( aDocumentsDirURL ); + + if( osl::FileBase::E_None == aDocumentsDir.open() ) + return sal_True; + } + break; + + case SETTING_USER_GIVENNAME: + { + rtl::OUString aCompleteName( rtl::OStringToOUString( + g_get_real_name(), osl_getThreadTextEncoding() ) ); + if( !aCompleteName.equalsAscii( "Unknown" ) ) + return sal_True; + } + break; + + case SETTING_USER_SURNAME: + { + rtl::OUString aCompleteName( rtl::OStringToOUString( + g_get_real_name(), osl_getThreadTextEncoding() ) ); + if( !aCompleteName.equalsAscii( "Unknown" ) ) + { + if( aCompleteName.trim().indexOf(rtl::OUString::createFromAscii(" "), 0) != -1 ) + return sal_True; + } + } + break; + +#ifdef ENABLE_LOCKDOWN + case SETTING_AUTO_SAVE: + { + GConfClient* aClient = GconfBackend::getGconfClient(); + GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_AUTO_SAVE_KEY, NULL ); + + if( ( aGconfValue != NULL ) ) + { + bool bOk = gconf_value_get_bool( aGconfValue ); + gconf_value_free( aGconfValue ); + if (bOk) return sal_True; + } + } + break; +#endif // ENABLE_LOCKDOWN + + default: + fprintf( stderr, "Unhandled setting to check dependency.\n" ); + break; + } + + return sal_False; +} + +} + +ConfigurationValue const ConfigurationValues[] = +{ + { + SETTING_ENABLE_ACCESSIBILITY, + "/desktop/gnome/interface/accessibility", + "EnableATToolSupport", + sal_True, + SETTINGS_LAST + }, + + { + SETTING_PROXY_MODE, + GCONF_PROXY_MODE_KEY, + "ooInetProxyType", + sal_True, + SETTINGS_LAST + }, + + { + SETTING_PROXY_HTTP_HOST, + "/system/http_proxy/host", + "ooInetHTTPProxyName", + sal_False, + SETTING_PROXY_MODE + }, + + { + 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 + }, + + { + SETTING_PROXY_HTTPS_PORT, + "/system/proxy/secure_port", + "ooInetHTTPSProxyPort", + sal_False, + SETTING_PROXY_MODE + }, + + { + SETTING_PROXY_FTP_HOST, + "/system/proxy/ftp_host", + "ooInetFTPProxyName", + sal_False, + SETTING_PROXY_MODE + }, + + { + SETTING_PROXY_FTP_PORT, + "/system/proxy/ftp_port", + "ooInetFTPProxyPort", + sal_False, + SETTING_PROXY_MODE + }, + + { + SETTING_NO_PROXY_FOR, + "/system/http_proxy/ignore_hosts", + "ooInetNoProxy", + sal_True, + SETTING_PROXY_MODE + }, + + { + 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 + }, + + { + 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 + }, + +#ifdef ENABLE_LOCKDOWN + { + 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 + }, + + { + SETTING_CALC_DEFAULT_DOC_FORMAT, + "/apps/openoffice/calc_default_document_format", + "SpreadsheetDocumentSetupFactoryDefaultFilter", + sal_False, + SETTINGS_LAST + }, + + { + SETTING_AUTO_SAVE, + GCONF_AUTO_SAVE_KEY, + "AutoSaveEnabled", + sal_False, + SETTINGS_LAST + }, + + { + 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 + }, + + { + 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 + }, + + { + 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::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 ) + { + css::uno::Any value; + if( data.bNeedsTranslation ) + value = translateToOOo( data, aGconfValue ); + else + value = makeAnyOfGconfValue( aGconfValue ); + + gconf_value_free( aGconfValue ); + + return value; + } + } + return css::uno::makeAny(cppu::UnoType< cppu::UnoVoidType >::get()); +} + +} diff --git a/shell/source/backends/gconfbe/gconfaccess.hxx b/shell/source/backends/gconfbe/gconfaccess.hxx new file mode 100644 index 000000000000..c986fd338da9 --- /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 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* 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 +* +* 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 + +#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::uno::Any getValue(ConfigurationValue const & data); + +} + +#endif diff --git a/shell/source/backends/gconfbe/gconfbackend.cxx b/shell/source/backends/gconfbe/gconfbackend.cxx index 504c3bba9232..cb18559c1b43 100644 --- a/shell/source/backends/gconfbe/gconfbackend.cxx +++ b/shell/source/backends/gconfbe/gconfbackend.cxx @@ -1,1011 +1,215 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: gconfbackend.cxx,v $ - * $Revision: 1.15 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* 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 +* +* for a copy of the LGPLv3 License. +************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_shell.hxx" +#include "sal/config.h" + +#include + +#include "boost/noncopyable.hpp" +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/container/XNameAccess.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/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "cppu/unotype.hxx" +#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")); +} -#include "gconfbackend.hxx" -#include "gconflayer.hxx" -#include - -#ifndef INCLUDED_VECTOR -#include -#define INCLUDED_VECTOR -#endif -#include -#include -#include -#include - -#include - -#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 - }, -}; +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); +} -// each entry should have an identifying ConfigurationSetting -static const ConfigurationValue CommonConfigurationValuesList[] = +class Service: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::container::XNameAccess >, + private boost::noncopyable { - { - 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 - }, +public: + Service(); - { - 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 - }, +private: + virtual ~Service() {} - { - SETTING_WARN_PRINT_DOC, - "/apps/openoffice/lockdown/warn_info_printing", - "org.openoffice.Office.Common/Security/Scripting/WarnPrintDoc", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return getServiceImplementationName(); } - { - SETTING_WARN_SAVEORSEND_DOC, - "/apps/openoffice/lockdown/warn_info_saving", - "org.openoffice.Office.Common/Security/Scripting/WarnSaveOrSendDoc", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } - { - SETTING_WARN_SIGN_DOC, - "/apps/openoffice/lockdown/warn_info_signing", - "org.openoffice.Office.Common/Security/Scripting/WarnSignDoc", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return getServiceSupportedServiceNames(); } - { - 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 - }, + virtual css::uno::Type SAL_CALL getElementType() + throw (css::uno::RuntimeException) + { return cppu::UnoType< cppu::UnoVoidType >::get(); } - { - SETTING_RECOMMEND_PASSWORD, - "/apps/openoffice/lockdown/recommend_password_on_save", - "org.openoffice.Office.Common/Security/Scripting/RecommendPasswordProtection", - "boolean", - sal_False, - sal_False, - SETTINGS_LAST - }, + virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException) + { return true; } - { - SETTING_UNDO_STEPS, - "/apps/openoffice/undo_steps", - "org.openoffice.Office.Common/Undo/Steps", - "int", - sal_False, - sal_False, - SETTINGS_LAST - }, + virtual css::uno::Any SAL_CALL getByName(rtl::OUString const & aName) + throw ( + css::container::NoSuchElementException, + css::lang::WrappedTargetException, css::uno::RuntimeException); - { - SETTING_SYMBOL_SET, - "/apps/openoffice/icon_size", - "org.openoffice.Office.Common/Misc/SymbolSet", - "short", - sal_False, - sal_True, - SETTINGS_LAST - }, + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getElementNames() + throw (css::uno::RuntimeException); - { - 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 + virtual sal_Bool SAL_CALL hasByName(rtl::OUString const & aName) + throw (css::uno::RuntimeException); + bool enabled_; }; -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& xContext) -{ - if(mInstance == 0) - { - mInstance = new GconfBackend (xContext); +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 } - - return mInstance; -} - -//------------------------------------------------------------------------------ - -GconfBackend::GconfBackend(const uno::Reference& xContext) - throw (backend::BackendAccessException) - : BackendBase(mMutex), m_xContext(xContext) -// , mNotificationThread(NULL) - - -{ -} - -//------------------------------------------------------------------------------ - -GconfBackend::~GconfBackend(void) { - - -// delete (mNotificationThread); - GconfBackend::mClient = NULL; - } -//------------------------------------------------------------------------------ - -GConfClient* GconfBackend::mClient= 0; - - -GConfClient* GconfBackend::getGconfClient() +css::uno::Any Service::getByName(rtl::OUString const & aName) + throw ( + css::container::NoSuchElementException, + css::lang::WrappedTargetException, css::uno::RuntimeException) { - - 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) + for (std::size_t i = 0; i < gconfaccess::nConfigurationValues; ++i) { + if (aName.equalsAscii( + gconfaccess::ConfigurationValues[i].OOoConfItem)) { - throw uno::RuntimeException(rtl::OUString::createFromAscii - ("GconfBackend:GconfLayer: Cannot Initialize Gconf connection"),NULL); + return enabled_ + ? gconfaccess::getValue(gconfaccess::ConfigurationValues[i]) + : css::uno::makeAny(cppu::UnoType< cppu::UnoVoidType >::get()); } } - - return mClient; + throw css::container::NoSuchElementException( + aName, static_cast< cppu::OWeakObject * >(this)); } -//------------------------------------------------------------------------------ - -uno::Reference SAL_CALL GconfBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException) +css::uno::Sequence< rtl::OUString > Service::getElementNames() + throw (css::uno::RuntimeException) { - uno::Reference 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 ); + css::uno::Sequence< rtl::OUString > names( + gconfaccess::nConfigurationValues); + for (std::size_t i = 0; i < gconfaccess::nConfigurationValues; ++i) { + names[i] = rtl::OUString::createFromAscii( + gconfaccess::ConfigurationValues[i].OOoConfItem); } - -#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 ); - } -#endif // ENABLE_LOCKDOWN - - return xLayer; -} - -//------------------------------------------------------------------------------ - -uno::Reference SAL_CALL -GconfBackend::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) -{ - throw lang::NoSupportException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("GconfBackend: No Update Operation allowed, Read Only access") ), - *this) ; + return names; } -//------------------------------------------------------------------------------ - -// currently not used -#if 0 -static void -keyChangedCallback(GConfClient* aClient, - guint aID, - GConfEntry* aEntry, - gpointer aBackend) +sal_Bool Service::hasByName(rtl::OUString const & aName) + throw (css::uno::RuntimeException) { - - OSL_TRACE("In KeyChangedCallback Function"); - rtl::OUString aGconfKey= rtl::OUString::createFromAscii(aEntry->key); - GconfBackend * aGconfBe = (GconfBackend*) aBackend; - - aGconfBe->notifyListeners(aGconfKey); - -} -#endif - -//------------------------------------------------------------------------------ - -void GconfBackend::notifyListeners(const rtl::OUString& /*aGconfKey*/) -{ -/* - //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 (aName.equalsAscii( + gconfaccess::ConfigurationValues[i].OOoConfItem)) { - aComponent = aIter->first; - break; + return true; } - - } - - - //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 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); - - } -*/ + return false; } - -//------------------------------------------------------------------------------ -void SAL_CALL GconfBackend::addChangesListener( - const uno::Reference& xListener, - const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException) -{ -/* - 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 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)); - - -} -//------------------------------------------------------------------------------ -void SAL_CALL GconfBackend::removeChangesListener( - const uno::Reference& /*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 = 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 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") ); + return static_cast< cppu::OWeakObject * >(new Service); } -//------------------------------------------------------------------------------ +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 SAL_CALL GconfBackend::getBackendServiceNames(void) +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) { - uno::Sequence 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 -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 721586a80186..000000000000 --- a/shell/source/backends/gconfbe/gconfbackend.hxx +++ /dev/null @@ -1,225 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: gconfbackend.hxx,v $ - * $Revision: 1.8 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef GCONFBACKEND_HXX_ -#define GCONFBACKEND_HXX_ - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XSCHEMASUPPLIER_HPP_ -#include -#endif -#include -#include -#include - -//#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -//#include -//#endif // _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include -#include -#include -#include - -#ifndef INCLUDED_MAP -#include -#define INCLUDED_MAP -#endif -//#ifndef _VOS_THREAD_HXX_ -//#include -//#endif - -#include - - -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 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 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 BackendBase ; - -/** - Implements the SingleLayerStratum service for gconf access. - */ -class GconfBackend : public BackendBase { - public : - - static GconfBackend* createInstance(const uno::Reference& 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 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 SAL_CALL getBackendServiceNames(void) ; - - /* returns a GconfClient */ - static GConfClient* getGconfClient(); - - //XSingleLayerStratum - virtual uno::Reference SAL_CALL - getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp ) - throw (backend::BackendAccessException, lang::IllegalArgumentException) ; - - virtual uno::Reference SAL_CALL - getUpdatableLayer( const rtl::OUString& aLayerId ) - throw (backend::BackendAccessException, lang::NoSupportException, - lang::IllegalArgumentException) ; - - // XBackendChangesNotifier - virtual void SAL_CALL addChangesListener( - const uno::Reference& xListener, - const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException); - - - virtual void SAL_CALL removeChangesListener( - const uno::Reference& xListener, - const rtl::OUString& aComponent) - throw (::com::sun::star::uno::RuntimeException); - - //Notify all listener of component change - void notifyListeners(const rtl::OUString& aGconfKey); - - protected: - /** - Service constructor from a service factory. - - @param xContext component context - */ - GconfBackend(const uno::Reference& xContext) - throw (backend::BackendAccessException); - - /** Destructor */ - ~GconfBackend(void) ; - - private: - - typedef uno::Reference ListenerRef; - typedef std::multimap ListenerList; - - /** Build Gconf/OO mapping table */ - void initializeMappingTable (); - - - /** The component context */ - uno::Reference 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 @@ - - - - gconfbe - - Oliver Braun - com.sun.star.comp.configuration.backend.GconfBackend - The - com.sun.star.loader.SharedLibrary - c++ - - com.sun.star.comp.configuration.backend.GconfBackend - ... - com.sun.star.configuration.backend.XBackendChangesListener - com.sun.star.configuration.backend.XBackendChangesNotifier - com.sun.star.configuration.backend.XLayerHandler - com.sun.star.configuration.backend.XSingleLayerStratum - com.sun.star.lang.XMultiComponentFactory - com.sun.star.lang.XServiceInfo - com.sun.star.lang.XSingleComponentFactory - com.sun.star.lang.XTypeProvider - com.sun.star.uno.TypeClass - com.sun.star.uno.XAggregation - com.sun.star.uno.XComponentContext - com.sun.star.uno.XCurrentContext - com.sun.star.uno.XWeak - com.sun.star.registry.XRegistryKey - - cppuhelper - cppu - sal - cppuhelper3$(COM) - cppu3 - sal3 - diff --git a/shell/source/backends/gconfbe/gconfbecdef.cxx b/shell/source/backends/gconfbe/gconfbecdef.cxx deleted file mode 100644 index ed20759faa7e..000000000000 --- a/shell/source/backends/gconfbe/gconfbecdef.cxx +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: gconfbecdef.cxx,v $ - * $Revision: 1.11 $ - * - * 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 - * - * 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 - -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include -#endif // _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include -#include - -#include "uno/current_context.hxx" -#include -#include "orbit.h" - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -//============================================================================== - -static uno::Reference SAL_CALL createGconfBackend(const uno::Reference& 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(); - - } catch (uno::RuntimeException e) { - return uno::Reference(); - } - -} - -//============================================================================== - -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 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.cxx b/shell/source/backends/gconfbe/gconflayer.cxx deleted file mode 100644 index 9d7ac2e8e47b..000000000000 --- a/shell/source/backends/gconfbe/gconflayer.cxx +++ /dev/null @@ -1,564 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: gconflayer.cxx,v $ - * $Revision: 1.15 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "gconflayer.hxx" -#include - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include -#endif -#include -#include -#include -#include -#include -#include - -#include - -using namespace rtl; - -//============================================================================== - -GconfLayer::GconfLayer( const uno::Reference& 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" ) ); - - typedef uno::Reference 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" ); - } -} - -//------------------------------------------------------------------------------ - -static OUString xdg_user_dir_lookup (const char *type) -{ - char *config_home; - char *p; - int relative; - bool bError = false; - - osl::Security aSecurity; - oslFileHandle handle; - OUString aHomeDirURL; - OUString aDocumentsDirURL; - OUString aConfigFileURL; - OUStringBuffer aUserDirBuf; - - if (!aSecurity.getHomeDir( aHomeDirURL ) ) - { - osl::FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii("/tmp"), aDocumentsDirURL); - return aDocumentsDirURL; - } - - config_home = getenv ("XDG_CONFIG_HOME"); - if (config_home == NULL || config_home[0] == 0) - { - aConfigFileURL = OUString(aHomeDirURL); - aConfigFileURL += OUString::createFromAscii( "/.config/user-dirs.dirs" ); - } - else - { - aConfigFileURL = OUString::createFromAscii(config_home); - aConfigFileURL += OUString::createFromAscii( "/user-dirs.dirs" ); - } - - if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read)) - { - rtl::ByteSequence seq; - while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq)) - { - /* Remove newline at end */ - int len = seq.getLength(); - if(len>0 && seq[len-1] == '\n') - seq[len-1] = 0; - - p = (char *)seq.getArray(); - - while (*p == ' ' || *p == '\t') - p++; - - if (strncmp (p, "XDG_", 4) != 0) - continue; - p += 4; - if (strncmp (p, type, strlen (type)) != 0) - continue; - p += strlen (type); - if (strncmp (p, "_DIR", 4) != 0) - continue; - p += 4; - - while (*p == ' ' || *p == '\t') - p++; - - if (*p != '=') - continue; - p++; - - while (*p == ' ' || *p == '\t') - p++; - - if (*p != '"') - continue; - p++; - - relative = 0; - if (strncmp (p, "$HOME/", 6) == 0) - { - p += 6; - relative = 1; - } - else if (*p != '/') - continue; - - if (relative) - { - aUserDirBuf = OUStringBuffer(aHomeDirURL); - aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) ); - } - else - { - aUserDirBuf = OUStringBuffer(); - } - - while (*p && *p != '"') - { - if ((*p == '\\') && (*(p+1) != 0)) - p++; - aUserDirBuf.append((sal_Unicode)*p++); - } - } - osl_closeFile(handle); - } - else - bError = true; - - if (aUserDirBuf.getLength()>0 && !bError) - { - aDocumentsDirURL = aUserDirBuf.makeStringAndClear(); - osl::Directory aDocumentsDir( aDocumentsDirURL ); - if( osl::FileBase::E_None == aDocumentsDir.open() ) - return aDocumentsDirURL; - } - - /* Special case desktop for historical compatibility */ - if (strcmp (type, "DESKTOP") == 0) - { - aUserDirBuf = OUStringBuffer(aHomeDirURL); - aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) ); - return aUserDirBuf.makeStringAndClear(); - } - else - { - aUserDirBuf = OUStringBuffer(aHomeDirURL); - aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) ); - return aUserDirBuf.makeStringAndClear(); - } -} - -//------------------------------------------------------------------------------ - -uno::Any makeAnyOfGconfValue( GConfValue *aGconfValue ) -{ - switch( aGconfValue->type ) - { - case GCONF_VALUE_BOOL: - return uno::makeAny( (sal_Bool) gconf_value_get_bool( aGconfValue ) ); - - case GCONF_VALUE_INT: - return uno::makeAny( (sal_Int32) gconf_value_get_int( aGconfValue ) ); - - case GCONF_VALUE_STRING: - return uno::makeAny( OStringToOUString( rtl::OString( - gconf_value_get_string(aGconfValue) ), RTL_TEXTENCODING_UTF8 ) ); - - default: - fprintf( stderr, "makeAnyOfGconfValue: Type not handled.\n" ); - break; - } - - return uno::Any(); -} - -//------------------------------------------------------------------------------ - -static void splitFontName( GConfValue *aGconfValue, rtl::OUString &rName, sal_Int16 &rHeight) -{ - rtl::OString aFont( gconf_value_get_string( aGconfValue ) ); - aFont.trim(); - sal_Int32 nIdx = aFont.lastIndexOf( ' ' ); - if (nIdx < 1) { // urk - rHeight = 12; - nIdx = aFont.getLength(); - } else { - rtl::OString aSize = aFont.copy( nIdx + 1 ); - rHeight = static_cast( aSize.toInt32() ); - } - - rName = rtl::OStringToOUString( aFont.copy( 0, nIdx ), RTL_TEXTENCODING_UTF8 ); -} - -//------------------------------------------------------------------------------ - -uno::Any translateToOOo( const ConfigurationValue aValue, GConfValue *aGconfValue ) -{ - - switch( aValue.nSettingId ) - { - case SETTING_PROXY_MODE: - { - rtl::OUString aProxyMode; - uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); - aOriginalValue >>= aProxyMode; - - if( aProxyMode.equals( rtl::OUString::createFromAscii( "manual" ) ) ) - return uno::makeAny( (sal_Int32) 1 ); - else if( aProxyMode.equals( rtl::OUString::createFromAscii( "none" ) ) ) - return uno::makeAny( (sal_Int32) 0 ); - } - break; - - case SETTING_NO_PROXY_FOR: - { - rtl::OStringBuffer aBuffer; - if( (GCONF_VALUE_LIST == aGconfValue->type) && (GCONF_VALUE_STRING == gconf_value_get_list_type(aGconfValue)) ) - { - GSList * list = gconf_value_get_list(aGconfValue); - for(; list; list = g_slist_next(list)) - { - aBuffer.append(gconf_value_get_string((GConfValue *) list->data)); - aBuffer.append(";"); - } - // Remove trailing ";" - aBuffer.setLength(aBuffer.getLength()-1); - return uno::makeAny(rtl::OStringToOUString(aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); - } - else - g_warning( "unexpected type for ignore_hosts" ); - } - break; - - case SETTING_MAILER_PROGRAM: - { - rtl::OUString aMailer; - uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); - aOriginalValue >>= aMailer; - sal_Int32 nIndex = 0; - return uno::makeAny( aMailer.getToken( 0, ' ', nIndex ) ); - } - -#ifdef ENABLE_LOCKDOWN - // "short" values need to be returned a sal_Int16 - case SETTING_FONT_ANTI_ALIASING_MIN_PIXEL: - case SETTING_SYMBOL_SET: - { - sal_Int32 nShortValue; - uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); - aOriginalValue >>= nShortValue; - return uno::makeAny( (sal_Int16) nShortValue ); - } - break; -#endif // ENABLE_LOCKDOWN - - // "boolean" values that need a string to be returned - case SETTING_ENABLE_ACCESSIBILITY: -#ifdef ENABLE_LOCKDOWN - case SETTING_DISABLE_PRINTING: -#endif // ENABLE_LOCKDOWN - { - sal_Bool bBooleanValue = false; - uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); - aOriginalValue >>= bBooleanValue; - return uno::makeAny( rtl::OUString::valueOf( (sal_Bool) bBooleanValue ) ); - } - - case SETTING_WORK_DIRECTORY: - { - rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS"); - - return uno::makeAny( aDocumentsDirURL ); - } - - case SETTING_USER_GIVENNAME: - { - rtl::OUString aCompleteName( rtl::OStringToOUString( - g_get_real_name(), osl_getThreadTextEncoding() ) ); - sal_Int32 nIndex = 0; - rtl::OUString aGivenName; - do - aGivenName = aCompleteName.getToken( 0, ' ', nIndex ); - while ( nIndex == 0 ); - - return uno::makeAny( aGivenName ); - - } - - case SETTING_USER_SURNAME: - { - rtl::OUString aCompleteName( rtl::OStringToOUString( - g_get_real_name(), osl_getThreadTextEncoding() ) ); - sal_Int32 nIndex = 0; - rtl::OUString aSurname; - do - aSurname = aCompleteName.getToken( 0, ' ', nIndex ); - while ( nIndex >= 0 ); - - return uno::makeAny( aSurname ); - } - - case SETTING_SOURCEVIEWFONT_NAME: - case SETTING_SOURCEVIEWFONT_HEIGHT: - { - rtl::OUString aName; - sal_Int16 nHeight; - - splitFontName (aGconfValue, aName, nHeight); - if (aValue.nSettingId == SETTING_SOURCEVIEWFONT_NAME) - return uno::makeAny( aName ); - else - return uno::makeAny( nHeight ); - } - - - default: - fprintf( stderr, "Unhandled setting to translate.\n" ); - break; - } - - return uno::Any(); -} - -//------------------------------------------------------------------------------ - -sal_Bool SAL_CALL isDependencySatisfied( 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 ) - { - bool bOk = g_strcasecmp( "manual", gconf_value_get_string( aGconfValue ) ) == 0; - gconf_value_free( aGconfValue ); - if (bOk) return sal_True; - } - } - break; - - case SETTING_WORK_DIRECTORY: - { - rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS"); - osl::Directory aDocumentsDir( aDocumentsDirURL ); - - if( osl::FileBase::E_None == aDocumentsDir.open() ) - return sal_True; - } - break; - - case SETTING_USER_GIVENNAME: - { - rtl::OUString aCompleteName( rtl::OStringToOUString( - g_get_real_name(), osl_getThreadTextEncoding() ) ); - if( !aCompleteName.equalsAscii( "Unknown" ) ) - return sal_True; - } - break; - - case SETTING_USER_SURNAME: - { - rtl::OUString aCompleteName( rtl::OStringToOUString( - g_get_real_name(), osl_getThreadTextEncoding() ) ); - if( !aCompleteName.equalsAscii( "Unknown" ) ) - { - if( aCompleteName.trim().indexOf(rtl::OUString::createFromAscii(" "), 0) != -1 ) - return sal_True; - } - } - break; - -#ifdef ENABLE_LOCKDOWN - case SETTING_AUTO_SAVE: - { - GConfClient* aClient = GconfBackend::getGconfClient(); - GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_AUTO_SAVE_KEY, NULL ); - - if( ( aGconfValue != NULL ) ) - { - bool bOk = gconf_value_get_bool( aGconfValue ); - gconf_value_free( aGconfValue ); - if (bOk) return sal_True; - } - } - break; -#endif // ENABLE_LOCKDOWN - - default: - fprintf( stderr, "Unhandled setting to check dependency.\n" ); - break; - } - - return sal_False; -} - -//------------------------------------------------------------------------------ - -void SAL_CALL GconfLayer::readData( const uno::Reference& 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 aPropInfoList( m_nConfigurationValues ); - sal_Int32 nProperties = 0; - - GConfClient* aClient = GconfBackend::getGconfClient(); - GConfValue* aGconfValue; - int i = 0; - - while( m_pPreloadValuesList[i] != NULL ) - gconf_client_preload( aClient, m_pPreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL ); - - for( i = 0; i < m_nConfigurationValues; i++ ) - { - if( ( m_pConfigurationValuesList[i].nDependsOn != SETTINGS_LAST ) && !isDependencySatisfied( m_pConfigurationValuesList[i] ) ) - continue; - - aGconfValue = gconf_client_get( aClient, m_pConfigurationValuesList[i].GconfItem, NULL ); - - 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; - - if( m_pConfigurationValuesList[i].bNeedsTranslation ) - aPropInfoList[nProperties].Value = translateToOOo( m_pConfigurationValuesList[i], aGconfValue ); - else - aPropInfoList[nProperties].Value = makeAnyOfGconfValue( aGconfValue ); - - gconf_value_free( aGconfValue ); - - nProperties++; - } - } - - if( nProperties > 0 ) - { - aPropInfoList.realloc( nProperties ); - m_xLayerContentDescriber->describeLayer( xHandler, aPropInfoList ); - } -} - -//------------------------------------------------------------------------------ - -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; - - // Make sure the timestamp differs from beta - sal_Int32 nHashCode = 0; - - GConfClient* aClient = GconfBackend::getGconfClient(); - GConfValue* aGconfValue; - int i = 0; - - while( m_pPreloadValuesList[i] != NULL ) - gconf_client_preload( aClient, m_pPreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL ); - - for( i = 0; i < m_nConfigurationValues; i++ ) - { - aGconfValue = gconf_client_get( aClient, m_pConfigurationValuesList[i].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; - gconf_value_free( aGconfValue ); - } - } - - return rtl::OUString::valueOf( nHashCode ); -} 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 -#include - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include -#endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include -#include - -#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 -{ -public : - /** - Constructor given the component context - - @param xContext The component context - */ - - GconfLayer( const uno::Reference& xContext, - const ConfigurationValue pConfigurationValuesList[], - const sal_Int32 nConfigurationValues, - const char * pPreloadValuesList[] ); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference& 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 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 472db4b244a3..aae7af45b106 100644 --- a/shell/source/backends/gconfbe/makefile.mk +++ b/shell/source/backends/gconfbe/makefile.mk @@ -35,8 +35,7 @@ TARGET=gconfbe LIBTARGET=NO ENABLE_EXCEPTIONS=TRUE - -COMP1TYPELIST=$(TARGET) +VISIBILITY_HIDDEN=TRUE # --- Settings --- @@ -69,9 +68,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 @@ -86,7 +84,6 @@ SHL1STDLIBS= \ SHL1STDLIBS+=$(PKGCONFIG_LIBS) -SHL1VERSIONMAP=exports.map SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME=$(SHL1TARGET) -- cgit