1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "precompiled_shell.hxx" 29*cdf0e10cSrcweir #include "sal/config.h" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "kapplication.h" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "boost/noncopyable.hpp" 34*cdf0e10cSrcweir #include "com/sun/star/beans/Optional.hpp" 35*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyVetoException.hpp" 36*cdf0e10cSrcweir #include "com/sun/star/beans/UnknownPropertyException.hpp" 37*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyChangeListener.hpp" 38*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp" 39*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySetInfo.hpp" 40*cdf0e10cSrcweir #include "com/sun/star/beans/XVetoableChangeListener.hpp" 41*cdf0e10cSrcweir #include "com/sun/star/lang/IllegalArgumentException.hpp" 42*cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp" 43*cdf0e10cSrcweir #include "com/sun/star/lang/XMultiComponentFactory.hpp" 44*cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp" 45*cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp" 46*cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx" 47*cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx" 48*cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 49*cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx" 50*cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 51*cdf0e10cSrcweir #include "com/sun/star/uno/XCurrentContext.hpp" 52*cdf0e10cSrcweir #include "cppuhelper/factory.hxx" 53*cdf0e10cSrcweir #include "cppuhelper/implbase2.hxx" 54*cdf0e10cSrcweir #include "cppuhelper/implementationentry.hxx" 55*cdf0e10cSrcweir #include "cppuhelper/weak.hxx" 56*cdf0e10cSrcweir #include "rtl/string.h" 57*cdf0e10cSrcweir #include "rtl/ustring.h" 58*cdf0e10cSrcweir #include "rtl/ustring.hxx" 59*cdf0e10cSrcweir #include "sal/types.h" 60*cdf0e10cSrcweir #include "uno/current_context.hxx" 61*cdf0e10cSrcweir #include "uno/lbnames.h" 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include "kde4access.hxx" 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir namespace { 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir namespace css = com::sun::star; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir rtl::OUString SAL_CALL getServiceImplementationName() { 70*cdf0e10cSrcweir return rtl::OUString( 71*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 72*cdf0e10cSrcweir "com.sun.star.comp.configuration.backend.KDE4Backend")); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() { 76*cdf0e10cSrcweir rtl::OUString name( 77*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 78*cdf0e10cSrcweir "com.sun.star.configuration.backend.KDE4Backend")); 79*cdf0e10cSrcweir return css::uno::Sequence< rtl::OUString >(&name, 1); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir class Service: 83*cdf0e10cSrcweir public cppu::WeakImplHelper2< 84*cdf0e10cSrcweir css::lang::XServiceInfo, css::beans::XPropertySet >, 85*cdf0e10cSrcweir private boost::noncopyable 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir public: 88*cdf0e10cSrcweir Service(); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir private: 91*cdf0e10cSrcweir virtual ~Service() {} 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getImplementationName() 94*cdf0e10cSrcweir throw (css::uno::RuntimeException) 95*cdf0e10cSrcweir { return getServiceImplementationName(); } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) 98*cdf0e10cSrcweir throw (css::uno::RuntimeException) 99*cdf0e10cSrcweir { return ServiceName == getSupportedServiceNames()[0]; } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir virtual css::uno::Sequence< rtl::OUString > SAL_CALL 102*cdf0e10cSrcweir getSupportedServiceNames() throw (css::uno::RuntimeException) 103*cdf0e10cSrcweir { return getServiceSupportedServiceNames(); } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL 106*cdf0e10cSrcweir getPropertySetInfo() throw (css::uno::RuntimeException) 107*cdf0e10cSrcweir { return css::uno::Reference< css::beans::XPropertySetInfo >(); } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir virtual void SAL_CALL setPropertyValue( 110*cdf0e10cSrcweir rtl::OUString const &, css::uno::Any const &) 111*cdf0e10cSrcweir throw ( 112*cdf0e10cSrcweir css::beans::UnknownPropertyException, 113*cdf0e10cSrcweir css::beans::PropertyVetoException, 114*cdf0e10cSrcweir css::lang::IllegalArgumentException, 115*cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getPropertyValue( 118*cdf0e10cSrcweir rtl::OUString const & PropertyName) 119*cdf0e10cSrcweir throw ( 120*cdf0e10cSrcweir css::beans::UnknownPropertyException, 121*cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( 124*cdf0e10cSrcweir rtl::OUString const &, 125*cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertyChangeListener > const &) 126*cdf0e10cSrcweir throw ( 127*cdf0e10cSrcweir css::beans::UnknownPropertyException, 128*cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 129*cdf0e10cSrcweir {} 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( 132*cdf0e10cSrcweir rtl::OUString const &, 133*cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertyChangeListener > const &) 134*cdf0e10cSrcweir throw ( 135*cdf0e10cSrcweir css::beans::UnknownPropertyException, 136*cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 137*cdf0e10cSrcweir {} 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir virtual void SAL_CALL addVetoableChangeListener( 140*cdf0e10cSrcweir rtl::OUString const &, 141*cdf0e10cSrcweir css::uno::Reference< css::beans::XVetoableChangeListener > const &) 142*cdf0e10cSrcweir throw ( 143*cdf0e10cSrcweir css::beans::UnknownPropertyException, 144*cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 145*cdf0e10cSrcweir {} 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir virtual void SAL_CALL removeVetoableChangeListener( 148*cdf0e10cSrcweir rtl::OUString const &, 149*cdf0e10cSrcweir css::uno::Reference< css::beans::XVetoableChangeListener > const &) 150*cdf0e10cSrcweir throw ( 151*cdf0e10cSrcweir css::beans::UnknownPropertyException, 152*cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 153*cdf0e10cSrcweir {} 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir bool enabled_; 156*cdf0e10cSrcweir }; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir Service::Service(): enabled_(false) { 159*cdf0e10cSrcweir css::uno::Reference< css::uno::XCurrentContext > context( 160*cdf0e10cSrcweir css::uno::getCurrentContext()); 161*cdf0e10cSrcweir if (context.is()) { 162*cdf0e10cSrcweir rtl::OUString desktop; 163*cdf0e10cSrcweir context->getValueByName( 164*cdf0e10cSrcweir rtl::OUString( 165*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>= 166*cdf0e10cSrcweir desktop; 167*cdf0e10cSrcweir enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE4")) && 168*cdf0e10cSrcweir KApplication::kApplication() != 0; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &) 173*cdf0e10cSrcweir throw ( 174*cdf0e10cSrcweir css::beans::UnknownPropertyException, css::beans::PropertyVetoException, 175*cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::WrappedTargetException, 176*cdf0e10cSrcweir css::uno::RuntimeException) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir throw css::lang::IllegalArgumentException( 179*cdf0e10cSrcweir rtl::OUString( 180*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), 181*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName) 185*cdf0e10cSrcweir throw ( 186*cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException, 187*cdf0e10cSrcweir css::uno::RuntimeException) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir if (PropertyName.equalsAsciiL( 190*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) || 191*cdf0e10cSrcweir PropertyName.equalsAsciiL( 192*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) || 193*cdf0e10cSrcweir PropertyName.equalsAsciiL( 194*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) || 195*cdf0e10cSrcweir PropertyName.equalsAsciiL( 196*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) || 197*cdf0e10cSrcweir PropertyName.equalsAsciiL( 198*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) || 199*cdf0e10cSrcweir PropertyName.equalsAsciiL( 200*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) || 201*cdf0e10cSrcweir PropertyName.equalsAsciiL( 202*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) || 203*cdf0e10cSrcweir PropertyName.equalsAsciiL( 204*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) || 205*cdf0e10cSrcweir PropertyName.equalsAsciiL( 206*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) || 207*cdf0e10cSrcweir PropertyName.equalsAsciiL( 208*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) || 209*cdf0e10cSrcweir PropertyName.equalsAsciiL( 210*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) || 211*cdf0e10cSrcweir PropertyName.equalsAsciiL( 212*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) || 213*cdf0e10cSrcweir PropertyName.equalsAsciiL( 214*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir return css::uno::makeAny( 217*cdf0e10cSrcweir enabled_ 218*cdf0e10cSrcweir ? kde4access::getValue(PropertyName) 219*cdf0e10cSrcweir : css::beans::Optional< css::uno::Any >()); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir throw css::beans::UnknownPropertyException( 222*cdf0e10cSrcweir PropertyName, static_cast< cppu::OWeakObject * >(this)); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( 226*cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > const &) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir return static_cast< cppu::OWeakObject * >(new Service); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir static cppu::ImplementationEntry const services[] = { 232*cdf0e10cSrcweir { &createInstance, &getServiceImplementationName, 233*cdf0e10cSrcweir &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0, 234*cdf0e10cSrcweir 0 }, 235*cdf0e10cSrcweir { 0, 0, 0, 0, 0, 0 } 236*cdf0e10cSrcweir }; 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( 241*cdf0e10cSrcweir char const * pImplName, void * pServiceManager, void * pRegistryKey) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir return cppu::component_getFactoryHelper( 244*cdf0e10cSrcweir pImplName, pServiceManager, pRegistryKey, services); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL 248*cdf0e10cSrcweir component_getImplementationEnvironment( 249*cdf0e10cSrcweir char const ** ppEnvTypeName, uno_Environment **) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 252*cdf0e10cSrcweir } 253