1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
25 #include <com/sun/star/configuration/XUpdate.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <com/sun/star/uno/XInterface.hpp>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/supportsservice.hxx>
32 #include <cppuhelper/weak.hxx>
33 #include <osl/mutex.hxx>
34 #include <rtl/ref.hxx>
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
38 #include "broadcaster.hxx"
39 #include "components.hxx"
41 #include "modifications.hxx"
42 #include "rootaccess.hxx"
44 namespace configmgr::update
{
48 std::set
< OUString
> seqToSet(
49 css::uno::Sequence
< OUString
> const & sequence
)
51 return std::set
< OUString
>( sequence
.begin(), sequence
.end() );
55 public cppu::WeakImplHelper
< css::configuration::XUpdate
, css::lang::XServiceInfo
>
58 explicit Service(const css::uno::Reference
< css::uno::XComponentContext
>& context
):
66 Service(const Service
&) = delete;
67 Service
& operator=(const Service
&) = delete;
69 virtual ~Service() override
{}
71 virtual void SAL_CALL
insertExtensionXcsFile(
72 sal_Bool shared
, OUString
const & fileUri
) override
;
74 virtual void SAL_CALL
insertExtensionXcuFile(
75 sal_Bool shared
, OUString
const & fileUri
) override
;
77 virtual void SAL_CALL
removeExtensionXcuFile(OUString
const & fileUri
) override
;
79 virtual void SAL_CALL
insertModificationXcuFile(
80 OUString
const & fileUri
,
81 css::uno::Sequence
< OUString
> const & includedPaths
,
82 css::uno::Sequence
< OUString
> const & excludedPaths
) override
;
84 OUString SAL_CALL
getImplementationName() override
{
85 return "com.sun.star.comp.configuration.Update";
88 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
) override
{
89 return cppu::supportsService(this, ServiceName
);
92 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
{
93 return {"com.sun.star.configuration.Update_Service"};
96 std::shared_ptr
<osl::Mutex
> lock_
;
97 css::uno::Reference
< css::uno::XComponentContext
> context_
;
100 void Service::insertExtensionXcsFile(
101 sal_Bool shared
, OUString
const & fileUri
)
103 osl::MutexGuard
g(*lock_
);
104 Components::getSingleton(context_
).insertExtensionXcsFile(shared
, fileUri
);
107 void Service::insertExtensionXcuFile(
108 sal_Bool shared
, OUString
const & fileUri
)
112 osl::MutexGuard
g(*lock_
);
113 Components
& components
= Components::getSingleton(context_
);
115 components
.insertExtensionXcuFile(shared
, fileUri
, &mods
);
116 components
.initGlobalBroadcaster(
117 mods
, rtl::Reference
< RootAccess
>(), &bc
);
122 void Service::removeExtensionXcuFile(OUString
const & fileUri
)
126 osl::MutexGuard
g(*lock_
);
127 Components
& components
= Components::getSingleton(context_
);
129 components
.removeExtensionXcuFile(fileUri
, &mods
);
130 components
.initGlobalBroadcaster(
131 mods
, rtl::Reference
< RootAccess
>(), &bc
);
136 void Service::insertModificationXcuFile(
137 OUString
const & fileUri
,
138 css::uno::Sequence
< OUString
> const & includedPaths
,
139 css::uno::Sequence
< OUString
> const & excludedPaths
)
143 osl::MutexGuard
g(*lock_
);
144 Components
& components
= Components::getSingleton(context_
);
146 components
.insertModificationXcuFile(
147 fileUri
, seqToSet(includedPaths
), seqToSet(excludedPaths
), &mods
);
148 components
.initGlobalBroadcaster(
149 mods
, rtl::Reference
< RootAccess
>(), &bc
);
157 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
158 com_sun_star_comp_configuration_Update_get_implementation(
159 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const& )
161 return cppu::acquire(new configmgr::update::Service(context
));
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */