bump product version to 5.0.4.1
[LibreOffice.git] / configmgr / source / update.cxx
blob6e5563eccb6f9c5eb2fad947f77730a83f3ea8ae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <cassert>
23 #include <memory>
24 #include <set>
26 #include <com/sun/star/configuration/XUpdate.hpp>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/RuntimeException.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <com/sun/star/uno/XInterface.hpp>
32 #include <cppuhelper/implbase1.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <osl/mutex.hxx>
35 #include <rtl/ref.hxx>
36 #include <rtl/ustring.h>
37 #include <rtl/ustring.hxx>
38 #include <sal/types.h>
40 #include "broadcaster.hxx"
41 #include "components.hxx"
42 #include "lock.hxx"
43 #include "modifications.hxx"
44 #include "rootaccess.hxx"
45 #include "update.hxx"
47 namespace configmgr { namespace update {
49 namespace {
51 std::set< OUString > seqToSet(
52 css::uno::Sequence< OUString > const & sequence)
54 return std::set< OUString >(
55 sequence.getConstArray(),
56 sequence.getConstArray() + sequence.getLength());
59 class Service:
60 public cppu::WeakImplHelper1< css::configuration::XUpdate >
62 public:
63 Service(css::uno::Reference< css::uno::XComponentContext > const context):
64 context_(context)
66 assert(context.is());
67 lock_ = lock();
70 private:
71 Service(const Service&) SAL_DELETED_FUNCTION;
72 Service& operator=(const Service&) SAL_DELETED_FUNCTION;
74 virtual ~Service() {}
76 virtual void SAL_CALL insertExtensionXcsFile(
77 sal_Bool shared, OUString const & fileUri)
78 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 virtual void SAL_CALL insertExtensionXcuFile(
81 sal_Bool shared, OUString const & fileUri)
82 throw (css::uno::RuntimeException,
83 std::exception) SAL_OVERRIDE;
85 virtual void SAL_CALL removeExtensionXcuFile(OUString const & fileUri)
86 throw (css::uno::RuntimeException,
87 std::exception) SAL_OVERRIDE;
89 virtual void SAL_CALL insertModificationXcuFile(
90 OUString const & fileUri,
91 css::uno::Sequence< OUString > const & includedPaths,
92 css::uno::Sequence< OUString > const & excludedPaths)
93 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 std::shared_ptr<osl::Mutex> lock_;
96 css::uno::Reference< css::uno::XComponentContext > context_;
99 void Service::insertExtensionXcsFile(
100 sal_Bool shared, OUString const & fileUri)
101 throw (css::uno::RuntimeException, std::exception)
103 osl::MutexGuard g(*lock_);
104 Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
107 void Service::insertExtensionXcuFile(
108 sal_Bool shared, OUString const & fileUri)
109 throw (css::uno::RuntimeException,
110 std::exception)
112 Broadcaster bc;
114 osl::MutexGuard g(*lock_);
115 Components & components = Components::getSingleton(context_);
116 Modifications mods;
117 components.insertExtensionXcuFile(shared, fileUri, &mods);
118 components.initGlobalBroadcaster(
119 mods, rtl::Reference< RootAccess >(), &bc);
121 bc.send();
124 void Service::removeExtensionXcuFile(OUString const & fileUri)
125 throw (css::uno::RuntimeException, std::exception)
127 Broadcaster bc;
129 osl::MutexGuard g(*lock_);
130 Components & components = Components::getSingleton(context_);
131 Modifications mods;
132 components.removeExtensionXcuFile(fileUri, &mods);
133 components.initGlobalBroadcaster(
134 mods, rtl::Reference< RootAccess >(), &bc);
136 bc.send();
139 void Service::insertModificationXcuFile(
140 OUString const & fileUri,
141 css::uno::Sequence< OUString > const & includedPaths,
142 css::uno::Sequence< OUString > const & excludedPaths)
143 throw (css::uno::RuntimeException, std::exception)
145 Broadcaster bc;
147 osl::MutexGuard g(*lock_);
148 Components & components = Components::getSingleton(context_);
149 Modifications mods;
150 components.insertModificationXcuFile(
151 fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
152 components.initGlobalBroadcaster(
153 mods, rtl::Reference< RootAccess >(), &bc);
155 bc.send();
160 css::uno::Reference< css::uno::XInterface > create(
161 css::uno::Reference< css::uno::XComponentContext > const & context)
163 return static_cast< cppu::OWeakObject * >(new Service(context));
166 OUString getImplementationName() {
167 return OUString("com.sun.star.comp.configuration.Update");
170 css::uno::Sequence< OUString > getSupportedServiceNames() {
171 OUString name("com.sun.star.configuration.Update_Service");
172 return css::uno::Sequence< OUString >(&name, 1);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */