bump product version to 7.2.5.1
[LibreOffice.git] / configmgr / source / update.cxx
blob1cc2a06fe2a204e55200548c92c59d4d41765937
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 <set>
25 #include <com/sun/star/configuration/XUpdate.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <com/sun/star/uno/XInterface.hpp>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/weak.hxx>
31 #include <osl/mutex.hxx>
32 #include <rtl/ref.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
36 #include "broadcaster.hxx"
37 #include "components.hxx"
38 #include "lock.hxx"
39 #include "modifications.hxx"
40 #include "rootaccess.hxx"
42 namespace configmgr::update {
44 namespace {
46 std::set< OUString > seqToSet(
47 css::uno::Sequence< OUString > const & sequence)
49 return std::set< OUString >( sequence.begin(), sequence.end() );
52 class Service:
53 public cppu::WeakImplHelper< css::configuration::XUpdate >
55 public:
56 explicit Service(const css::uno::Reference< css::uno::XComponentContext >& context):
57 context_(context)
59 assert(context.is());
60 lock_ = lock();
63 private:
64 Service(const Service&) = delete;
65 Service& operator=(const Service&) = delete;
67 virtual ~Service() override {}
69 virtual void SAL_CALL insertExtensionXcsFile(
70 sal_Bool shared, OUString const & fileUri) override;
72 virtual void SAL_CALL insertExtensionXcuFile(
73 sal_Bool shared, OUString const & fileUri) override;
75 virtual void SAL_CALL removeExtensionXcuFile(OUString const & fileUri) override;
77 virtual void SAL_CALL insertModificationXcuFile(
78 OUString const & fileUri,
79 css::uno::Sequence< OUString > const & includedPaths,
80 css::uno::Sequence< OUString > const & excludedPaths) override;
82 std::shared_ptr<osl::Mutex> lock_;
83 css::uno::Reference< css::uno::XComponentContext > context_;
86 void Service::insertExtensionXcsFile(
87 sal_Bool shared, OUString const & fileUri)
89 osl::MutexGuard g(*lock_);
90 Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
93 void Service::insertExtensionXcuFile(
94 sal_Bool shared, OUString const & fileUri)
96 Broadcaster bc;
98 osl::MutexGuard g(*lock_);
99 Components & components = Components::getSingleton(context_);
100 Modifications mods;
101 components.insertExtensionXcuFile(shared, fileUri, &mods);
102 components.initGlobalBroadcaster(
103 mods, rtl::Reference< RootAccess >(), &bc);
105 bc.send();
108 void Service::removeExtensionXcuFile(OUString const & fileUri)
110 Broadcaster bc;
112 osl::MutexGuard g(*lock_);
113 Components & components = Components::getSingleton(context_);
114 Modifications mods;
115 components.removeExtensionXcuFile(fileUri, &mods);
116 components.initGlobalBroadcaster(
117 mods, rtl::Reference< RootAccess >(), &bc);
119 bc.send();
122 void Service::insertModificationXcuFile(
123 OUString const & fileUri,
124 css::uno::Sequence< OUString > const & includedPaths,
125 css::uno::Sequence< OUString > const & excludedPaths)
127 Broadcaster bc;
129 osl::MutexGuard g(*lock_);
130 Components & components = Components::getSingleton(context_);
131 Modifications mods;
132 components.insertModificationXcuFile(
133 fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
134 components.initGlobalBroadcaster(
135 mods, rtl::Reference< RootAccess >(), &bc);
137 bc.send();
143 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
144 com_sun_star_comp_configuration_Update_get_implementation(
145 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
147 return cppu::acquire(new configmgr::update::Service(context));
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */