Branch data Line data Source code
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 : : #include <set>
24 : :
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"
40 : :
41 : : #include "broadcaster.hxx"
42 : : #include "components.hxx"
43 : : #include "lock.hxx"
44 : : #include "modifications.hxx"
45 : : #include "rootaccess.hxx"
46 : : #include "update.hxx"
47 : :
48 : : namespace configmgr { namespace update {
49 : :
50 : : namespace {
51 : :
52 : : namespace css = com::sun::star;
53 : :
54 : 0 : std::set< rtl::OUString > seqToSet(
55 : : css::uno::Sequence< rtl::OUString > const & sequence)
56 : : {
57 : : return std::set< rtl::OUString >(
58 : : sequence.getConstArray(),
59 : 0 : sequence.getConstArray() + sequence.getLength());
60 : : }
61 : :
62 : : class Service:
63 : : public cppu::WeakImplHelper1< css::configuration::XUpdate >,
64 : : private boost::noncopyable
65 : : {
66 : : public:
67 : 0 : Service(css::uno::Reference< css::uno::XComponentContext > const context):
68 [ # # ]: 0 : context_(context)
69 : : {
70 : : assert(context.is());
71 [ # # ][ # # ]: 0 : lock_ = lock();
[ # # ]
72 : 0 : }
73 : :
74 : : private:
75 [ # # ][ # # ]: 0 : virtual ~Service() {}
76 : :
77 : : virtual void SAL_CALL insertExtensionXcsFile(
78 : : sal_Bool shared, rtl::OUString const & fileUri)
79 : : throw (css::uno::RuntimeException);
80 : :
81 : : virtual void SAL_CALL insertExtensionXcuFile(
82 : : sal_Bool shared, rtl::OUString const & fileUri)
83 : : throw (css::uno::RuntimeException);
84 : :
85 : : virtual void SAL_CALL removeExtensionXcuFile(rtl::OUString const & fileUri)
86 : : throw (css::uno::RuntimeException);
87 : :
88 : : virtual void SAL_CALL insertModificationXcuFile(
89 : : rtl::OUString const & fileUri,
90 : : css::uno::Sequence< rtl::OUString > const & includedPaths,
91 : : css::uno::Sequence< rtl::OUString > const & excludedPaths)
92 : : throw (css::uno::RuntimeException);
93 : :
94 : : boost::shared_ptr<osl::Mutex> lock_;
95 : : css::uno::Reference< css::uno::XComponentContext > context_;
96 : : };
97 : :
98 : 0 : void Service::insertExtensionXcsFile(
99 : : sal_Bool shared, rtl::OUString const & fileUri)
100 : : throw (css::uno::RuntimeException)
101 : : {
102 [ # # ]: 0 : osl::MutexGuard g(*lock_);
103 [ # # ][ # # ]: 0 : Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
[ # # ]
104 : 0 : }
105 : :
106 : 0 : void Service::insertExtensionXcuFile(
107 : : sal_Bool shared, rtl::OUString const & fileUri)
108 : : throw (css::uno::RuntimeException)
109 : : {
110 [ # # ]: 0 : Broadcaster bc;
111 : : {
112 [ # # ]: 0 : osl::MutexGuard g(*lock_);
113 [ # # ]: 0 : Components & components = Components::getSingleton(context_);
114 [ # # ]: 0 : Modifications mods;
115 [ # # ]: 0 : components.insertExtensionXcuFile(shared, fileUri, &mods);
116 : : components.initGlobalBroadcaster(
117 [ # # ][ # # ]: 0 : mods, rtl::Reference< RootAccess >(), &bc);
[ # # ]
118 : : }
119 [ # # ]: 0 : bc.send();
120 : 0 : }
121 : :
122 : 0 : void Service::removeExtensionXcuFile(rtl::OUString const & fileUri)
123 : : throw (css::uno::RuntimeException)
124 : : {
125 [ # # ]: 0 : Broadcaster bc;
126 : : {
127 [ # # ]: 0 : osl::MutexGuard g(*lock_);
128 [ # # ]: 0 : Components & components = Components::getSingleton(context_);
129 [ # # ]: 0 : Modifications mods;
130 [ # # ]: 0 : components.removeExtensionXcuFile(fileUri, &mods);
131 : : components.initGlobalBroadcaster(
132 [ # # ][ # # ]: 0 : mods, rtl::Reference< RootAccess >(), &bc);
[ # # ]
133 : : }
134 [ # # ]: 0 : bc.send();
135 : 0 : }
136 : :
137 : 0 : void Service::insertModificationXcuFile(
138 : : rtl::OUString const & fileUri,
139 : : css::uno::Sequence< rtl::OUString > const & includedPaths,
140 : : css::uno::Sequence< rtl::OUString > const & excludedPaths)
141 : : throw (css::uno::RuntimeException)
142 : : {
143 [ # # ]: 0 : Broadcaster bc;
144 : : {
145 [ # # ]: 0 : osl::MutexGuard g(*lock_);
146 [ # # ]: 0 : Components & components = Components::getSingleton(context_);
147 [ # # ]: 0 : Modifications mods;
148 : : components.insertModificationXcuFile(
149 [ # # ][ # # ]: 0 : fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
[ # # ]
150 : : components.initGlobalBroadcaster(
151 [ # # ][ # # ]: 0 : mods, rtl::Reference< RootAccess >(), &bc);
[ # # ]
152 : : }
153 [ # # ]: 0 : bc.send();
154 : 0 : }
155 : :
156 : : }
157 : :
158 : 0 : css::uno::Reference< css::uno::XInterface > create(
159 : : css::uno::Reference< css::uno::XComponentContext > const & context)
160 : : {
161 [ # # ][ # # ]: 0 : return static_cast< cppu::OWeakObject * >(new Service(context));
162 : : }
163 : :
164 : 954 : rtl::OUString getImplementationName() {
165 : : return rtl::OUString(
166 : 954 : RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update"));
167 : : }
168 : :
169 : 0 : css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
170 : : rtl::OUString name(
171 : : RTL_CONSTASCII_USTRINGPARAM(
172 [ # # ]: 0 : "com.sun.star.configuration.Update_Service"));
173 [ # # ]: 0 : return css::uno::Sequence< rtl::OUString >(&name, 1);
174 : : }
175 : :
176 : : } }
177 : :
178 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|