1*2722ceddSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2722ceddSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2722ceddSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2722ceddSAndrew Rist * distributed with this work for additional information 6*2722ceddSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2722ceddSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2722ceddSAndrew Rist * "License"); you may not use this file except in compliance 9*2722ceddSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2722ceddSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2722ceddSAndrew Rist * software distributed under the License is distributed on an 15*2722ceddSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2722ceddSAndrew Rist * KIND, either express or implied. See the License for the 17*2722ceddSAndrew Rist * specific language governing permissions and limitations 18*2722ceddSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2722ceddSAndrew Rist *************************************************************/ 21*2722ceddSAndrew Rist 22*2722ceddSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_desktop.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //TODO: Large parts of this file were copied from dp_component.cxx; those parts 28cdf0e10cSrcweir // should be consolidated. 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include "dp_configuration.hrc" 31cdf0e10cSrcweir #include "dp_backend.h" 32cdf0e10cSrcweir #include "dp_persmap.h" 33cdf0e10cSrcweir #include "dp_ucb.h" 34cdf0e10cSrcweir #include "rtl/string.hxx" 35cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 36cdf0e10cSrcweir #include "rtl/uri.hxx" 37cdf0e10cSrcweir #include "rtl/memory.h" 38cdf0e10cSrcweir #include "osl/file.hxx" 39cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx" 40cdf0e10cSrcweir #include "ucbhelper/content.hxx" 41cdf0e10cSrcweir #include "comphelper/anytostring.hxx" 42cdf0e10cSrcweir #include "comphelper/servicedecl.hxx" 43cdf0e10cSrcweir #include "xmlscript/xml_helper.hxx" 44cdf0e10cSrcweir #include "svl/inettype.hxx" 45cdf0e10cSrcweir #include "com/sun/star/configuration/Update.hpp" 46cdf0e10cSrcweir #include "com/sun/star/ucb/NameClash.hpp" 47cdf0e10cSrcweir #include "com/sun/star/io/XActiveDataSink.hpp" 48cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" 49cdf0e10cSrcweir #include "com/sun/star/util/XRefreshable.hpp" 50cdf0e10cSrcweir #include <list> 51cdf0e10cSrcweir #include <memory> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include "dp_configurationbackenddb.hxx" 54cdf0e10cSrcweir 55cdf0e10cSrcweir using namespace ::dp_misc; 56cdf0e10cSrcweir using namespace ::com::sun::star; 57cdf0e10cSrcweir using namespace ::com::sun::star::uno; 58cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 59cdf0e10cSrcweir using ::rtl::OUString; 60cdf0e10cSrcweir 61cdf0e10cSrcweir namespace dp_registry { 62cdf0e10cSrcweir namespace backend { 63cdf0e10cSrcweir namespace configuration { 64cdf0e10cSrcweir namespace { 65cdf0e10cSrcweir 66cdf0e10cSrcweir typedef ::std::list<OUString> t_stringlist; 67cdf0e10cSrcweir 68cdf0e10cSrcweir //============================================================================== 69cdf0e10cSrcweir class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend 70cdf0e10cSrcweir { 71cdf0e10cSrcweir class PackageImpl : public ::dp_registry::backend::Package 72cdf0e10cSrcweir { 73cdf0e10cSrcweir BackendImpl * getMyBackend() const ; 74cdf0e10cSrcweir 75cdf0e10cSrcweir const bool m_isSchema; 76cdf0e10cSrcweir 77cdf0e10cSrcweir // Package 78cdf0e10cSrcweir virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_( 79cdf0e10cSrcweir ::osl::ResettableMutexGuard & guard, 80cdf0e10cSrcweir ::rtl::Reference<AbortChannel> const & abortChannel, 81cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ); 82cdf0e10cSrcweir virtual void processPackage_( 83cdf0e10cSrcweir ::osl::ResettableMutexGuard & guard, 84cdf0e10cSrcweir bool registerPackage, 85cdf0e10cSrcweir bool startup, 86cdf0e10cSrcweir ::rtl::Reference<AbortChannel> const & abortChannel, 87cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir inline PackageImpl( 91cdf0e10cSrcweir ::rtl::Reference<PackageRegistryBackend> const & myBackend, 92cdf0e10cSrcweir OUString const & url, OUString const & name, 93cdf0e10cSrcweir Reference<deployment::XPackageTypeInfo> const & xPackageType, 94cdf0e10cSrcweir bool isSchema, bool bRemoved, OUString const & identifier) 95cdf0e10cSrcweir : Package( myBackend, url, name, name /* display-name */, 96cdf0e10cSrcweir xPackageType, bRemoved, identifier), 97cdf0e10cSrcweir m_isSchema( isSchema ) 98cdf0e10cSrcweir {} 99cdf0e10cSrcweir }; 100cdf0e10cSrcweir friend class PackageImpl; 101cdf0e10cSrcweir 102cdf0e10cSrcweir t_stringlist m_xcs_files; 103cdf0e10cSrcweir t_stringlist m_xcu_files; 104cdf0e10cSrcweir t_stringlist & getFiles( bool xcs ) { 105cdf0e10cSrcweir return xcs ? m_xcs_files : m_xcu_files; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir bool m_configmgrini_inited; 109cdf0e10cSrcweir bool m_configmgrini_modified; 110cdf0e10cSrcweir std::auto_ptr<ConfigurationBackendDb> m_backendDb; 111cdf0e10cSrcweir 112cdf0e10cSrcweir // PackageRegistryBackend 113cdf0e10cSrcweir virtual Reference<deployment::XPackage> bindPackage_( 114cdf0e10cSrcweir OUString const & url, OUString const & mediaType, sal_Bool bRemoved, 115cdf0e10cSrcweir OUString const & identifier, 116cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir ::std::auto_ptr<PersistentMap> m_registeredPackages; 119cdf0e10cSrcweir // for backwards compatibility 120cdf0e10cSrcweir 121cdf0e10cSrcweir virtual void SAL_CALL disposing(); 122cdf0e10cSrcweir 123cdf0e10cSrcweir const Reference<deployment::XPackageTypeInfo> m_xConfDataTypeInfo; 124cdf0e10cSrcweir const Reference<deployment::XPackageTypeInfo> m_xConfSchemaTypeInfo; 125cdf0e10cSrcweir Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos; 126cdf0e10cSrcweir 127cdf0e10cSrcweir void configmgrini_verify_init( 128cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ); 129cdf0e10cSrcweir void configmgrini_flush( Reference<XCommandEnvironment> const & xCmdEnv ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir /* The paramter isURL is false in the case of adding the conf:ini-entry 132cdf0e10cSrcweir value from the backend db. This entry already contains the path as it 133cdf0e10cSrcweir is used in the configmgr.ini. 134cdf0e10cSrcweir */ 135cdf0e10cSrcweir bool addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url, 136cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ); 137cdf0e10cSrcweir bool removeFromConfigmgrIni( bool isSchema, OUString const & url, 138cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ); 139cdf0e10cSrcweir 140cdf0e10cSrcweir void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data); 141cdf0e10cSrcweir ::boost::optional<ConfigurationBackendDb::Data> readDataFromDb(OUString const & url); 142cdf0e10cSrcweir void revokeEntryFromDb(OUString const & url); 143cdf0e10cSrcweir ::std::list<OUString> getAllIniEntries(); 144cdf0e10cSrcweir bool hasActiveEntry(OUString const & url); 145cdf0e10cSrcweir bool activateEntry(OUString const & url); 146cdf0e10cSrcweir 147cdf0e10cSrcweir public: 148cdf0e10cSrcweir BackendImpl( Sequence<Any> const & args, 149cdf0e10cSrcweir Reference<XComponentContext> const & xComponentContext ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir // XPackageRegistry 152cdf0e10cSrcweir virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL 153cdf0e10cSrcweir getSupportedPackageTypes() throw (RuntimeException); 154cdf0e10cSrcweir virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) 155cdf0e10cSrcweir throw (deployment::DeploymentException, 156cdf0e10cSrcweir uno::RuntimeException); 157cdf0e10cSrcweir 158cdf0e10cSrcweir using PackageRegistryBackend::disposing; 159cdf0e10cSrcweir }; 160cdf0e10cSrcweir 161cdf0e10cSrcweir //______________________________________________________________________________ 162cdf0e10cSrcweir void BackendImpl::disposing() 163cdf0e10cSrcweir { 164cdf0e10cSrcweir try { 165cdf0e10cSrcweir configmgrini_flush( Reference<XCommandEnvironment>() ); 166cdf0e10cSrcweir 167cdf0e10cSrcweir PackageRegistryBackend::disposing(); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir catch (RuntimeException &) { 170cdf0e10cSrcweir throw; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir catch (Exception &) { 173cdf0e10cSrcweir Any exc( ::cppu::getCaughtException() ); 174cdf0e10cSrcweir throw lang::WrappedTargetRuntimeException( 175cdf0e10cSrcweir OUSTR("caught unexpected exception while disposing..."), 176cdf0e10cSrcweir static_cast<OWeakObject *>(this), exc ); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir //______________________________________________________________________________ 181cdf0e10cSrcweir BackendImpl::BackendImpl( 182cdf0e10cSrcweir Sequence<Any> const & args, 183cdf0e10cSrcweir Reference<XComponentContext> const & xComponentContext ) 184cdf0e10cSrcweir : PackageRegistryBackend( args, xComponentContext ), 185cdf0e10cSrcweir m_configmgrini_inited( false ), 186cdf0e10cSrcweir m_configmgrini_modified( false ), 187cdf0e10cSrcweir m_xConfDataTypeInfo( new Package::TypeInfo( 188cdf0e10cSrcweir OUSTR("application/" 189cdf0e10cSrcweir "vnd.sun.star.configuration-data"), 190cdf0e10cSrcweir OUSTR("*.xcu"), 191cdf0e10cSrcweir getResourceString(RID_STR_CONF_DATA), 192cdf0e10cSrcweir RID_IMG_CONF_XML, RID_IMG_CONF_XML_HC ) ), 193cdf0e10cSrcweir m_xConfSchemaTypeInfo( new Package::TypeInfo( 194cdf0e10cSrcweir OUSTR("application/" 195cdf0e10cSrcweir "vnd.sun.star.configuration-schema"), 196cdf0e10cSrcweir OUSTR("*.xcs"), 197cdf0e10cSrcweir getResourceString(RID_STR_CONF_SCHEMA), 198cdf0e10cSrcweir RID_IMG_CONF_XML, RID_IMG_CONF_XML_HC ) ), 199cdf0e10cSrcweir m_typeInfos( 2 ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir m_typeInfos[ 0 ] = m_xConfDataTypeInfo; 202cdf0e10cSrcweir m_typeInfos[ 1 ] = m_xConfSchemaTypeInfo; 203cdf0e10cSrcweir 204cdf0e10cSrcweir const Reference<XCommandEnvironment> xCmdEnv; 205cdf0e10cSrcweir 206cdf0e10cSrcweir if (transientMode()) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir //TODO 209cdf0e10cSrcweir } 210cdf0e10cSrcweir else 211cdf0e10cSrcweir { 212cdf0e10cSrcweir OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); 213cdf0e10cSrcweir m_backendDb.reset( 214cdf0e10cSrcweir new ConfigurationBackendDb(getComponentContext(), dbFile)); 215cdf0e10cSrcweir //clean up data folders which are no longer used. 216cdf0e10cSrcweir //This must not be done in the same process where the help files 217cdf0e10cSrcweir //are still registers. Only after revoking and restarting OOo the folders 218cdf0e10cSrcweir //can be removed. This works now, because the extension manager is a singleton 219cdf0e10cSrcweir //and the backends are only create once per process. 220cdf0e10cSrcweir ::std::list<OUString> folders = m_backendDb->getAllDataUrls(); 221cdf0e10cSrcweir deleteUnusedFolders(OUString(), folders); 222cdf0e10cSrcweir 223cdf0e10cSrcweir 224cdf0e10cSrcweir configmgrini_verify_init( xCmdEnv ); 225cdf0e10cSrcweir m_registeredPackages.reset( 226cdf0e10cSrcweir new PersistentMap( 227cdf0e10cSrcweir makeURL( getCachePath(), OUSTR("registered_packages.db") ), 228cdf0e10cSrcweir false ) ); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir void BackendImpl::addDataToDb( 233cdf0e10cSrcweir OUString const & url, ConfigurationBackendDb::Data const & data) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir if (m_backendDb.get()) 236cdf0e10cSrcweir m_backendDb->addEntry(url, data); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir ::boost::optional<ConfigurationBackendDb::Data> BackendImpl::readDataFromDb( 240cdf0e10cSrcweir OUString const & url) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir ::boost::optional<ConfigurationBackendDb::Data> data; 243cdf0e10cSrcweir if (m_backendDb.get()) 244cdf0e10cSrcweir data = m_backendDb->getEntry(url); 245cdf0e10cSrcweir return data; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir void BackendImpl::revokeEntryFromDb(OUString const & url) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir if (m_backendDb.get()) 251cdf0e10cSrcweir m_backendDb->revokeEntry(url); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir ::std::list<OUString> BackendImpl::getAllIniEntries() 255cdf0e10cSrcweir { 256cdf0e10cSrcweir if (m_backendDb.get()) 257cdf0e10cSrcweir return m_backendDb->getAllIniEntries(); 258cdf0e10cSrcweir else 259cdf0e10cSrcweir return ::std::list<OUString>(); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir bool BackendImpl::hasActiveEntry(OUString const & url) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir if (m_backendDb.get()) 265cdf0e10cSrcweir return m_backendDb->hasActiveEntry(url); 266cdf0e10cSrcweir return false; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir bool BackendImpl::activateEntry(OUString const & url) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir if (m_backendDb.get()) 272cdf0e10cSrcweir return m_backendDb->activateEntry(url); 273cdf0e10cSrcweir return false; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir 277cdf0e10cSrcweir 278cdf0e10cSrcweir // XPackageRegistry 279cdf0e10cSrcweir //______________________________________________________________________________ 280cdf0e10cSrcweir Sequence< Reference<deployment::XPackageTypeInfo> > 281cdf0e10cSrcweir BackendImpl::getSupportedPackageTypes() throw (RuntimeException) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir return m_typeInfos; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) 286cdf0e10cSrcweir throw (deployment::DeploymentException, 287cdf0e10cSrcweir uno::RuntimeException) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir if (m_backendDb.get()) 290cdf0e10cSrcweir m_backendDb->removeEntry(url); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir // PackageRegistryBackend 294cdf0e10cSrcweir //______________________________________________________________________________ 295cdf0e10cSrcweir Reference<deployment::XPackage> BackendImpl::bindPackage_( 296cdf0e10cSrcweir OUString const & url, OUString const & mediaType_, 297cdf0e10cSrcweir sal_Bool bRemoved, OUString const & identifier, 298cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir OUString mediaType( mediaType_ ); 301cdf0e10cSrcweir if (mediaType.getLength() == 0) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir // detect media-type: 304cdf0e10cSrcweir ::ucbhelper::Content ucbContent; 305cdf0e10cSrcweir if (create_ucb_content( &ucbContent, url, xCmdEnv )) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir const OUString title( ucbContent.getPropertyValue( 308cdf0e10cSrcweir StrTitle::get() ).get<OUString>() ); 309cdf0e10cSrcweir if (title.endsWithIgnoreAsciiCaseAsciiL( 310cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM(".xcu") )) { 311cdf0e10cSrcweir mediaType = OUSTR("application/" 312cdf0e10cSrcweir "vnd.sun.star.configuration-data"); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir if (title.endsWithIgnoreAsciiCaseAsciiL( 315cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM(".xcs") )) { 316cdf0e10cSrcweir mediaType = OUSTR("application/" 317cdf0e10cSrcweir "vnd.sun.star.configuration-schema"); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir if (mediaType.getLength() == 0) 321cdf0e10cSrcweir throw lang::IllegalArgumentException( 322cdf0e10cSrcweir StrCannotDetectMediaType::get() + url, 323cdf0e10cSrcweir static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) ); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir String type, subType; 327cdf0e10cSrcweir INetContentTypeParameterList params; 328cdf0e10cSrcweir if (INetContentTypes::parse( mediaType, type, subType, ¶ms )) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir if (type.EqualsIgnoreCaseAscii("application")) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir OUString name; 333cdf0e10cSrcweir if (!bRemoved) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir ::ucbhelper::Content ucbContent( url, xCmdEnv ); 336cdf0e10cSrcweir name = ucbContent.getPropertyValue( 337cdf0e10cSrcweir StrTitle::get() ).get<OUString>(); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir ::ucbhelper::Content ucbContent( url, xCmdEnv ); 341cdf0e10cSrcweir if (subType.EqualsIgnoreCaseAscii( 342cdf0e10cSrcweir "vnd.sun.star.configuration-data")) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir return new PackageImpl( 345cdf0e10cSrcweir this, url, name, m_xConfDataTypeInfo, false /* data file */, 346cdf0e10cSrcweir bRemoved, identifier); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir else if (subType.EqualsIgnoreCaseAscii( 349cdf0e10cSrcweir "vnd.sun.star.configuration-schema")) { 350cdf0e10cSrcweir return new PackageImpl( 351cdf0e10cSrcweir this, url, name, m_xConfSchemaTypeInfo, true /* schema file */, 352cdf0e10cSrcweir bRemoved, identifier); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir throw lang::IllegalArgumentException( 357cdf0e10cSrcweir StrUnsupportedMediaType::get() + mediaType, 358cdf0e10cSrcweir static_cast<OWeakObject *>(this), 359cdf0e10cSrcweir static_cast<sal_Int16>(-1) ); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //############################################################################## 363cdf0e10cSrcweir 364cdf0e10cSrcweir //______________________________________________________________________________ 365cdf0e10cSrcweir void BackendImpl::configmgrini_verify_init( 366cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir if (transientMode()) 369cdf0e10cSrcweir return; 370cdf0e10cSrcweir const ::osl::MutexGuard guard( getMutex() ); 371cdf0e10cSrcweir if (! m_configmgrini_inited) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir // common rc: 374cdf0e10cSrcweir ::ucbhelper::Content ucb_content; 375cdf0e10cSrcweir if (create_ucb_content( 376cdf0e10cSrcweir &ucb_content, 377cdf0e10cSrcweir makeURL( getCachePath(), OUSTR("configmgr.ini") ), 378cdf0e10cSrcweir xCmdEnv, false /* no throw */ )) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir OUString line; 381cdf0e10cSrcweir if (readLine( &line, OUSTR("SCHEMA="), ucb_content, 382cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir sal_Int32 index = sizeof ("SCHEMA=") - 1; 385cdf0e10cSrcweir do { 386cdf0e10cSrcweir OUString token( line.getToken( 0, ' ', index ).trim() ); 387cdf0e10cSrcweir if (token.getLength() > 0) { 388cdf0e10cSrcweir //The file may not exist anymore if a shared or bundled 389cdf0e10cSrcweir //extension was removed, but it can still be in the configmgrini. 390cdf0e10cSrcweir //After running XExtensionManager::synchronize, the configmgrini is 391cdf0e10cSrcweir //cleaned up 392cdf0e10cSrcweir m_xcs_files.push_back( token ); 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir while (index >= 0); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir if (readLine( &line, OUSTR("DATA="), ucb_content, 398cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )) { 399cdf0e10cSrcweir sal_Int32 index = sizeof ("DATA=") - 1; 400cdf0e10cSrcweir do { 401cdf0e10cSrcweir OUString token( line.getToken( 0, ' ', index ).trim() ); 402cdf0e10cSrcweir if (token.getLength() > 0) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir if (token[ 0 ] == '?') 405cdf0e10cSrcweir token = token.copy( 1 ); 406cdf0e10cSrcweir //The file may not exist anymore if a shared or bundled 407cdf0e10cSrcweir //extension was removed, but it can still be in the configmgrini. 408cdf0e10cSrcweir //After running XExtensionManager::synchronize, the configmgrini is 409cdf0e10cSrcweir //cleaned up 410cdf0e10cSrcweir m_xcu_files.push_back( token ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir } 413cdf0e10cSrcweir while (index >= 0); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir } 416cdf0e10cSrcweir m_configmgrini_modified = false; 417cdf0e10cSrcweir m_configmgrini_inited = true; 418cdf0e10cSrcweir } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir //______________________________________________________________________________ 422cdf0e10cSrcweir void BackendImpl::configmgrini_flush( 423cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir if (transientMode()) 426cdf0e10cSrcweir return; 427cdf0e10cSrcweir if (!m_configmgrini_inited || !m_configmgrini_modified) 428cdf0e10cSrcweir return; 429cdf0e10cSrcweir 430cdf0e10cSrcweir ::rtl::OStringBuffer buf; 431cdf0e10cSrcweir if (! m_xcs_files.empty()) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir t_stringlist::const_iterator iPos( m_xcs_files.begin() ); 434cdf0e10cSrcweir t_stringlist::const_iterator const iEnd( m_xcs_files.end() ); 435cdf0e10cSrcweir buf.append( RTL_CONSTASCII_STRINGPARAM("SCHEMA=") ); 436cdf0e10cSrcweir while (iPos != iEnd) { 437cdf0e10cSrcweir // encoded ASCII file-urls: 438cdf0e10cSrcweir const ::rtl::OString item( 439cdf0e10cSrcweir ::rtl::OUStringToOString( *iPos, RTL_TEXTENCODING_ASCII_US ) ); 440cdf0e10cSrcweir buf.append( item ); 441cdf0e10cSrcweir ++iPos; 442cdf0e10cSrcweir if (iPos != iEnd) 443cdf0e10cSrcweir buf.append( ' ' ); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir buf.append(LF); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir if (! m_xcu_files.empty()) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir t_stringlist::const_iterator iPos( m_xcu_files.begin() ); 450cdf0e10cSrcweir t_stringlist::const_iterator const iEnd( m_xcu_files.end() ); 451cdf0e10cSrcweir buf.append( RTL_CONSTASCII_STRINGPARAM("DATA=") ); 452cdf0e10cSrcweir while (iPos != iEnd) { 453cdf0e10cSrcweir // encoded ASCII file-urls: 454cdf0e10cSrcweir const ::rtl::OString item( 455cdf0e10cSrcweir ::rtl::OUStringToOString( *iPos, RTL_TEXTENCODING_ASCII_US ) ); 456cdf0e10cSrcweir buf.append( item ); 457cdf0e10cSrcweir ++iPos; 458cdf0e10cSrcweir if (iPos != iEnd) 459cdf0e10cSrcweir buf.append( ' ' ); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir buf.append(LF); 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir // write configmgr.ini: 465cdf0e10cSrcweir const Reference<io::XInputStream> xData( 466cdf0e10cSrcweir ::xmlscript::createInputStream( 467cdf0e10cSrcweir ::rtl::ByteSequence( 468cdf0e10cSrcweir reinterpret_cast<sal_Int8 const *>(buf.getStr()), 469cdf0e10cSrcweir buf.getLength() ) ) ); 470cdf0e10cSrcweir ::ucbhelper::Content ucb_content( 471cdf0e10cSrcweir makeURL( getCachePath(), OUSTR("configmgr.ini") ), xCmdEnv ); 472cdf0e10cSrcweir ucb_content.writeStream( xData, true /* replace existing */ ); 473cdf0e10cSrcweir 474cdf0e10cSrcweir m_configmgrini_modified = false; 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir //______________________________________________________________________________ 478cdf0e10cSrcweir bool BackendImpl::addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url_, 479cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir const OUString rcterm( isURL ? dp_misc::makeRcTerm(url_) : url_ ); 482cdf0e10cSrcweir const ::osl::MutexGuard guard( getMutex() ); 483cdf0e10cSrcweir configmgrini_verify_init( xCmdEnv ); 484cdf0e10cSrcweir t_stringlist & rSet = getFiles(isSchema); 485cdf0e10cSrcweir if (::std::find( rSet.begin(), rSet.end(), rcterm ) == rSet.end()) { 486cdf0e10cSrcweir rSet.push_front( rcterm ); // prepend to list, thus overriding 487cdf0e10cSrcweir // write immediately: 488cdf0e10cSrcweir m_configmgrini_modified = true; 489cdf0e10cSrcweir configmgrini_flush( xCmdEnv ); 490cdf0e10cSrcweir return true; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir else 493cdf0e10cSrcweir return false; 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir //______________________________________________________________________________ 497cdf0e10cSrcweir bool BackendImpl::removeFromConfigmgrIni( 498cdf0e10cSrcweir bool isSchema, OUString const & url_, 499cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir const OUString rcterm( dp_misc::makeRcTerm(url_) ); 502cdf0e10cSrcweir const ::osl::MutexGuard guard( getMutex() ); 503cdf0e10cSrcweir configmgrini_verify_init( xCmdEnv ); 504cdf0e10cSrcweir t_stringlist & rSet = getFiles(isSchema); 505cdf0e10cSrcweir t_stringlist::iterator i(std::find(rSet.begin(), rSet.end(), rcterm)); 506cdf0e10cSrcweir if (i == rSet.end() && !isSchema) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir //in case the xcu contained %origin% then the configmr.ini contains the 509cdf0e10cSrcweir //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) 510cdf0e10cSrcweir //However, m_url (getURL()) contains the URL for the file in the actual 511cdf0e10cSrcweir //extension installatation. 512cdf0e10cSrcweir ::boost::optional<ConfigurationBackendDb::Data> data = readDataFromDb(url_); 513cdf0e10cSrcweir if (data) 514cdf0e10cSrcweir i = std::find(rSet.begin(), rSet.end(), data->iniEntry); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir if (i == rSet.end()) { 517cdf0e10cSrcweir return false; 518cdf0e10cSrcweir } 519cdf0e10cSrcweir rSet.erase(i); 520cdf0e10cSrcweir // write immediately: 521cdf0e10cSrcweir m_configmgrini_modified = true; 522cdf0e10cSrcweir configmgrini_flush( xCmdEnv ); 523cdf0e10cSrcweir return true; 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir //############################################################################## 527cdf0e10cSrcweir 528cdf0e10cSrcweir // Package 529cdf0e10cSrcweir //______________________________________________________________________________ 530cdf0e10cSrcweir 531cdf0e10cSrcweir BackendImpl * BackendImpl::PackageImpl::getMyBackend() const 532cdf0e10cSrcweir { 533cdf0e10cSrcweir BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get()); 534cdf0e10cSrcweir if (NULL == pBackend) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir //May throw a DisposedException 537cdf0e10cSrcweir check(); 538cdf0e10cSrcweir //We should never get here... 539cdf0e10cSrcweir throw RuntimeException( 540cdf0e10cSrcweir OUSTR("Failed to get the BackendImpl"), 541cdf0e10cSrcweir static_cast<OWeakObject*>(const_cast<PackageImpl *>(this))); 542cdf0e10cSrcweir } 543cdf0e10cSrcweir return pBackend; 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir beans::Optional< beans::Ambiguous<sal_Bool> > 547cdf0e10cSrcweir BackendImpl::PackageImpl::isRegistered_( 548cdf0e10cSrcweir ::osl::ResettableMutexGuard &, 549cdf0e10cSrcweir ::rtl::Reference<AbortChannel> const &, 550cdf0e10cSrcweir Reference<XCommandEnvironment> const & ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir BackendImpl * that = getMyBackend(); 553cdf0e10cSrcweir const rtl::OUString url(getURL()); 554cdf0e10cSrcweir 555cdf0e10cSrcweir bool bReg = false; 556cdf0e10cSrcweir if (that->hasActiveEntry(getURL())) 557cdf0e10cSrcweir bReg = true; 558cdf0e10cSrcweir if (!bReg) 559cdf0e10cSrcweir //fallback for user extension registered in berkeley DB 560cdf0e10cSrcweir bReg = that->m_registeredPackages->has( 561cdf0e10cSrcweir rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 )); 562cdf0e10cSrcweir 563cdf0e10cSrcweir return beans::Optional< beans::Ambiguous<sal_Bool> >( 564cdf0e10cSrcweir true, beans::Ambiguous<sal_Bool>( bReg, false ) ); 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir //------------------------------------------------------------------------------ 568cdf0e10cSrcweir OUString encodeForXml( OUString const & text ) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir // encode conforming xml: 571cdf0e10cSrcweir sal_Int32 len = text.getLength(); 572cdf0e10cSrcweir ::rtl::OUStringBuffer buf; 573cdf0e10cSrcweir for ( sal_Int32 pos = 0; pos < len; ++pos ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir sal_Unicode c = text[ pos ]; 576cdf0e10cSrcweir switch (c) { 577cdf0e10cSrcweir case '<': 578cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("<") ); 579cdf0e10cSrcweir break; 580cdf0e10cSrcweir case '>': 581cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(">") ); 582cdf0e10cSrcweir break; 583cdf0e10cSrcweir case '&': 584cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("&") ); 585cdf0e10cSrcweir break; 586cdf0e10cSrcweir case '\'': 587cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("'") ); 588cdf0e10cSrcweir break; 589cdf0e10cSrcweir case '\"': 590cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(""") ); 591cdf0e10cSrcweir break; 592cdf0e10cSrcweir default: 593cdf0e10cSrcweir buf.append( c ); 594cdf0e10cSrcweir break; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir } 597cdf0e10cSrcweir return buf.makeStringAndClear(); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir //______________________________________________________________________________ 601cdf0e10cSrcweir OUString replaceOrigin( 602cdf0e10cSrcweir OUString const & url, OUString const & destFolder, Reference< XCommandEnvironment > const & xCmdEnv, bool & out_replaced) 603cdf0e10cSrcweir { 604cdf0e10cSrcweir // looking for %origin%: 605cdf0e10cSrcweir ::ucbhelper::Content ucb_content( url, xCmdEnv ); 606cdf0e10cSrcweir ::rtl::ByteSequence bytes( readFile( ucb_content ) ); 607cdf0e10cSrcweir ::rtl::ByteSequence filtered( bytes.getLength() * 2, 608cdf0e10cSrcweir ::rtl::BYTESEQ_NODEFAULT ); 609cdf0e10cSrcweir bool use_filtered = false; 610cdf0e10cSrcweir ::rtl::OString origin; 611cdf0e10cSrcweir sal_Char const * pBytes = reinterpret_cast<sal_Char const *>( 612cdf0e10cSrcweir bytes.getConstArray()); 613cdf0e10cSrcweir sal_Size nBytes = bytes.getLength(); 614cdf0e10cSrcweir sal_Int32 write_pos = 0; 615cdf0e10cSrcweir while (nBytes > 0) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir sal_Int32 index = rtl_str_indexOfChar_WithLength( pBytes, nBytes, '%' ); 618cdf0e10cSrcweir if (index < 0) { 619cdf0e10cSrcweir if (! use_filtered) // opt 620cdf0e10cSrcweir break; 621cdf0e10cSrcweir index = nBytes; 622cdf0e10cSrcweir } 623cdf0e10cSrcweir 624cdf0e10cSrcweir if ((write_pos + index) > filtered.getLength()) 625cdf0e10cSrcweir filtered.realloc( (filtered.getLength() + index) * 2 ); 626cdf0e10cSrcweir rtl_copyMemory( filtered.getArray() + write_pos, pBytes, index ); 627cdf0e10cSrcweir write_pos += index; 628cdf0e10cSrcweir pBytes += index; 629cdf0e10cSrcweir nBytes -= index; 630cdf0e10cSrcweir if (nBytes == 0) 631cdf0e10cSrcweir break; 632cdf0e10cSrcweir 633cdf0e10cSrcweir // consume %: 634cdf0e10cSrcweir ++pBytes; 635cdf0e10cSrcweir --nBytes; 636cdf0e10cSrcweir sal_Char const * pAdd = "%"; 637cdf0e10cSrcweir sal_Int32 nAdd = 1; 638cdf0e10cSrcweir if (nBytes > 1 && pBytes[ 0 ] == '%') 639cdf0e10cSrcweir { 640cdf0e10cSrcweir // %% => % 641cdf0e10cSrcweir ++pBytes; 642cdf0e10cSrcweir --nBytes; 643cdf0e10cSrcweir use_filtered = true; 644cdf0e10cSrcweir } 645cdf0e10cSrcweir else if (rtl_str_shortenedCompare_WithLength( 646cdf0e10cSrcweir pBytes, nBytes, 647cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("origin%"), 648cdf0e10cSrcweir sizeof ("origin%") - 1 ) == 0) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir if (origin.getLength() == 0) { 651cdf0e10cSrcweir // encode only once 652cdf0e10cSrcweir origin = ::rtl::OUStringToOString( 653cdf0e10cSrcweir encodeForXml( url.copy( 0, url.lastIndexOf( '/' ) ) ), 654cdf0e10cSrcweir // xxx todo: encode always for UTF-8? => lookup doc-header? 655cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir pAdd = origin.getStr(); 658cdf0e10cSrcweir nAdd = origin.getLength(); 659cdf0e10cSrcweir pBytes += (sizeof ("origin%") - 1); 660cdf0e10cSrcweir nBytes -= (sizeof ("origin%") - 1); 661cdf0e10cSrcweir use_filtered = true; 662cdf0e10cSrcweir } 663cdf0e10cSrcweir if ((write_pos + nAdd) > filtered.getLength()) 664cdf0e10cSrcweir filtered.realloc( (filtered.getLength() + nAdd) * 2 ); 665cdf0e10cSrcweir rtl_copyMemory( filtered.getArray() + write_pos, pAdd, nAdd ); 666cdf0e10cSrcweir write_pos += nAdd; 667cdf0e10cSrcweir } 668cdf0e10cSrcweir if (!use_filtered) 669cdf0e10cSrcweir return url; 670cdf0e10cSrcweir if (write_pos < filtered.getLength()) 671cdf0e10cSrcweir filtered.realloc( write_pos ); 672cdf0e10cSrcweir rtl::OUString newUrl(url); 673cdf0e10cSrcweir if (destFolder.getLength()) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir //get the file name of the xcu and add it to the url of the temporary folder 676cdf0e10cSrcweir sal_Int32 i = url.lastIndexOf('/'); 677cdf0e10cSrcweir newUrl = destFolder + url.copy(i); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir ucbhelper::Content(newUrl, xCmdEnv).writeStream( 681cdf0e10cSrcweir xmlscript::createInputStream(filtered), true); 682cdf0e10cSrcweir out_replaced = true; 683cdf0e10cSrcweir return newUrl; 684cdf0e10cSrcweir } 685cdf0e10cSrcweir 686cdf0e10cSrcweir //______________________________________________________________________________ 687cdf0e10cSrcweir void BackendImpl::PackageImpl::processPackage_( 688cdf0e10cSrcweir ::osl::ResettableMutexGuard &, 689cdf0e10cSrcweir bool doRegisterPackage, 690cdf0e10cSrcweir bool startup, 691cdf0e10cSrcweir ::rtl::Reference<AbortChannel> const &, 692cdf0e10cSrcweir Reference<XCommandEnvironment> const & xCmdEnv ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir BackendImpl * that = getMyBackend(); 695cdf0e10cSrcweir OUString url( getURL() ); 696cdf0e10cSrcweir 697cdf0e10cSrcweir if (doRegisterPackage) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir if (getMyBackend()->activateEntry(getURL())) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url); 702cdf0e10cSrcweir OSL_ASSERT(data); 703cdf0e10cSrcweir that->addToConfigmgrIni( m_isSchema, false, data->iniEntry, xCmdEnv ); 704cdf0e10cSrcweir } 705cdf0e10cSrcweir else 706cdf0e10cSrcweir { 707cdf0e10cSrcweir ConfigurationBackendDb::Data data; 708cdf0e10cSrcweir if (!m_isSchema) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); 711cdf0e10cSrcweir bool out_replaced = false; 712cdf0e10cSrcweir url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced); 713cdf0e10cSrcweir if (out_replaced) 714cdf0e10cSrcweir data.dataUrl = sModFolder; 715cdf0e10cSrcweir else 716cdf0e10cSrcweir deleteTempFolder(sModFolder); 717cdf0e10cSrcweir } 718cdf0e10cSrcweir //No need for live-deployment for bundled extension, because OOo 719cdf0e10cSrcweir //restarts after installation 720cdf0e10cSrcweir if (that->m_eContext != CONTEXT_BUNDLED 721cdf0e10cSrcweir && that->m_eContext != CONTEXT_BUNDLED_PREREG 722cdf0e10cSrcweir && !startup) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir if (m_isSchema) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir com::sun::star::configuration::Update::get( 727cdf0e10cSrcweir that->m_xComponentContext)->insertExtensionXcsFile( 728cdf0e10cSrcweir that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); 729cdf0e10cSrcweir } 730cdf0e10cSrcweir else 731cdf0e10cSrcweir { 732cdf0e10cSrcweir com::sun::star::configuration::Update::get( 733cdf0e10cSrcweir that->m_xComponentContext)->insertExtensionXcuFile( 734cdf0e10cSrcweir that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); 735cdf0e10cSrcweir } 736cdf0e10cSrcweir } 737cdf0e10cSrcweir that->addToConfigmgrIni( m_isSchema, true, url, xCmdEnv ); 738cdf0e10cSrcweir data.iniEntry = dp_misc::makeRcTerm(url); 739cdf0e10cSrcweir that->addDataToDb(getURL(), data); 740cdf0e10cSrcweir } 741cdf0e10cSrcweir } 742cdf0e10cSrcweir else // revoke 743cdf0e10cSrcweir { 744cdf0e10cSrcweir if (!that->removeFromConfigmgrIni(m_isSchema, url, xCmdEnv)) { 745cdf0e10cSrcweir t_string2string_map entries( 746cdf0e10cSrcweir that->m_registeredPackages->getEntries()); 747cdf0e10cSrcweir for (t_string2string_map::iterator i(entries.begin()); 748cdf0e10cSrcweir i != entries.end(); ++i) 749cdf0e10cSrcweir { 750cdf0e10cSrcweir //If the xcu file was installed before the configmgr was chaned 751cdf0e10cSrcweir //to use the configmgr.ini, one needed to rebuild to whole directory 752cdf0e10cSrcweir //structur containing the xcu, xcs files from all extensions. Now, 753cdf0e10cSrcweir //we just add all other xcu/xcs files to the configmgr.ini instead of 754cdf0e10cSrcweir //rebuilding the directory structure. 755cdf0e10cSrcweir rtl::OUString url2( 756cdf0e10cSrcweir rtl::OStringToOUString(i->first, RTL_TEXTENCODING_UTF8)); 757cdf0e10cSrcweir if (url2 != url) { 758cdf0e10cSrcweir bool schema = i->second.equalsIgnoreAsciiCase( 759cdf0e10cSrcweir "vnd.sun.star.configuration-schema"); 760cdf0e10cSrcweir OUString url_replaced(url2); 761cdf0e10cSrcweir ConfigurationBackendDb::Data data; 762cdf0e10cSrcweir if (!schema) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); 765cdf0e10cSrcweir bool out_replaced = false; 766cdf0e10cSrcweir url_replaced = replaceOrigin( 767cdf0e10cSrcweir url2, sModFolder, xCmdEnv, out_replaced); 768cdf0e10cSrcweir if (out_replaced) 769cdf0e10cSrcweir data.dataUrl = sModFolder; 770cdf0e10cSrcweir else 771cdf0e10cSrcweir deleteTempFolder(sModFolder); 772cdf0e10cSrcweir } 773cdf0e10cSrcweir that->addToConfigmgrIni(schema, true, url_replaced, xCmdEnv); 774cdf0e10cSrcweir data.iniEntry = dp_misc::makeRcTerm(url_replaced); 775cdf0e10cSrcweir that->addDataToDb(url2, data); 776cdf0e10cSrcweir } 777cdf0e10cSrcweir that->m_registeredPackages->erase(i->first); 778cdf0e10cSrcweir } 779cdf0e10cSrcweir try 780cdf0e10cSrcweir { 781cdf0e10cSrcweir ::ucbhelper::Content( 782cdf0e10cSrcweir makeURL( that->getCachePath(), OUSTR("registry") ), 783cdf0e10cSrcweir xCmdEnv ).executeCommand( 784cdf0e10cSrcweir OUSTR("delete"), Any( true /* delete physically */ ) ); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir catch(Exception&) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir OSL_ASSERT(0); 789cdf0e10cSrcweir } 790cdf0e10cSrcweir } 791cdf0e10cSrcweir 792cdf0e10cSrcweir ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url); 793cdf0e10cSrcweir //If an xcu file was life deployed then always a data entry is written. 794cdf0e10cSrcweir //If the xcu file was already in the configmr.ini then there is also 795cdf0e10cSrcweir //a data entry 796cdf0e10cSrcweir if (!m_isSchema && data) 797cdf0e10cSrcweir { 798cdf0e10cSrcweir com::sun::star::configuration::Update::get( 799cdf0e10cSrcweir that->m_xComponentContext)->removeExtensionXcuFile(expandUnoRcTerm(data->iniEntry)); 800cdf0e10cSrcweir } 801cdf0e10cSrcweir that->revokeEntryFromDb(url); 802cdf0e10cSrcweir } 803cdf0e10cSrcweir } 804cdf0e10cSrcweir 805cdf0e10cSrcweir } // anon namespace 806cdf0e10cSrcweir 807cdf0e10cSrcweir namespace sdecl = comphelper::service_decl; 808cdf0e10cSrcweir sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI; 809cdf0e10cSrcweir extern sdecl::ServiceDecl const serviceDecl( 810cdf0e10cSrcweir serviceBI, 811cdf0e10cSrcweir "com.sun.star.comp.deployment.configuration.PackageRegistryBackend", 812cdf0e10cSrcweir BACKEND_SERVICE_NAME ); 813cdf0e10cSrcweir 814cdf0e10cSrcweir } // namespace configuration 815cdf0e10cSrcweir } // namespace backend 816cdf0e10cSrcweir } // namespace dp_registry 817cdf0e10cSrcweir 818