1f8e2c85aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f8e2c85aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f8e2c85aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5f8e2c85aSAndrew Rist * distributed with this work for additional information 6f8e2c85aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f8e2c85aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8f8e2c85aSAndrew Rist * "License"); you may not use this file except in compliance 9f8e2c85aSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f8e2c85aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f8e2c85aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14f8e2c85aSAndrew Rist * software distributed under the License is distributed on an 15f8e2c85aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f8e2c85aSAndrew Rist * KIND, either express or implied. See the License for the 17f8e2c85aSAndrew Rist * specific language governing permissions and limitations 18f8e2c85aSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f8e2c85aSAndrew Rist *************************************************************/ 21f8e2c85aSAndrew Rist 22f8e2c85aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_shell.hxx" 25cdf0e10cSrcweir #include "sal/config.h" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cstddef> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "boost/noncopyable.hpp" 30cdf0e10cSrcweir #include "com/sun/star/beans/Optional.hpp" 31cdf0e10cSrcweir #include "com/sun/star/beans/PropertyVetoException.hpp" 32cdf0e10cSrcweir #include "com/sun/star/beans/UnknownPropertyException.hpp" 33cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyChangeListener.hpp" 34cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp" 35cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySetInfo.hpp" 36cdf0e10cSrcweir #include "com/sun/star/beans/XVetoableChangeListener.hpp" 37cdf0e10cSrcweir #include "com/sun/star/lang/IllegalArgumentException.hpp" 38cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp" 39cdf0e10cSrcweir #include "com/sun/star/lang/XMultiComponentFactory.hpp" 40cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp" 41cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp" 42cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx" 43cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx" 44cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 45cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx" 46cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 47cdf0e10cSrcweir #include "com/sun/star/uno/XCurrentContext.hpp" 48cdf0e10cSrcweir #include "cppuhelper/factory.hxx" 49cdf0e10cSrcweir #include "cppuhelper/implbase2.hxx" 50cdf0e10cSrcweir #include "cppuhelper/implementationentry.hxx" 51cdf0e10cSrcweir #include "cppuhelper/weak.hxx" 52cdf0e10cSrcweir #include "rtl/string.h" 53cdf0e10cSrcweir #include "rtl/ustring.h" 54cdf0e10cSrcweir #include "rtl/ustring.hxx" 55cdf0e10cSrcweir #include "sal/types.h" 56cdf0e10cSrcweir #include "uno/current_context.hxx" 57cdf0e10cSrcweir #include "uno/lbnames.h" 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include "gconfaccess.hxx" 60cdf0e10cSrcweir 61cdf0e10cSrcweir namespace { 62cdf0e10cSrcweir 63cdf0e10cSrcweir namespace css = com::sun::star; 64cdf0e10cSrcweir 65cdf0e10cSrcweir rtl::OUString SAL_CALL getServiceImplementationName() { 66cdf0e10cSrcweir return rtl::OUString( 67cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 68cdf0e10cSrcweir "com.sun.star.comp.configuration.backend.GconfBackend")); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() { 72cdf0e10cSrcweir rtl::OUString name( 73cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 74cdf0e10cSrcweir "com.sun.star.configuration.backend.GconfBackend")); 75cdf0e10cSrcweir return css::uno::Sequence< rtl::OUString >(&name, 1); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir class Service: 79cdf0e10cSrcweir public cppu::WeakImplHelper2< 80cdf0e10cSrcweir css::lang::XServiceInfo, css::beans::XPropertySet >, 81cdf0e10cSrcweir private boost::noncopyable 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir Service(); 85cdf0e10cSrcweir 86cdf0e10cSrcweir private: 87cdf0e10cSrcweir virtual ~Service() {} 88cdf0e10cSrcweir 89cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getImplementationName() 90cdf0e10cSrcweir throw (css::uno::RuntimeException) 91cdf0e10cSrcweir { return getServiceImplementationName(); } 92cdf0e10cSrcweir 93cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) 94cdf0e10cSrcweir throw (css::uno::RuntimeException) 95cdf0e10cSrcweir { return ServiceName == getSupportedServiceNames()[0]; } 96cdf0e10cSrcweir 97cdf0e10cSrcweir virtual css::uno::Sequence< rtl::OUString > SAL_CALL 98cdf0e10cSrcweir getSupportedServiceNames() throw (css::uno::RuntimeException) 99cdf0e10cSrcweir { return getServiceSupportedServiceNames(); } 100cdf0e10cSrcweir 101cdf0e10cSrcweir virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL 102cdf0e10cSrcweir getPropertySetInfo() throw (css::uno::RuntimeException) 103cdf0e10cSrcweir { return css::uno::Reference< css::beans::XPropertySetInfo >(); } 104cdf0e10cSrcweir 105cdf0e10cSrcweir virtual void SAL_CALL setPropertyValue( 106cdf0e10cSrcweir rtl::OUString const &, css::uno::Any const &) 107cdf0e10cSrcweir throw ( 108cdf0e10cSrcweir css::beans::UnknownPropertyException, 109cdf0e10cSrcweir css::beans::PropertyVetoException, 110cdf0e10cSrcweir css::lang::IllegalArgumentException, 111cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException); 112cdf0e10cSrcweir 113cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getPropertyValue( 114cdf0e10cSrcweir rtl::OUString const & PropertyName) 115cdf0e10cSrcweir throw ( 116cdf0e10cSrcweir css::beans::UnknownPropertyException, 117cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException); 118cdf0e10cSrcweir 119cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( 120cdf0e10cSrcweir rtl::OUString const &, 121cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertyChangeListener > const &) 122cdf0e10cSrcweir throw ( 123cdf0e10cSrcweir css::beans::UnknownPropertyException, 124cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 125cdf0e10cSrcweir {} 126cdf0e10cSrcweir 127cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( 128cdf0e10cSrcweir rtl::OUString const &, 129cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertyChangeListener > const &) 130cdf0e10cSrcweir throw ( 131cdf0e10cSrcweir css::beans::UnknownPropertyException, 132cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 133cdf0e10cSrcweir {} 134cdf0e10cSrcweir 135cdf0e10cSrcweir virtual void SAL_CALL addVetoableChangeListener( 136cdf0e10cSrcweir rtl::OUString const &, 137cdf0e10cSrcweir css::uno::Reference< css::beans::XVetoableChangeListener > const &) 138cdf0e10cSrcweir throw ( 139cdf0e10cSrcweir css::beans::UnknownPropertyException, 140cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 141cdf0e10cSrcweir {} 142cdf0e10cSrcweir 143cdf0e10cSrcweir virtual void SAL_CALL removeVetoableChangeListener( 144cdf0e10cSrcweir rtl::OUString const &, 145cdf0e10cSrcweir css::uno::Reference< css::beans::XVetoableChangeListener > const &) 146cdf0e10cSrcweir throw ( 147cdf0e10cSrcweir css::beans::UnknownPropertyException, 148cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException) 149cdf0e10cSrcweir {} 150cdf0e10cSrcweir 151cdf0e10cSrcweir bool enabled_; 152cdf0e10cSrcweir }; 153cdf0e10cSrcweir 154cdf0e10cSrcweir Service::Service(): enabled_(false) { 155cdf0e10cSrcweir css::uno::Reference< css::uno::XCurrentContext > context( 156cdf0e10cSrcweir css::uno::getCurrentContext()); 157cdf0e10cSrcweir if (context.is()) { 158cdf0e10cSrcweir rtl::OUString desktop; 159cdf0e10cSrcweir context->getValueByName( 160cdf0e10cSrcweir rtl::OUString( 161cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>= 162cdf0e10cSrcweir desktop; 163*6b1c0a07SDamjan Jovanovic enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("GNOME")) 164cdf0e10cSrcweir // ORBit-2 versions < 2.8 cause a deadlock with the gtk+ VCL plugin 165*6b1c0a07SDamjan Jovanovic // But ORBit-2 version 2.8 was released in 2003 and ORBit is almost obsolete now. 166*6b1c0a07SDamjan Jovanovic /* && 167*6b1c0a07SDamjan Jovanovic ((orbit_major_version == 2 && orbit_minor_version >= 8) || 168*6b1c0a07SDamjan Jovanovic orbit_major_version > 2)*/; 169*6b1c0a07SDamjan Jovanovic 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &) 174cdf0e10cSrcweir throw ( 175cdf0e10cSrcweir css::beans::UnknownPropertyException, css::beans::PropertyVetoException, 176cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::WrappedTargetException, 177cdf0e10cSrcweir css::uno::RuntimeException) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir throw css::lang::IllegalArgumentException( 180cdf0e10cSrcweir rtl::OUString( 181cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), 182cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName) 186cdf0e10cSrcweir throw ( 187cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException, 188cdf0e10cSrcweir css::uno::RuntimeException) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir for (std::size_t i = 0; i < gconfaccess::nConfigurationValues; ++i) { 191cdf0e10cSrcweir if (PropertyName.equalsAscii( 192cdf0e10cSrcweir gconfaccess::ConfigurationValues[i].OOoConfItem)) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir return css::uno::makeAny( 195cdf0e10cSrcweir enabled_ 196cdf0e10cSrcweir ? gconfaccess::getValue(gconfaccess::ConfigurationValues[i]) 197cdf0e10cSrcweir : css::beans::Optional< css::uno::Any >()); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir } 200cdf0e10cSrcweir throw css::beans::UnknownPropertyException( 201cdf0e10cSrcweir PropertyName, static_cast< cppu::OWeakObject * >(this)); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( 205cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > const &) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir return static_cast< cppu::OWeakObject * >(new Service); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir static cppu::ImplementationEntry const services[] = { 211cdf0e10cSrcweir { &createInstance, &getServiceImplementationName, 212cdf0e10cSrcweir &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0, 213cdf0e10cSrcweir 0 }, 214cdf0e10cSrcweir { 0, 0, 0, 0, 0, 0 } 215cdf0e10cSrcweir }; 216cdf0e10cSrcweir 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( 220cdf0e10cSrcweir char const * pImplName, void * pServiceManager, void * pRegistryKey) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir return cppu::component_getFactoryHelper( 223cdf0e10cSrcweir pImplName, pServiceManager, pRegistryKey, services); 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL 227cdf0e10cSrcweir component_getImplementationEnvironment( 228cdf0e10cSrcweir char const ** ppEnvTypeName, uno_Environment **) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 231cdf0e10cSrcweir } 232