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 .
|
|
|
|
*/
|
2006-06-02 11:24:22 +00:00
|
|
|
|
2009-10-01 10:39:31 +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-10-01 10:39:31 +02:00
|
|
|
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
|
|
|
|
#include "com/sun/star/lang/XServiceInfo.hpp"
|
|
|
|
#include "com/sun/star/uno/Any.hxx"
|
2009-10-01 13:40:46 +02:00
|
|
|
#include "com/sun/star/uno/Reference.hxx"
|
2009-10-01 10:39:31 +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"
|
|
|
|
#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"
|
2006-06-02 11:24:22 +00:00
|
|
|
|
2012-05-14 20:09:41 -05:00
|
|
|
#include "shell/kde_headers.h"
|
2009-10-01 10:39:31 +02:00
|
|
|
|
|
|
|
#include "kdeaccess.hxx"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SAL_CALL getServiceImplementationName() {
|
|
|
|
return OUString(
|
2013-03-19 09:22:44 +01:00
|
|
|
"com.sun.star.comp.configuration.backend.KDEBackend");
|
2009-10-01 10:39:31 +02:00
|
|
|
}
|
2006-06-02 11:24:22 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
css::uno::Sequence< OUString > SAL_CALL getServiceSupportedServiceNames() {
|
|
|
|
OUString name(
|
2013-03-19 11:39:07 +01:00
|
|
|
"com.sun.star.configuration.backend.KDEBackend");
|
2013-04-07 12:06:47 +02:00
|
|
|
return css::uno::Sequence< OUString >(&name, 1);
|
2009-10-01 10:39:31 +02:00
|
|
|
}
|
2006-06-02 11:24:22 +00:00
|
|
|
|
2009-10-01 10:39:31 +02:00
|
|
|
class Service:
|
|
|
|
public cppu::WeakImplHelper2<
|
2009-10-01 13:40:46 +02:00
|
|
|
css::lang::XServiceInfo, css::beans::XPropertySet >,
|
2009-10-01 10:39:31 +02:00
|
|
|
private boost::noncopyable
|
2006-06-02 11:24:22 +00:00
|
|
|
{
|
2009-10-01 10:39:31 +02:00
|
|
|
public:
|
|
|
|
Service();
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~Service() {}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual OUString SAL_CALL getImplementationName()
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
|
2009-10-01 10:39:31 +02:00
|
|
|
{ return getServiceImplementationName(); }
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
|
2009-10-01 10:39:31 +02:00
|
|
|
{ return ServiceName == getSupportedServiceNames()[0]; }
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual css::uno::Sequence< OUString > SAL_CALL
|
2014-03-26 16:37:00 +01:00
|
|
|
getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
|
2009-10-01 10:39:31 +02:00
|
|
|
{ return getServiceSupportedServiceNames(); }
|
|
|
|
|
2009-10-01 13:40:46 +02:00
|
|
|
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
|
2014-03-26 16:37:00 +01:00
|
|
|
getPropertySetInfo() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
|
2009-10-01 13:40:46 +02:00
|
|
|
{ return css::uno::Reference< css::beans::XPropertySetInfo >(); }
|
2009-10-01 10:39:31 +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,
|
2014-03-26 16:37:00 +01:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2009-10-01 10:39:31 +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-10-01 10:39:31 +02:00
|
|
|
throw (
|
2009-10-01 13:40:46 +02:00
|
|
|
css::beans::UnknownPropertyException,
|
2014-03-26 16:37:00 +01:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2009-10-01 10:39:31 +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,
|
2014-03-26 16:37:00 +01:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_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,
|
2014-03-26 16:37:00 +01:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
|
2009-10-01 13:40:46 +02:00
|
|
|
{}
|
2009-10-01 10:39:31 +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,
|
2014-03-26 16:37:00 +01:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_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,
|
2014-03-26 16:37:00 +01:00
|
|
|
css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
|
2009-10-01 13:40:46 +02:00
|
|
|
{}
|
2009-10-01 10:39:31 +02:00
|
|
|
|
|
|
|
bool enabled_;
|
|
|
|
};
|
|
|
|
|
|
|
|
Service::Service(): enabled_(false) {
|
|
|
|
css::uno::Reference< css::uno::XCurrentContext > context(
|
|
|
|
css::uno::getCurrentContext());
|
|
|
|
if (context.is()) {
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString desktop;
|
2009-10-01 10:39:31 +02:00
|
|
|
context->getValueByName(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString("system.desktop-environment")) >>=
|
2009-10-01 10:39:31 +02:00
|
|
|
desktop;
|
2012-04-06 19:49:53 +02:00
|
|
|
enabled_ = desktop == "KDE" && KApplication::kApplication() != 0;
|
2006-06-02 11:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void Service::setPropertyValue(OUString const &, css::uno::Any const &)
|
2009-10-01 10:39:31 +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)
|
2006-06-02 11:24:22 +00: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);
|
2006-06-02 11:24:22 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
css::uno::Any Service::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)
|
2006-06-02 11:24:22 +00:00
|
|
|
{
|
2012-04-06 19:49:53 +02:00
|
|
|
if ( PropertyName == "EnableATToolSupport" || PropertyName == "ExternalMailer" || PropertyName == "SourceViewFontHeight"
|
|
|
|
|| PropertyName == "SourceViewFontName" || PropertyName == "WorkPathVariable" || PropertyName == "ooInetFTPProxyName"
|
|
|
|
|| PropertyName == "ooInetFTPProxyPort" || PropertyName == "ooInetHTTPProxyName" || PropertyName == "ooInetHTTPProxyPort"
|
|
|
|
|| PropertyName == "ooInetHTTPSProxyName" || PropertyName == "ooInetHTTPSProxyPort" || PropertyName == "ooInetNoProxy"
|
2014-02-26 17:02:38 +02:00
|
|
|
|| PropertyName == "ooInetProxyType" || PropertyName == "TemplatePathVariable" )
|
2009-10-01 13:40:46 +02:00
|
|
|
{
|
|
|
|
return css::uno::makeAny(
|
|
|
|
enabled_
|
|
|
|
? kdeaccess::getValue(PropertyName)
|
|
|
|
: css::beans::Optional< css::uno::Any >());
|
2006-07-13 11:31:31 +00:00
|
|
|
}
|
2009-10-01 13:40:46 +02:00
|
|
|
throw css::beans::UnknownPropertyException(
|
|
|
|
PropertyName, static_cast< cppu::OWeakObject * >(this));
|
2006-06-02 11:24:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 10:39:31 +02:00
|
|
|
css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
|
|
|
|
css::uno::Reference< css::uno::XComponentContext > const &)
|
2006-06-02 11:24:22 +00:00
|
|
|
{
|
2009-10-01 10:39:31 +02:00
|
|
|
return static_cast< cppu::OWeakObject * >(new Service);
|
2006-06-02 11:24:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 10:39:31 +02:00
|
|
|
static cppu::ImplementationEntry const services[] = {
|
|
|
|
{ &createInstance, &getServiceImplementationName,
|
|
|
|
&getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0,
|
|
|
|
0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
2006-06-02 11:24:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-10-02 12:04:10 +03:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL kdebe1_component_getFactory(
|
2009-10-01 10:39:31 +02:00
|
|
|
char const * pImplName, void * pServiceManager, void * pRegistryKey)
|
2006-06-02 11:24:22 +00:00
|
|
|
{
|
2009-10-01 10:39:31 +02:00
|
|
|
return cppu::component_getFactoryHelper(
|
|
|
|
pImplName, pServiceManager, pRegistryKey, services);
|
2006-06-02 11:24:22 +00:00
|
|
|
}
|
|
|
|
|
2011-04-21 00:27:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|