2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-02 14:13:40 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-09-30 09:14:44 +02:00
|
|
|
|
|
|
|
#include "sal/config.h"
|
|
|
|
|
|
|
|
#include "boost/noncopyable.hpp"
|
2009-10-01 13:40:46 +02:00
|
|
|
#include "com/sun/star/beans/Optional.hpp"
|
|
|
|
#include "com/sun/star/beans/PropertyVetoException.hpp"
|
|
|
|
#include "com/sun/star/beans/UnknownPropertyException.hpp"
|
|
|
|
#include "com/sun/star/beans/XPropertyChangeListener.hpp"
|
|
|
|
#include "com/sun/star/beans/XPropertySet.hpp"
|
|
|
|
#include "com/sun/star/beans/XPropertySetInfo.hpp"
|
|
|
|
#include "com/sun/star/beans/XVetoableChangeListener.hpp"
|
|
|
|
#include "com/sun/star/lang/IllegalArgumentException.hpp"
|
|
|
|
#include "com/sun/star/lang/WrappedTargetException.hpp"
|
2009-09-30 09:14:44 +02:00
|
|
|
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
|
|
|
|
#include "com/sun/star/lang/XServiceInfo.hpp"
|
|
|
|
#include "com/sun/star/uno/Any.hxx"
|
|
|
|
#include "com/sun/star/uno/Exception.hpp"
|
2009-10-01 13:40:46 +02:00
|
|
|
#include "com/sun/star/uno/Reference.hxx"
|
2009-09-30 09:14:44 +02:00
|
|
|
#include "com/sun/star/uno/RuntimeException.hpp"
|
|
|
|
#include "com/sun/star/uno/Sequence.hxx"
|
|
|
|
#include "com/sun/star/uno/XComponentContext.hpp"
|
|
|
|
#include "com/sun/star/uno/XCurrentContext.hpp"
|
|
|
|
#include "cppuhelper/factory.hxx"
|
2015-09-03 09:33:40 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2009-09-30 09:14:44 +02:00
|
|
|
#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"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SAL_CALL getDefaultImplementationName() {
|
|
|
|
return OUString(
|
2013-03-19 09:22:44 +01:00
|
|
|
"com.sun.star.comp.configuration.backend.DesktopBackend");
|
2009-09-30 09:14:44 +02:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
css::uno::Sequence< OUString > SAL_CALL getDefaultSupportedServiceNames() {
|
|
|
|
OUString name(
|
2013-03-19 11:39:07 +01:00
|
|
|
"com.sun.star.configuration.backend.DesktopBackend");
|
2013-04-07 12:06:47 +02:00
|
|
|
return css::uno::Sequence< OUString >(&name, 1);
|
2009-09-30 09:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class Default:
|
2015-09-03 09:33:40 +09:00
|
|
|
public cppu::WeakImplHelper<
|
2009-10-01 13:40:46 +02:00
|
|
|
css::lang::XServiceInfo, css::beans::XPropertySet >,
|
2009-09-30 09:14:44 +02:00
|
|
|
private boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Default() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~Default() {}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual OUString SAL_CALL getImplementationName()
|
2015-10-12 16:04:04 +02:00
|
|
|
throw (css::uno::RuntimeException, std::exception) override
|
2009-09-30 09:14:44 +02:00
|
|
|
{ return getDefaultImplementationName(); }
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
|
2015-10-12 16:04:04 +02:00
|
|
|
throw (css::uno::RuntimeException, std::exception) override
|
2009-09-30 09:14:44 +02:00
|
|
|
{ return ServiceName == getSupportedServiceNames()[0]; }
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual css::uno::Sequence< OUString > SAL_CALL
|
2015-10-12 16:04:04 +02:00
|
|
|
getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) override
|
2009-09-30 09:14:44 +02:00
|
|
|
{ return getDefaultSupportedServiceNames(); }
|
|
|
|
|
2009-10-01 13:40:46 +02:00
|
|
|
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
|
2015-10-12 16:04:04 +02:00
|
|
|
getPropertySetInfo() throw (css::uno::RuntimeException, std::exception) override
|
2009-10-01 13:40:46 +02:00
|
|
|
{ return css::uno::Reference< css::beans::XPropertySetInfo >(); }
|
2009-09-30 09:14:44 +02:00
|
|
|
|
2009-10-01 13:40:46 +02:00
|
|
|
virtual void SAL_CALL setPropertyValue(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const &, css::uno::Any const &)
|
2009-10-01 13:40:46 +02:00
|
|
|
throw (
|
|
|
|
css::beans::UnknownPropertyException,
|
|
|
|
css::beans::PropertyVetoException,
|
|
|
|
css::lang::IllegalArgumentException,
|
2015-10-12 16:04:04 +02:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
|
2009-09-30 09:14:44 +02:00
|
|
|
|
2009-10-01 13:40:46 +02:00
|
|
|
virtual css::uno::Any SAL_CALL getPropertyValue(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const & PropertyName)
|
2009-09-30 09:14:44 +02:00
|
|
|
throw (
|
2009-10-01 13:40:46 +02:00
|
|
|
css::beans::UnknownPropertyException,
|
2015-10-12 16:04:04 +02:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
|
2009-09-30 09:14:44 +02:00
|
|
|
|
2009-10-01 13:40:46 +02:00
|
|
|
virtual void SAL_CALL addPropertyChangeListener(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const &,
|
2009-10-01 13:40:46 +02:00
|
|
|
css::uno::Reference< css::beans::XPropertyChangeListener > const &)
|
|
|
|
throw (
|
|
|
|
css::beans::UnknownPropertyException,
|
2015-10-12 16:04:04 +02:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override
|
2009-10-01 13:40:46 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void SAL_CALL removePropertyChangeListener(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const &,
|
2009-10-01 13:40:46 +02:00
|
|
|
css::uno::Reference< css::beans::XPropertyChangeListener > const &)
|
|
|
|
throw (
|
|
|
|
css::beans::UnknownPropertyException,
|
2015-10-12 16:04:04 +02:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override
|
2009-10-01 13:40:46 +02:00
|
|
|
{}
|
2009-09-30 09:14:44 +02:00
|
|
|
|
2009-10-01 13:40:46 +02:00
|
|
|
virtual void SAL_CALL addVetoableChangeListener(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const &,
|
2009-10-01 13:40:46 +02:00
|
|
|
css::uno::Reference< css::beans::XVetoableChangeListener > const &)
|
|
|
|
throw (
|
|
|
|
css::beans::UnknownPropertyException,
|
2015-10-12 16:04:04 +02:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override
|
2009-10-01 13:40:46 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void SAL_CALL removeVetoableChangeListener(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const &,
|
2009-10-01 13:40:46 +02:00
|
|
|
css::uno::Reference< css::beans::XVetoableChangeListener > const &)
|
|
|
|
throw (
|
|
|
|
css::beans::UnknownPropertyException,
|
2015-10-12 16:04:04 +02:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override
|
2009-10-01 13:40:46 +02:00
|
|
|
{}
|
2009-09-30 09:14:44 +02:00
|
|
|
};
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void Default::setPropertyValue(OUString const &, css::uno::Any const &)
|
2009-09-30 09:14:44 +02:00
|
|
|
throw (
|
2009-10-01 13:40:46 +02:00
|
|
|
css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
|
|
|
|
css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
|
2014-02-25 21:31:58 +01:00
|
|
|
css::uno::RuntimeException, std::exception)
|
2009-09-30 09:14:44 +02:00
|
|
|
{
|
2009-10-01 13:40:46 +02:00
|
|
|
throw css::lang::IllegalArgumentException(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString("setPropertyValue not supported"),
|
2009-10-01 13:40:46 +02:00
|
|
|
static_cast< cppu::OWeakObject * >(this), -1);
|
2009-09-30 09:14:44 +02:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
css::uno::Any Default::getPropertyValue(OUString const & PropertyName)
|
2009-10-01 13:40:46 +02:00
|
|
|
throw (
|
|
|
|
css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
|
2014-02-25 21:31:58 +01:00
|
|
|
css::uno::RuntimeException, std::exception)
|
2009-09-30 09:14:44 +02:00
|
|
|
{
|
2014-02-24 11:38:13 +00:00
|
|
|
if ( PropertyName == "EnableATToolSupport" ||
|
|
|
|
PropertyName == "ExternalMailer" ||
|
|
|
|
PropertyName == "SourceViewFontHeight" ||
|
|
|
|
PropertyName == "SourceViewFontName" ||
|
|
|
|
PropertyName == "TemplatePathVariable" ||
|
|
|
|
PropertyName == "WorkPathVariable" ||
|
|
|
|
PropertyName == "ooInetFTPProxyName" ||
|
|
|
|
PropertyName == "ooInetFTPProxyPort" ||
|
|
|
|
PropertyName == "ooInetHTTPProxyName" ||
|
|
|
|
PropertyName == "ooInetHTTPProxyPort" ||
|
|
|
|
PropertyName == "ooInetHTTPSProxyName" ||
|
|
|
|
PropertyName == "ooInetHTTPSProxyPort" ||
|
|
|
|
PropertyName == "ooInetNoProxy" ||
|
|
|
|
PropertyName == "ooInetProxyType" ||
|
|
|
|
PropertyName == "givenname" ||
|
|
|
|
PropertyName == "sn" )
|
2009-10-01 13:40:46 +02:00
|
|
|
{
|
|
|
|
return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
|
2009-09-30 09:14:44 +02:00
|
|
|
}
|
2009-10-01 13:40:46 +02:00
|
|
|
throw css::beans::UnknownPropertyException(
|
|
|
|
PropertyName, static_cast< cppu::OWeakObject * >(this));
|
2009-09-30 09:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
css::uno::Reference< css::uno::XInterface > createBackend(
|
|
|
|
css::uno::Reference< css::uno::XComponentContext > const & context,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString const & name)
|
2009-09-30 09:14:44 +02:00
|
|
|
{
|
|
|
|
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;
|
2011-12-26 03:38:13 +09:00
|
|
|
} catch (const css::uno::Exception & e) {
|
2009-09-30 09:14:44 +02:00
|
|
|
// Assuming these exceptions indicate that the service is not installed:
|
|
|
|
OSL_TRACE(
|
|
|
|
"createInstance(%s) failed with %s",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(name, RTL_TEXTENCODING_UTF8).getStr(),
|
|
|
|
OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
|
2009-09-30 09:14:44 +02:00
|
|
|
return css::uno::Reference< css::uno::XInterface >();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
|
|
|
|
css::uno::Reference< css::uno::XComponentContext > const & context)
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString desktop;
|
2009-09-30 09:14:44 +02:00
|
|
|
css::uno::Reference< css::uno::XCurrentContext > current(
|
|
|
|
css::uno::getCurrentContext());
|
|
|
|
if (current.is()) {
|
|
|
|
current->getValueByName(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString("system.desktop-environment")) >>=
|
2009-09-30 09:14:44 +02:00
|
|
|
desktop;
|
|
|
|
}
|
2012-07-09 09:47:52 +01:00
|
|
|
|
2009-09-30 09:14:44 +02:00
|
|
|
// Fall back to the default if the specific backend is not available:
|
|
|
|
css::uno::Reference< css::uno::XInterface > backend;
|
2012-04-06 15:37:46 +02:00
|
|
|
if ( desktop == "GNOME" ) {
|
2009-09-30 09:14:44 +02:00
|
|
|
backend = createBackend(
|
|
|
|
context,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString(
|
2013-03-19 09:22:44 +01:00
|
|
|
"com.sun.star.configuration.backend.GconfBackend"));
|
2012-04-06 15:37:46 +02:00
|
|
|
} else if ( desktop == "KDE" ) {
|
2009-09-30 09:14:44 +02:00
|
|
|
backend = createBackend(
|
|
|
|
context,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString(
|
2013-03-19 09:22:44 +01:00
|
|
|
"com.sun.star.configuration.backend.KDEBackend"));
|
2012-04-06 15:37:46 +02:00
|
|
|
} else if ( desktop == "KDE4" ) {
|
2009-10-01 10:39:31 +02:00
|
|
|
backend = createBackend(
|
|
|
|
context,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString(
|
2013-03-19 09:22:44 +01:00
|
|
|
"com.sun.star.configuration.backend.KDE4Backend"));
|
2009-10-01 10:39:31 +02:00
|
|
|
}
|
2009-09-30 09:14:44 +02:00
|
|
|
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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-12 18:06:31 +02:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL desktopbe1_component_getFactory(
|
2009-09-30 09:14:44 +02:00
|
|
|
char const * pImplName, void * pServiceManager, void * pRegistryKey)
|
|
|
|
{
|
|
|
|
return cppu::component_getFactoryHelper(
|
|
|
|
pImplName, pServiceManager, pRegistryKey, services);
|
|
|
|
}
|
|
|
|
|
2011-04-21 00:27:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|