/src/libreoffice/configmgr/source/update.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <sal/config.h> |
21 | | |
22 | | #include <cassert> |
23 | | |
24 | | #include <com/sun/star/configuration/XUpdate.hpp> |
25 | | #include <com/sun/star/lang/XServiceInfo.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/supportsservice.hxx> |
31 | | #include <cppuhelper/weak.hxx> |
32 | | #include <osl/mutex.hxx> |
33 | | #include <rtl/ref.hxx> |
34 | | #include <rtl/ustring.hxx> |
35 | | #include <sal/types.h> |
36 | | |
37 | | #include "broadcaster.hxx" |
38 | | #include "components.hxx" |
39 | | #include "lock.hxx" |
40 | | #include "modifications.hxx" |
41 | | #include "rootaccess.hxx" |
42 | | |
43 | | namespace configmgr::update { |
44 | | |
45 | | namespace { |
46 | | |
47 | | class Service: |
48 | | public cppu::WeakImplHelper< css::configuration::XUpdate, css::lang::XServiceInfo > |
49 | | { |
50 | | public: |
51 | | explicit Service(const css::uno::Reference< css::uno::XComponentContext >& context): |
52 | 0 | context_(context) |
53 | 0 | { |
54 | 0 | assert(context.is()); |
55 | 0 | lock_ = lock(); |
56 | 0 | } |
57 | | |
58 | | private: |
59 | | Service(const Service&) = delete; |
60 | | Service& operator=(const Service&) = delete; |
61 | | |
62 | 0 | virtual ~Service() override {} |
63 | | |
64 | | virtual void SAL_CALL insertExtensionXcsFile( |
65 | | sal_Bool shared, OUString const & fileUri) override; |
66 | | |
67 | | virtual void SAL_CALL insertExtensionXcuFile( |
68 | | sal_Bool shared, OUString const & fileUri) override; |
69 | | |
70 | | virtual void SAL_CALL removeExtensionXcuFile(OUString const & fileUri) override; |
71 | | |
72 | | virtual void SAL_CALL insertModificationXcuFile( |
73 | | OUString const & fileUri, |
74 | | css::uno::Sequence< OUString > const & includedPaths, |
75 | | css::uno::Sequence< OUString > const & excludedPaths) override; |
76 | | |
77 | 0 | OUString SAL_CALL getImplementationName() override { |
78 | 0 | return u"com.sun.star.comp.configuration.Update"_ustr; |
79 | 0 | } |
80 | | |
81 | 0 | sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override { |
82 | 0 | return cppu::supportsService(this, ServiceName); |
83 | 0 | } |
84 | | |
85 | 0 | css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override { |
86 | 0 | return {u"com.sun.star.configuration.Update_Service"_ustr}; |
87 | 0 | } |
88 | | |
89 | | std::shared_ptr<osl::Mutex> lock_; |
90 | | css::uno::Reference< css::uno::XComponentContext > context_; |
91 | | }; |
92 | | |
93 | | void Service::insertExtensionXcsFile( |
94 | | sal_Bool shared, OUString const & fileUri) |
95 | 0 | { |
96 | 0 | osl::MutexGuard g(*lock_); |
97 | 0 | Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri); |
98 | 0 | } |
99 | | |
100 | | void Service::insertExtensionXcuFile( |
101 | | sal_Bool shared, OUString const & fileUri) |
102 | 0 | { |
103 | 0 | Broadcaster bc; |
104 | 0 | { |
105 | 0 | osl::MutexGuard g(*lock_); |
106 | 0 | Components & components = Components::getSingleton(context_); |
107 | 0 | Modifications mods; |
108 | 0 | components.insertExtensionXcuFile(shared, fileUri, &mods); |
109 | 0 | components.initGlobalBroadcaster( |
110 | 0 | mods, rtl::Reference< RootAccess >(), &bc); |
111 | 0 | } |
112 | 0 | bc.send(); |
113 | 0 | } |
114 | | |
115 | | void Service::removeExtensionXcuFile(OUString const & fileUri) |
116 | 0 | { |
117 | 0 | Broadcaster bc; |
118 | 0 | { |
119 | 0 | osl::MutexGuard g(*lock_); |
120 | 0 | Components & components = Components::getSingleton(context_); |
121 | 0 | Modifications mods; |
122 | 0 | components.removeExtensionXcuFile(fileUri, &mods); |
123 | 0 | components.initGlobalBroadcaster( |
124 | 0 | mods, rtl::Reference< RootAccess >(), &bc); |
125 | 0 | } |
126 | 0 | bc.send(); |
127 | 0 | } |
128 | | |
129 | | void Service::insertModificationXcuFile( |
130 | | OUString const & fileUri, |
131 | | css::uno::Sequence< OUString > const & includedPaths, |
132 | | css::uno::Sequence< OUString > const & excludedPaths) |
133 | 0 | { |
134 | 0 | Broadcaster bc; |
135 | 0 | { |
136 | 0 | osl::MutexGuard g(*lock_); |
137 | 0 | Components & components = Components::getSingleton(context_); |
138 | 0 | Modifications mods; |
139 | 0 | components.insertModificationXcuFile( |
140 | 0 | fileUri, includedPaths, excludedPaths, &mods); |
141 | 0 | components.initGlobalBroadcaster( |
142 | 0 | mods, rtl::Reference< RootAccess >(), &bc); |
143 | 0 | } |
144 | 0 | bc.send(); |
145 | 0 | } |
146 | | |
147 | | } |
148 | | } |
149 | | |
150 | | extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* |
151 | | com_sun_star_comp_configuration_Update_get_implementation( |
152 | | css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& ) |
153 | 0 | { |
154 | 0 | return cppu::acquire(new configmgr::update::Service(context)); |
155 | 0 | } |
156 | | |
157 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |