bump product version to 7.6.3.2-android
[LibreOffice.git] / desktop / source / deployment / registry / configuration / dp_configuration.cxx
blob6228142486707eb2208eb728bce649ef780fe976
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 //TODO: Large parts of this file were copied from dp_component.cxx; those parts
21 // should be consolidated.
23 #include <config_extensions.h>
25 #include <dp_backend.h>
26 #if HAVE_FEATURE_EXTENSIONS
27 #include <dp_persmap.h>
28 #endif
29 #include <dp_misc.h>
30 #include <dp_ucb.h>
31 #include <rtl/string.hxx>
32 #include <rtl/strbuf.hxx>
33 #include <rtl/ustrbuf.hxx>
34 #include <cppuhelper/exc_hlp.hxx>
35 #include <cppuhelper/supportsservice.hxx>
36 #include <ucbhelper/content.hxx>
37 #include <unotools/ucbhelper.hxx>
38 #include <xmlscript/xml_helper.hxx>
39 #include <comphelper/lok.hxx>
40 #include <comphelper/xmlencode.hxx>
41 #include <svl/inettype.hxx>
42 #include <o3tl/string_view.hxx>
43 #include <com/sun/star/configuration/Update.hpp>
44 #include <com/sun/star/lang/IllegalArgumentException.hpp>
45 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
46 #include <deque>
47 #include <memory>
48 #include <string_view>
49 #include <utility>
51 #include "dp_configurationbackenddb.hxx"
53 using namespace ::dp_misc;
54 using namespace ::com::sun::star;
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::ucb;
58 namespace dp_registry::backend::configuration {
59 namespace {
61 class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
63 class PackageImpl : public ::dp_registry::backend::Package
65 BackendImpl * getMyBackend() const ;
67 const bool m_isSchema;
69 // Package
70 virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
71 ::osl::ResettableMutexGuard & guard,
72 ::rtl::Reference<AbortChannel> const & abortChannel,
73 Reference<XCommandEnvironment> const & xCmdEnv ) override;
74 virtual void processPackage_(
75 ::osl::ResettableMutexGuard & guard,
76 bool registerPackage,
77 bool startup,
78 ::rtl::Reference<AbortChannel> const & abortChannel,
79 Reference<XCommandEnvironment> const & xCmdEnv ) override;
81 public:
82 PackageImpl(
83 ::rtl::Reference<PackageRegistryBackend> const & myBackend,
84 OUString const & url, OUString const & name,
85 Reference<deployment::XPackageTypeInfo> const & xPackageType,
86 bool isSchema, bool bRemoved, OUString const & identifier)
87 : Package( myBackend, url, name, name /* display-name */,
88 xPackageType, bRemoved, identifier),
89 m_isSchema( isSchema )
92 friend class PackageImpl;
94 std::deque<OUString> m_xcs_files;
95 std::deque<OUString> m_xcu_files;
96 std::deque<OUString> & getFiles( bool xcs ) {
97 return xcs ? m_xcs_files : m_xcu_files;
100 bool m_configmgrini_inited;
101 bool m_configmgrini_modified;
102 std::unique_ptr<ConfigurationBackendDb> m_backendDb;
104 // PackageRegistryBackend
105 virtual Reference<deployment::XPackage> bindPackage_(
106 OUString const & url, OUString const & mediaType, bool bRemoved,
107 OUString const & identifier,
108 Reference<XCommandEnvironment> const & xCmdEnv ) override;
110 #if HAVE_FEATURE_EXTENSIONS
111 // for backwards compatibility - nil if no (compatible) back-compat db present
112 std::unique_ptr<PersistentMap> m_registeredPackages;
113 #endif
115 virtual void SAL_CALL disposing() override;
117 const Reference<deployment::XPackageTypeInfo> m_xConfDataTypeInfo;
118 const Reference<deployment::XPackageTypeInfo> m_xConfSchemaTypeInfo;
119 Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
121 void configmgrini_verify_init(
122 Reference<XCommandEnvironment> const & xCmdEnv );
123 void configmgrini_flush( Reference<XCommandEnvironment> const & xCmdEnv );
125 /* The parameter isURL is false in the case of adding the conf:ini-entry
126 value from the backend db. This entry already contains the path as it
127 is used in the configmgr.ini.
129 void addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url,
130 Reference<XCommandEnvironment> const & xCmdEnv );
131 #if HAVE_FEATURE_EXTENSIONS
132 bool removeFromConfigmgrIni( bool isSchema, OUString const & url,
133 Reference<XCommandEnvironment> const & xCmdEnv );
134 #endif
135 void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data);
136 ::std::optional<ConfigurationBackendDb::Data> readDataFromDb(std::u16string_view url);
137 void revokeEntryFromDb(std::u16string_view url);
138 bool hasActiveEntry(std::u16string_view url);
139 bool activateEntry(std::u16string_view url);
141 public:
142 BackendImpl( Sequence<Any> const & args,
143 Reference<XComponentContext> const & xComponentContext );
145 // XServiceInfo
146 virtual OUString SAL_CALL getImplementationName() override;
147 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
148 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
150 // XPackageRegistry
151 virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL
152 getSupportedPackageTypes() override;
153 virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) override;
155 using PackageRegistryBackend::disposing;
159 void BackendImpl::disposing()
161 try {
162 configmgrini_flush( Reference<XCommandEnvironment>() );
164 PackageRegistryBackend::disposing();
166 catch (const RuntimeException &) {
167 throw;
169 catch (const Exception &) {
170 Any exc( ::cppu::getCaughtException() );
171 throw lang::WrappedTargetRuntimeException(
172 "caught unexpected exception while disposing...",
173 static_cast<OWeakObject *>(this), exc );
178 BackendImpl::BackendImpl(
179 Sequence<Any> const & args,
180 Reference<XComponentContext> const & xComponentContext )
181 : PackageRegistryBackend( args, xComponentContext ),
182 m_configmgrini_inited( false ),
183 m_configmgrini_modified( false ),
184 m_xConfDataTypeInfo( new Package::TypeInfo(
185 "application/vnd.sun.star.configuration-data",
186 "*.xcu",
187 DpResId(RID_STR_CONF_DATA)
188 ) ),
189 m_xConfSchemaTypeInfo( new Package::TypeInfo(
190 "application/vnd.sun.star.configuration-schema",
191 "*.xcs",
192 DpResId(RID_STR_CONF_SCHEMA)
193 ) ),
194 m_typeInfos{ m_xConfDataTypeInfo, m_xConfSchemaTypeInfo }
196 const Reference<XCommandEnvironment> xCmdEnv;
198 if (transientMode())
200 // TODO
202 else
204 OUString dbFile = makeURL(getCachePath(), "backenddb.xml");
205 m_backendDb.reset(
206 new ConfigurationBackendDb(getComponentContext(), dbFile));
207 //clean up data folders which are no longer used.
208 //This must not be done in the same process where the help files
209 //are still registers. Only after revoking and restarting OOo the folders
210 //can be removed. This works now, because the extension manager is a singleton
211 //and the backends are only create once per process.
212 std::vector<OUString> folders = m_backendDb->getAllDataUrls();
213 deleteUnusedFolders(folders);
215 configmgrini_verify_init( xCmdEnv );
217 #if HAVE_FEATURE_EXTENSIONS
218 std::unique_ptr<PersistentMap> pMap;
219 OUString aCompatURL( makeURL( getCachePath(), "registered_packages.pmap" ) );
221 // Don't create it if it doesn't exist already
222 if ( ::utl::UCBContentHelper::Exists( expandUnoRcUrl( aCompatURL ) ) )
226 pMap.reset( new PersistentMap( aCompatURL ) );
228 catch (const Exception &e)
230 OUString aStr = "Exception loading legacy package database: '" +
231 e.Message +
232 "' - ignoring file, please remove it.\n";
233 dp_misc::writeConsole( aStr );
236 m_registeredPackages = std::move(pMap);
237 #endif
241 // XServiceInfo
242 OUString BackendImpl::getImplementationName()
244 return "com.sun.star.comp.deployment.configuration.PackageRegistryBackend";
247 sal_Bool BackendImpl::supportsService( const OUString& ServiceName )
249 return cppu::supportsService(this, ServiceName);
252 css::uno::Sequence< OUString > BackendImpl::getSupportedServiceNames()
254 return { BACKEND_SERVICE_NAME };
257 void BackendImpl::addDataToDb(
258 OUString const & url, ConfigurationBackendDb::Data const & data)
260 if (m_backendDb)
261 m_backendDb->addEntry(url, data);
264 ::std::optional<ConfigurationBackendDb::Data> BackendImpl::readDataFromDb(
265 std::u16string_view url)
267 ::std::optional<ConfigurationBackendDb::Data> data;
268 if (m_backendDb)
269 data = m_backendDb->getEntry(url);
270 return data;
273 void BackendImpl::revokeEntryFromDb(std::u16string_view url)
275 if (m_backendDb)
276 m_backendDb->revokeEntry(url);
279 bool BackendImpl::hasActiveEntry(std::u16string_view url)
281 if (m_backendDb)
282 return m_backendDb->hasActiveEntry(url);
283 return false;
286 bool BackendImpl::activateEntry(std::u16string_view url)
288 if (m_backendDb)
289 return m_backendDb->activateEntry(url);
290 return false;
294 // XPackageRegistry
296 Sequence< Reference<deployment::XPackageTypeInfo> >
297 BackendImpl::getSupportedPackageTypes()
299 return m_typeInfos;
301 void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/)
303 if (m_backendDb)
304 m_backendDb->removeEntry(url);
307 // PackageRegistryBackend
309 Reference<deployment::XPackage> BackendImpl::bindPackage_(
310 OUString const & url, OUString const & mediaType_,
311 bool bRemoved, OUString const & identifier,
312 Reference<XCommandEnvironment> const & xCmdEnv )
314 OUString mediaType( mediaType_ );
315 if (mediaType.isEmpty())
317 // detect media-type:
318 ::ucbhelper::Content ucbContent;
319 if (create_ucb_content( &ucbContent, url, xCmdEnv ))
321 const OUString title( StrTitle::getTitle( ucbContent ) );
322 if (title.endsWithIgnoreAsciiCase( ".xcu" )) {
323 mediaType = "application/vnd.sun.star.configuration-data";
325 if (title.endsWithIgnoreAsciiCase( ".xcs" )) {
326 mediaType = "application/vnd.sun.star.configuration-schema";
329 if (mediaType.isEmpty())
330 throw lang::IllegalArgumentException(
331 StrCannotDetectMediaType() + url,
332 static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) );
335 OUString type, subType;
336 INetContentTypeParameterList params;
337 if (INetContentTypes::parse( mediaType, type, subType, &params ))
339 if (type.equalsIgnoreAsciiCase("application"))
341 OUString name;
342 if (!bRemoved)
344 ::ucbhelper::Content ucbContent( url, xCmdEnv, m_xComponentContext );
345 name = StrTitle::getTitle( ucbContent );
348 if (subType.equalsIgnoreAsciiCase( "vnd.sun.star.configuration-data"))
350 return new PackageImpl(
351 this, url, name, m_xConfDataTypeInfo, false /* data file */,
352 bRemoved, identifier);
354 else if (subType.equalsIgnoreAsciiCase( "vnd.sun.star.configuration-schema")) {
355 return new PackageImpl(
356 this, url, name, m_xConfSchemaTypeInfo, true /* schema file */,
357 bRemoved, identifier);
361 throw lang::IllegalArgumentException(
362 StrUnsupportedMediaType() + mediaType,
363 static_cast<OWeakObject *>(this),
364 static_cast<sal_Int16>(-1) );
368 void BackendImpl::configmgrini_verify_init(
369 Reference<XCommandEnvironment> const & xCmdEnv )
371 if (transientMode())
372 return;
373 const ::osl::MutexGuard guard( m_aMutex );
374 if ( m_configmgrini_inited)
375 return;
377 // common rc:
378 ::ucbhelper::Content ucb_content;
379 if (create_ucb_content(
380 &ucb_content,
381 makeURL( getCachePath(), "configmgr.ini" ),
382 xCmdEnv, false /* no throw */ ))
384 OUString line;
385 if (readLine( &line, u"SCHEMA=", ucb_content,
386 RTL_TEXTENCODING_UTF8 ))
388 sal_Int32 index = RTL_CONSTASCII_LENGTH("SCHEMA=");
389 do {
390 OUString token( o3tl::trim(o3tl::getToken(line, 0, ' ', index )) );
391 if (!token.isEmpty()) {
392 //The file may not exist anymore if a shared or bundled
393 //extension was removed, but it can still be in the configmgrini.
394 //After running XExtensionManager::synchronize, the configmgrini is
395 //cleaned up
396 m_xcs_files.push_back( token );
399 while (index >= 0);
401 if (readLine( &line, u"DATA=", ucb_content,
402 RTL_TEXTENCODING_UTF8 )) {
403 sal_Int32 index = RTL_CONSTASCII_LENGTH("DATA=");
404 do {
405 std::u16string_view token( o3tl::trim(o3tl::getToken(line, 0, ' ', index )) );
406 if (!token.empty())
408 if (token[ 0 ] == '?')
409 token = token.substr( 1 );
410 //The file may not exist anymore if a shared or bundled
411 //extension was removed, but it can still be in the configmgrini.
412 //After running XExtensionManager::synchronize, the configmgrini is
413 //cleaned up
414 m_xcu_files.push_back( OUString(token) );
417 while (index >= 0);
420 m_configmgrini_modified = false;
421 m_configmgrini_inited = true;
425 void BackendImpl::configmgrini_flush(
426 Reference<XCommandEnvironment> const & xCmdEnv )
428 if (transientMode())
429 return;
430 if (!m_configmgrini_inited || !m_configmgrini_modified)
431 return;
433 OStringBuffer buf;
434 if (! m_xcs_files.empty())
436 auto iPos( m_xcs_files.cbegin() );
437 auto const iEnd( m_xcs_files.cend() );
438 buf.append( "SCHEMA=" );
439 while (iPos != iEnd) {
440 // encoded ASCII file-urls:
441 const OString item(
442 OUStringToOString( *iPos, RTL_TEXTENCODING_ASCII_US ) );
443 buf.append( item );
444 ++iPos;
445 if (iPos != iEnd)
446 buf.append( ' ' );
448 buf.append(LF);
450 if (! m_xcu_files.empty())
452 auto iPos( m_xcu_files.cbegin() );
453 auto const iEnd( m_xcu_files.cend() );
454 buf.append( "DATA=" );
455 while (iPos != iEnd) {
456 // encoded ASCII file-urls:
457 const OString item(
458 OUStringToOString( *iPos, RTL_TEXTENCODING_ASCII_US ) );
459 buf.append( item );
460 ++iPos;
461 if (iPos != iEnd)
462 buf.append( ' ' );
464 buf.append(LF);
467 // write configmgr.ini:
468 const Reference<io::XInputStream> xData(
469 ::xmlscript::createInputStream(
470 reinterpret_cast<sal_Int8 const *>(buf.getStr()),
471 buf.getLength() ) );
472 ::ucbhelper::Content ucb_content(
473 makeURL( getCachePath(), "configmgr.ini" ), xCmdEnv, m_xComponentContext );
474 ucb_content.writeStream( xData, true /* replace existing */ );
476 m_configmgrini_modified = false;
480 void BackendImpl::addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url_,
481 Reference<XCommandEnvironment> const & xCmdEnv )
483 const OUString rcterm( isURL ? dp_misc::makeRcTerm(url_) : url_ );
484 const ::osl::MutexGuard guard( m_aMutex );
485 configmgrini_verify_init( xCmdEnv );
486 std::deque<OUString> & rSet = getFiles(isSchema);
487 if (std::find( rSet.begin(), rSet.end(), rcterm ) == rSet.end()) {
488 rSet.push_front( rcterm ); // prepend to list, thus overriding
489 // write immediately:
490 m_configmgrini_modified = true;
491 configmgrini_flush( xCmdEnv );
495 #if HAVE_FEATURE_EXTENSIONS
496 bool BackendImpl::removeFromConfigmgrIni(
497 bool isSchema, OUString const & url_,
498 Reference<XCommandEnvironment> const & xCmdEnv )
500 const OUString rcterm( dp_misc::makeRcTerm(url_) );
501 const ::osl::MutexGuard guard( m_aMutex );
502 configmgrini_verify_init( xCmdEnv );
503 std::deque<OUString> & rSet = getFiles(isSchema);
504 auto i(std::find(rSet.begin(), rSet.end(), rcterm));
505 if (i == rSet.end() && !isSchema)
507 //in case the xcu contained %origin% then the configmr.ini contains the
508 //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER)
509 //However, m_url (getURL()) contains the URL for the file in the actual
510 //extension installation.
511 ::std::optional<ConfigurationBackendDb::Data> data = readDataFromDb(url_);
512 if (data)
513 i = std::find(rSet.begin(), rSet.end(), data->iniEntry);
515 if (i == rSet.end()) {
516 return false;
518 rSet.erase(i);
519 // write immediately:
520 m_configmgrini_modified = true;
521 configmgrini_flush( xCmdEnv );
522 return true;
524 #endif
526 // Package
529 BackendImpl * BackendImpl::PackageImpl::getMyBackend() const
531 BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
532 if (nullptr == pBackend)
534 //May throw a DisposedException
535 check();
536 //We should never get here...
537 throw RuntimeException(
538 "Failed to get the BackendImpl",
539 static_cast<OWeakObject*>(const_cast<PackageImpl *>(this)));
541 return pBackend;
544 beans::Optional< beans::Ambiguous<sal_Bool> >
545 BackendImpl::PackageImpl::isRegistered_(
546 ::osl::ResettableMutexGuard &,
547 ::rtl::Reference<AbortChannel> const &,
548 Reference<XCommandEnvironment> const & )
550 BackendImpl * that = getMyBackend();
552 bool bReg = false;
553 if (that->hasActiveEntry(getURL()))
554 bReg = true;
556 #if HAVE_FEATURE_EXTENSIONS
557 const OUString url(getURL());
558 if (!bReg && that->m_registeredPackages)
560 // fallback for user extension registered in berkeley DB
561 bReg = that->m_registeredPackages->has(
562 OUStringToOString( url, RTL_TEXTENCODING_UTF8 ));
564 #endif
565 return beans::Optional< beans::Ambiguous<sal_Bool> >(
566 true, beans::Ambiguous<sal_Bool>( bReg, false ) );
570 OUString replaceOrigin(
571 OUString const & url, std::u16string_view destFolder, Reference< XCommandEnvironment > const & xCmdEnv, Reference< XComponentContext > const & xContext, bool & out_replaced)
573 // looking for %origin%:
574 ::ucbhelper::Content ucb_content( url, xCmdEnv, xContext );
575 std::vector<sal_Int8> bytes( readFile( ucb_content ) );
576 std::vector<sal_Int8> filtered( bytes.size() * 2 );
577 bool use_filtered = false;
578 OString origin;
579 char const * pBytes = reinterpret_cast<char const *>(
580 bytes.data());
581 std::size_t nBytes = bytes.size();
582 size_t write_pos = 0;
583 while (nBytes > 0)
585 sal_Int32 index = rtl_str_indexOfChar_WithLength( pBytes, nBytes, '%' );
586 if (index < 0) {
587 if (! use_filtered) // opt
588 break;
589 index = nBytes;
592 if ((write_pos + index) > filtered.size())
593 filtered.resize( (filtered.size() + index) * 2 );
594 memcpy( filtered.data() + write_pos, pBytes, index );
595 write_pos += index;
596 pBytes += index;
597 nBytes -= index;
598 if (nBytes == 0)
599 break;
601 // consume %:
602 ++pBytes;
603 --nBytes;
604 char const * pAdd = "%";
605 sal_Int32 nAdd = 1;
606 if (nBytes > 1 && pBytes[ 0 ] == '%')
608 // %% => %
609 ++pBytes;
610 --nBytes;
611 use_filtered = true;
613 else if (rtl_str_shortenedCompare_WithLength(
614 pBytes, nBytes,
615 "origin%",
616 RTL_CONSTASCII_LENGTH("origin%"),
617 RTL_CONSTASCII_LENGTH("origin%")) == 0)
619 if (origin.isEmpty()) {
620 // encode only once
621 origin = OUStringToOString(
622 comphelper::string::encodeForXml( url.subView( 0, url.lastIndexOf( '/' ) ) ),
623 // xxx todo: encode always for UTF-8? => lookup doc-header?
624 RTL_TEXTENCODING_UTF8 );
626 pAdd = origin.getStr();
627 nAdd = origin.getLength();
628 pBytes += RTL_CONSTASCII_LENGTH("origin%");
629 nBytes -= RTL_CONSTASCII_LENGTH("origin%");
630 use_filtered = true;
632 if ((write_pos + nAdd) > filtered.size())
633 filtered.resize( (filtered.size() + nAdd) * 2 );
634 memcpy( filtered.data() + write_pos, pAdd, nAdd );
635 write_pos += nAdd;
637 if (!use_filtered)
638 return url;
639 if (write_pos < filtered.size())
640 filtered.resize( write_pos );
641 OUString newUrl(url);
642 if (!destFolder.empty())
644 //get the file name of the xcu and add it to the url of the temporary folder
645 sal_Int32 i = url.lastIndexOf('/');
646 newUrl = OUString::Concat(destFolder) + url.subView(i);
649 ucbhelper::Content(newUrl, xCmdEnv, xContext).writeStream(
650 xmlscript::createInputStream(std::move(filtered)), true);
651 out_replaced = true;
652 return newUrl;
656 void BackendImpl::PackageImpl::processPackage_(
657 ::osl::ResettableMutexGuard &,
658 bool doRegisterPackage,
659 bool startup,
660 ::rtl::Reference<AbortChannel> const &,
661 Reference<XCommandEnvironment> const & xCmdEnv )
663 BackendImpl * that = getMyBackend();
664 OUString url( getURL() );
666 if (doRegisterPackage)
668 if (getMyBackend()->activateEntry(getURL()))
670 ::std::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url);
671 OSL_ASSERT(data);
672 that->addToConfigmgrIni( m_isSchema, false, data->iniEntry, xCmdEnv );
674 else
676 ConfigurationBackendDb::Data data;
677 if (!m_isSchema)
679 const OUString sModFolder = that->createFolder(xCmdEnv);
680 bool out_replaced = false;
681 url = replaceOrigin(url, sModFolder, xCmdEnv, that->getComponentContext(), out_replaced);
682 if (out_replaced)
683 data.dataUrl = sModFolder;
684 else
685 deleteTempFolder(sModFolder);
687 //No need for live-deployment for bundled extension, because OOo
688 //restarts after installation
689 if ((that->m_eContext != Context::Bundled && !startup)
690 || comphelper::LibreOfficeKit::isActive())
692 if (m_isSchema)
694 css::configuration::Update::get(
695 that->m_xComponentContext)->insertExtensionXcsFile(
696 that->m_eContext == Context::Shared, expandUnoRcUrl(url));
698 else
700 css::configuration::Update::get(
701 that->m_xComponentContext)->insertExtensionXcuFile(
702 that->m_eContext == Context::Shared, expandUnoRcUrl(url));
705 that->addToConfigmgrIni( m_isSchema, true, url, xCmdEnv );
706 data.iniEntry = dp_misc::makeRcTerm(url);
707 that->addDataToDb(getURL(), data);
710 else // revoke
712 #if HAVE_FEATURE_EXTENSIONS
713 if (!that->removeFromConfigmgrIni(m_isSchema, url, xCmdEnv) &&
714 that->m_registeredPackages) {
715 // Obsolete package database handling - should be removed for LibreOffice 4.0
716 t_string2string_map entries(
717 that->m_registeredPackages->getEntries());
718 for (auto const& entry : entries)
720 //If the xcu file was installed before the configmgr was changed
721 //to use the configmgr.ini, one needed to rebuild to whole directory
722 //structure containing the xcu, xcs files from all extensions. Now,
723 //we just add all other xcu/xcs files to the configmgr.ini instead of
724 //rebuilding the directory structure.
725 OUString url2(
726 OStringToOUString(entry.first, RTL_TEXTENCODING_UTF8));
727 if (url2 != url) {
728 bool schema = entry.second.equalsIgnoreAsciiCase(
729 "vnd.sun.star.configuration-schema");
730 OUString url_replaced(url2);
731 ConfigurationBackendDb::Data data;
732 if (!schema)
734 const OUString sModFolder = that->createFolder(xCmdEnv);
735 bool out_replaced = false;
736 url_replaced = replaceOrigin(
737 url2, sModFolder, xCmdEnv, that->getComponentContext(), out_replaced);
738 if (out_replaced)
739 data.dataUrl = sModFolder;
740 else
741 deleteTempFolder(sModFolder);
743 that->addToConfigmgrIni(schema, true, url_replaced, xCmdEnv);
744 data.iniEntry = dp_misc::makeRcTerm(url_replaced);
745 that->addDataToDb(url2, data);
747 that->m_registeredPackages->erase(entry.first);
751 ::ucbhelper::Content(
752 makeURL( that->getCachePath(), "registry" ),
753 xCmdEnv, that->getComponentContext() ).executeCommand(
754 "delete", Any( true /* delete physically */ ) );
756 catch(const Exception&)
758 OSL_ASSERT(false);
761 #endif
762 ::std::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url);
763 //If an xcu file was life deployed then always a data entry is written.
764 //If the xcu file was already in the configmr.ini then there is also
765 //a data entry
766 if (!m_isSchema && data)
768 css::configuration::Update::get(
769 that->m_xComponentContext)->removeExtensionXcuFile(expandUnoRcTerm(data->iniEntry));
771 that->revokeEntryFromDb(url);
775 } // anon namespace
777 } // namespace dp_registry
779 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
780 com_sun_star_comp_deployment_configuration_PackageRegistryBackend_get_implementation(
781 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
783 return cppu::acquire(new dp_registry::backend::configuration::BackendImpl(args, context));
786 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */