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 "boost/noncopyable.hpp"
26 #include "boost/shared_ptr.hpp"
27 #include "com/sun/star/configuration/XUpdate.hpp"
28 #include "com/sun/star/uno/Reference.hxx"
29 #include "com/sun/star/uno/RuntimeException.hpp"
30 #include "com/sun/star/uno/Sequence.hxx"
31 #include "com/sun/star/uno/XComponentContext.hpp"
32 #include "com/sun/star/uno/XInterface.hpp"
33 #include "cppuhelper/implbase1.hxx"
34 #include "cppuhelper/weak.hxx"
35 #include "osl/mutex.hxx"
36 #include "rtl/ref.hxx"
37 #include "rtl/ustring.h"
38 #include "rtl/ustring.hxx"
39 #include "sal/types.h"
41 #include "broadcaster.hxx"
42 #include "components.hxx"
44 #include "modifications.hxx"
45 #include "rootaccess.hxx"
48 namespace configmgr
{ namespace update
{
52 std::set
< rtl::OUString
> seqToSet(
53 css::uno::Sequence
< rtl::OUString
> const & sequence
)
55 return std::set
< rtl::OUString
>(
56 sequence
.getConstArray(),
57 sequence
.getConstArray() + sequence
.getLength());
61 public cppu::WeakImplHelper1
< css::configuration::XUpdate
>,
62 private boost::noncopyable
65 Service(css::uno::Reference
< css::uno::XComponentContext
> const context
):
75 virtual void SAL_CALL
insertExtensionXcsFile(
76 sal_Bool shared
, rtl::OUString
const & fileUri
)
77 throw (css::uno::RuntimeException
);
79 virtual void SAL_CALL
insertExtensionXcuFile(
80 sal_Bool shared
, rtl::OUString
const & fileUri
)
81 throw (css::uno::RuntimeException
);
83 virtual void SAL_CALL
removeExtensionXcuFile(rtl::OUString
const & fileUri
)
84 throw (css::uno::RuntimeException
);
86 virtual void SAL_CALL
insertModificationXcuFile(
87 rtl::OUString
const & fileUri
,
88 css::uno::Sequence
< rtl::OUString
> const & includedPaths
,
89 css::uno::Sequence
< rtl::OUString
> const & excludedPaths
)
90 throw (css::uno::RuntimeException
);
92 boost::shared_ptr
<osl::Mutex
> lock_
;
93 css::uno::Reference
< css::uno::XComponentContext
> context_
;
96 void Service::insertExtensionXcsFile(
97 sal_Bool shared
, rtl::OUString
const & fileUri
)
98 throw (css::uno::RuntimeException
)
100 osl::MutexGuard
g(*lock_
);
101 Components::getSingleton(context_
).insertExtensionXcsFile(shared
, fileUri
);
104 void Service::insertExtensionXcuFile(
105 sal_Bool shared
, rtl::OUString
const & fileUri
)
106 throw (css::uno::RuntimeException
)
110 osl::MutexGuard
g(*lock_
);
111 Components
& components
= Components::getSingleton(context_
);
113 components
.insertExtensionXcuFile(shared
, fileUri
, &mods
);
114 components
.initGlobalBroadcaster(
115 mods
, rtl::Reference
< RootAccess
>(), &bc
);
120 void Service::removeExtensionXcuFile(rtl::OUString
const & fileUri
)
121 throw (css::uno::RuntimeException
)
125 osl::MutexGuard
g(*lock_
);
126 Components
& components
= Components::getSingleton(context_
);
128 components
.removeExtensionXcuFile(fileUri
, &mods
);
129 components
.initGlobalBroadcaster(
130 mods
, rtl::Reference
< RootAccess
>(), &bc
);
135 void Service::insertModificationXcuFile(
136 rtl::OUString
const & fileUri
,
137 css::uno::Sequence
< rtl::OUString
> const & includedPaths
,
138 css::uno::Sequence
< rtl::OUString
> const & excludedPaths
)
139 throw (css::uno::RuntimeException
)
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
);
156 css::uno::Reference
< css::uno::XInterface
> create(
157 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
159 return static_cast< cppu::OWeakObject
* >(new Service(context
));
162 rtl::OUString
getImplementationName() {
163 return rtl::OUString(
164 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update"));
167 css::uno::Sequence
< rtl::OUString
> getSupportedServiceNames() {
169 RTL_CONSTASCII_USTRINGPARAM(
170 "com.sun.star.configuration.Update_Service"));
171 return css::uno::Sequence
< rtl::OUString
>(&name
, 1);
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */