bump product version to 6.3.0.0.beta1
[LibreOffice.git] / configmgr / source / update.cxx
blobe084a920e61469e41c5fdacab7125638809c44e6
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/implbase.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 >( sequence.begin(), sequence.end() );
57 class Service:
58 public cppu::WeakImplHelper< css::configuration::XUpdate >
60 public:
61 explicit Service(const css::uno::Reference< css::uno::XComponentContext >& context):
62 context_(context)
64 assert(context.is());
65 lock_ = lock();
68 private:
69 Service(const Service&) = delete;
70 Service& operator=(const Service&) = delete;
72 virtual ~Service() override {}
74 virtual void SAL_CALL insertExtensionXcsFile(
75 sal_Bool shared, OUString const & fileUri) override;
77 virtual void SAL_CALL insertExtensionXcuFile(
78 sal_Bool shared, OUString const & fileUri) override;
80 virtual void SAL_CALL removeExtensionXcuFile(OUString const & fileUri) override;
82 virtual void SAL_CALL insertModificationXcuFile(
83 OUString const & fileUri,
84 css::uno::Sequence< OUString > const & includedPaths,
85 css::uno::Sequence< OUString > const & excludedPaths) override;
87 std::shared_ptr<osl::Mutex> lock_;
88 css::uno::Reference< css::uno::XComponentContext > context_;
91 void Service::insertExtensionXcsFile(
92 sal_Bool shared, OUString const & fileUri)
94 osl::MutexGuard g(*lock_);
95 Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
98 void Service::insertExtensionXcuFile(
99 sal_Bool shared, OUString const & fileUri)
101 Broadcaster bc;
103 osl::MutexGuard g(*lock_);
104 Components & components = Components::getSingleton(context_);
105 Modifications mods;
106 components.insertExtensionXcuFile(shared, fileUri, &mods);
107 components.initGlobalBroadcaster(
108 mods, rtl::Reference< RootAccess >(), &bc);
110 bc.send();
113 void Service::removeExtensionXcuFile(OUString const & fileUri)
115 Broadcaster bc;
117 osl::MutexGuard g(*lock_);
118 Components & components = Components::getSingleton(context_);
119 Modifications mods;
120 components.removeExtensionXcuFile(fileUri, &mods);
121 components.initGlobalBroadcaster(
122 mods, rtl::Reference< RootAccess >(), &bc);
124 bc.send();
127 void Service::insertModificationXcuFile(
128 OUString const & fileUri,
129 css::uno::Sequence< OUString > const & includedPaths,
130 css::uno::Sequence< OUString > const & excludedPaths)
132 Broadcaster bc;
134 osl::MutexGuard g(*lock_);
135 Components & components = Components::getSingleton(context_);
136 Modifications mods;
137 components.insertModificationXcuFile(
138 fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
139 components.initGlobalBroadcaster(
140 mods, rtl::Reference< RootAccess >(), &bc);
142 bc.send();
147 css::uno::Reference< css::uno::XInterface > create(
148 css::uno::Reference< css::uno::XComponentContext > const & context)
150 return static_cast< cppu::OWeakObject * >(new Service(context));
153 OUString getImplementationName() {
154 return OUString("com.sun.star.comp.configuration.Update");
157 css::uno::Sequence< OUString > getSupportedServiceNames() {
158 return css::uno::Sequence< OUString > { "com.sun.star.configuration.Update_Service" };
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */