1*3a7cf181SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3a7cf181SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3a7cf181SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3a7cf181SAndrew Rist * distributed with this work for additional information 6*3a7cf181SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3a7cf181SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3a7cf181SAndrew Rist * "License"); you may not use this file except in compliance 9*3a7cf181SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*3a7cf181SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*3a7cf181SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3a7cf181SAndrew Rist * software distributed under the License is distributed on an 15*3a7cf181SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3a7cf181SAndrew Rist * KIND, either express or implied. See the License for the 17*3a7cf181SAndrew Rist * specific language governing permissions and limitations 18*3a7cf181SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*3a7cf181SAndrew Rist *************************************************************/ 21*3a7cf181SAndrew Rist 22*3a7cf181SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_configmgr.hxx" 25cdf0e10cSrcweir #include "sal/config.h" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <set> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "boost/noncopyable.hpp" 30cdf0e10cSrcweir #include "com/sun/star/configuration/XUpdate.hpp" 31cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx" 32cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 33cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx" 34cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 35cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp" 36cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx" 37cdf0e10cSrcweir #include "cppuhelper/weak.hxx" 38cdf0e10cSrcweir #include "osl/mutex.hxx" 39cdf0e10cSrcweir #include "rtl/ref.hxx" 40cdf0e10cSrcweir #include "rtl/ustring.h" 41cdf0e10cSrcweir #include "rtl/ustring.hxx" 42cdf0e10cSrcweir #include "sal/types.h" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include "broadcaster.hxx" 45cdf0e10cSrcweir #include "components.hxx" 46cdf0e10cSrcweir #include "lock.hxx" 47cdf0e10cSrcweir #include "modifications.hxx" 48cdf0e10cSrcweir #include "rootaccess.hxx" 49cdf0e10cSrcweir #include "update.hxx" 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace configmgr { namespace update { 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace { 54cdf0e10cSrcweir 55cdf0e10cSrcweir namespace css = com::sun::star; 56cdf0e10cSrcweir 57cdf0e10cSrcweir std::set< rtl::OUString > seqToSet( 58cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & sequence) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir return std::set< rtl::OUString >( 61cdf0e10cSrcweir sequence.getConstArray(), 62cdf0e10cSrcweir sequence.getConstArray() + sequence.getLength()); 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir class Service: 66cdf0e10cSrcweir public cppu::WeakImplHelper1< css::configuration::XUpdate >, 67cdf0e10cSrcweir private boost::noncopyable 68cdf0e10cSrcweir { 69cdf0e10cSrcweir public: 70cdf0e10cSrcweir Service(css::uno::Reference< css::uno::XComponentContext > const context): 71cdf0e10cSrcweir context_(context) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir OSL_ASSERT(context.is()); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir private: 77cdf0e10cSrcweir virtual ~Service() {} 78cdf0e10cSrcweir 79cdf0e10cSrcweir virtual void SAL_CALL insertExtensionXcsFile( 80cdf0e10cSrcweir sal_Bool shared, rtl::OUString const & fileUri) 81cdf0e10cSrcweir throw (css::uno::RuntimeException); 82cdf0e10cSrcweir 83cdf0e10cSrcweir virtual void SAL_CALL insertExtensionXcuFile( 84cdf0e10cSrcweir sal_Bool shared, rtl::OUString const & fileUri) 85cdf0e10cSrcweir throw (css::uno::RuntimeException); 86cdf0e10cSrcweir 87cdf0e10cSrcweir virtual void SAL_CALL removeExtensionXcuFile(rtl::OUString const & fileUri) 88cdf0e10cSrcweir throw (css::uno::RuntimeException); 89cdf0e10cSrcweir 90cdf0e10cSrcweir virtual void SAL_CALL insertModificationXcuFile( 91cdf0e10cSrcweir rtl::OUString const & fileUri, 92cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & includedPaths, 93cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & excludedPaths) 94cdf0e10cSrcweir throw (css::uno::RuntimeException); 95cdf0e10cSrcweir 96cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > context_; 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir void Service::insertExtensionXcsFile( 100cdf0e10cSrcweir sal_Bool shared, rtl::OUString const & fileUri) 101cdf0e10cSrcweir throw (css::uno::RuntimeException) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir osl::MutexGuard g(lock); 104cdf0e10cSrcweir Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir void Service::insertExtensionXcuFile( 108cdf0e10cSrcweir sal_Bool shared, rtl::OUString const & fileUri) 109cdf0e10cSrcweir throw (css::uno::RuntimeException) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir Broadcaster bc; 112cdf0e10cSrcweir { 113cdf0e10cSrcweir osl::MutexGuard g(lock); 114cdf0e10cSrcweir Components & components = Components::getSingleton(context_); 115cdf0e10cSrcweir Modifications mods; 116cdf0e10cSrcweir components.insertExtensionXcuFile(shared, fileUri, &mods); 117cdf0e10cSrcweir components.initGlobalBroadcaster( 118cdf0e10cSrcweir mods, rtl::Reference< RootAccess >(), &bc); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir bc.send(); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir void Service::removeExtensionXcuFile(rtl::OUString const & fileUri) 124cdf0e10cSrcweir throw (css::uno::RuntimeException) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir Broadcaster bc; 127cdf0e10cSrcweir { 128cdf0e10cSrcweir osl::MutexGuard g(lock); 129cdf0e10cSrcweir Components & components = Components::getSingleton(context_); 130cdf0e10cSrcweir Modifications mods; 131cdf0e10cSrcweir components.removeExtensionXcuFile(fileUri, &mods); 132cdf0e10cSrcweir components.initGlobalBroadcaster( 133cdf0e10cSrcweir mods, rtl::Reference< RootAccess >(), &bc); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir bc.send(); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir void Service::insertModificationXcuFile( 139cdf0e10cSrcweir rtl::OUString const & fileUri, 140cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & includedPaths, 141cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & excludedPaths) 142cdf0e10cSrcweir throw (css::uno::RuntimeException) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir Broadcaster bc; 145cdf0e10cSrcweir { 146cdf0e10cSrcweir osl::MutexGuard g(lock); 147cdf0e10cSrcweir Components & components = Components::getSingleton(context_); 148cdf0e10cSrcweir Modifications mods; 149cdf0e10cSrcweir components.insertModificationXcuFile( 150cdf0e10cSrcweir fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); 151cdf0e10cSrcweir components.initGlobalBroadcaster( 152cdf0e10cSrcweir mods, rtl::Reference< RootAccess >(), &bc); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir bc.send(); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > create( 160cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > const & context) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir return static_cast< cppu::OWeakObject * >(new Service(context)); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir rtl::OUString getImplementationName() { 166cdf0e10cSrcweir return rtl::OUString( 167cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update")); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { 171cdf0e10cSrcweir rtl::OUString name( 172cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 173cdf0e10cSrcweir "com.sun.star.configuration.Update_Service")); 174cdf0e10cSrcweir return css::uno::Sequence< rtl::OUString >(&name, 1); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir } } 178