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 10*2722ceddSAndrew Rist * 11*2722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2722ceddSAndrew Rist * 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. 19*2722ceddSAndrew Rist * 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 #include <algorithm> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "app.hxx" 30cdf0e10cSrcweir #include "cmdlineargs.hxx" 31cdf0e10cSrcweir #include "desktopresid.hxx" 32cdf0e10cSrcweir #include "desktop.hrc" 33cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 36cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp> 37cdf0e10cSrcweir #include <com/sun/star/uno/XCurrentContext.hpp> 38cdf0e10cSrcweir #include <com/sun/star/packages/zip/ZipIOException.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 42cdf0e10cSrcweir #include <com/sun/star/container/XContentEnumerationAccess.hpp> 43cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProviderManager.hpp> 44cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProviderFactory.hpp> 45cdf0e10cSrcweir #include <uno/current_context.hxx> 46cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 47cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 48cdf0e10cSrcweir #include <osl/file.hxx> 49cdf0e10cSrcweir #include <osl/module.h> 50cdf0e10cSrcweir #include <vos/process.hxx> 51cdf0e10cSrcweir #include <rtl/uri.hxx> 52cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 53cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 54cdf0e10cSrcweir #include <comphelper/regpathhelper.hxx> 55cdf0e10cSrcweir #include <tools/debug.hxx> 56cdf0e10cSrcweir #include <tools/tempfile.hxx> 57cdf0e10cSrcweir #include <ucbhelper/configurationkeys.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 60cdf0e10cSrcweir #include <tools/urlobj.hxx> 61cdf0e10cSrcweir #include <tools/rcid.h> 62cdf0e10cSrcweir 63cdf0e10cSrcweir #include <rtl/logfile.hxx> 64cdf0e10cSrcweir #include <rtl/instance.hxx> 65cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 66cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 67cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 68cdf0e10cSrcweir #include <unotools/tempfile.hxx> 69cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 70cdf0e10cSrcweir #include <vcl/svapp.hxx> 71cdf0e10cSrcweir #include <unotools/startoptions.hxx> 72cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 73cdf0e10cSrcweir #include <unotools/internaloptions.hxx> 74cdf0e10cSrcweir 75cdf0e10cSrcweir 76cdf0e10cSrcweir #define DEFINE_CONST_OUSTRING(CONSTASCII) OUString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII)) 77cdf0e10cSrcweir 78cdf0e10cSrcweir #define DESKTOP_TEMPDIRNAME "soffice.tmp" 79cdf0e10cSrcweir 80cdf0e10cSrcweir using namespace rtl; 81cdf0e10cSrcweir using namespace vos; 82cdf0e10cSrcweir using namespace desktop; 83cdf0e10cSrcweir using namespace ::com::sun::star::uno; 84cdf0e10cSrcweir using namespace ::com::sun::star::lang; 85cdf0e10cSrcweir using namespace ::com::sun::star::beans; 86cdf0e10cSrcweir using namespace ::com::sun::star::registry; 87cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 88cdf0e10cSrcweir 89cdf0e10cSrcweir namespace desktop 90cdf0e10cSrcweir { 91cdf0e10cSrcweir 92cdf0e10cSrcweir // ----------------------------------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir static bool configureUcb(bool bServer, rtl::OUString const & rPortalConnect) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "desktop (sb93797) ::configureUcb" ); 97cdf0e10cSrcweir Reference< XMultiServiceFactory > 98cdf0e10cSrcweir xServiceFactory( comphelper::getProcessServiceFactory() ); 99cdf0e10cSrcweir if (!xServiceFactory.is()) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir DBG_ERROR("configureUcb(): No XMultiServiceFactory"); 102cdf0e10cSrcweir return false; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir rtl::OUString aPipe; 106cdf0e10cSrcweir vos::OSecurity().getUserIdent(aPipe); 107cdf0e10cSrcweir 108cdf0e10cSrcweir rtl::OUStringBuffer aPortal; 109cdf0e10cSrcweir if (rPortalConnect.getLength() != 0) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir aPortal.append(sal_Unicode(',')); 112cdf0e10cSrcweir aPortal.append(rPortalConnect); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir Sequence< Any > aArgs(6); 116cdf0e10cSrcweir aArgs[0] 117cdf0e10cSrcweir <<= rtl::OUString::createFromAscii(bServer ? 118cdf0e10cSrcweir UCB_CONFIGURATION_KEY1_SERVER : 119cdf0e10cSrcweir UCB_CONFIGURATION_KEY1_LOCAL); 120cdf0e10cSrcweir aArgs[1] 121cdf0e10cSrcweir <<= rtl::OUString::createFromAscii(UCB_CONFIGURATION_KEY2_OFFICE); 122cdf0e10cSrcweir aArgs[2] <<= rtl::OUString::createFromAscii("PIPE"); 123cdf0e10cSrcweir aArgs[3] <<= aPipe; 124cdf0e10cSrcweir aArgs[4] <<= rtl::OUString::createFromAscii("PORTAL"); 125cdf0e10cSrcweir aArgs[5] <<= aPortal.makeStringAndClear(); 126cdf0e10cSrcweir 127cdf0e10cSrcweir bool ret = 128cdf0e10cSrcweir ::ucbhelper::ContentBroker::initialize( xServiceFactory, aArgs ) != false; 129cdf0e10cSrcweir 130cdf0e10cSrcweir #ifdef GNOME_VFS_ENABLED 131cdf0e10cSrcweir // register GnomeUCP if necessary 132cdf0e10cSrcweir ::ucbhelper::ContentBroker* cb = ::ucbhelper::ContentBroker::get(); 133cdf0e10cSrcweir if(cb) { 134cdf0e10cSrcweir try { 135cdf0e10cSrcweir Reference< XCurrentContext > xCurrentContext( 136cdf0e10cSrcweir getCurrentContext()); 137cdf0e10cSrcweir if (xCurrentContext.is()) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir Any aValue = xCurrentContext->getValueByName( 140cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 141cdf0e10cSrcweir "system.desktop-environment" ) ) 142cdf0e10cSrcweir ); 143cdf0e10cSrcweir rtl::OUString aDesktopEnvironment; 144cdf0e10cSrcweir if ((aValue >>= aDesktopEnvironment) 145cdf0e10cSrcweir && aDesktopEnvironment.equalsAscii("GNOME")) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir Reference<XContentProviderManager> xCPM = 148cdf0e10cSrcweir cb->getContentProviderManagerInterface(); 149cdf0e10cSrcweir #if 0 150cdf0e10cSrcweir try 151cdf0e10cSrcweir { 152cdf0e10cSrcweir 153cdf0e10cSrcweir Reference<XContentProviderFactory> xCPF( 154cdf0e10cSrcweir xServiceFactory->createInstance( 155cdf0e10cSrcweir rtl::OUString::createFromAscii( 156cdf0e10cSrcweir "com.sun.star.ucb.ContentProviderProxyFactory")), 157cdf0e10cSrcweir UNO_QUERY); 158cdf0e10cSrcweir if(xCPF.is()) 159cdf0e10cSrcweir xCPM->registerContentProvider( 160cdf0e10cSrcweir xCPF->createContentProvider( 161cdf0e10cSrcweir rtl::OUString::createFromAscii( 162cdf0e10cSrcweir "com.sun.star.ucb.GnomeVFSContentProvider" 163cdf0e10cSrcweir ) 164cdf0e10cSrcweir ), 165cdf0e10cSrcweir rtl::OUString::createFromAscii(".*"), 166cdf0e10cSrcweir false); 167cdf0e10cSrcweir } catch (...) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir } 170cdf0e10cSrcweir #else 171cdf0e10cSrcweir 172cdf0e10cSrcweir // Workaround for P1 #124597#. Instanciate GNOME-VFS-UCP in the thread that initialized 173cdf0e10cSrcweir // GNOME in order to avoid a deadlock that may occure in case UCP gets initialized from 174cdf0e10cSrcweir // a different thread. The latter may happen when calling the Office remotely via UNO. 175cdf0e10cSrcweir // THIS IS NOT A FIX, JUST A WORKAROUND! 176cdf0e10cSrcweir 177cdf0e10cSrcweir try 178cdf0e10cSrcweir { 179cdf0e10cSrcweir Reference<XContentProvider> xCP( 180cdf0e10cSrcweir xServiceFactory->createInstance( 181cdf0e10cSrcweir rtl::OUString::createFromAscii( 182cdf0e10cSrcweir "com.sun.star.ucb.GnomeVFSContentProvider")), 183cdf0e10cSrcweir UNO_QUERY); 184cdf0e10cSrcweir if(xCP.is()) 185cdf0e10cSrcweir xCPM->registerContentProvider( 186cdf0e10cSrcweir xCP, 187cdf0e10cSrcweir rtl::OUString::createFromAscii(".*"), 188cdf0e10cSrcweir false); 189cdf0e10cSrcweir } catch (...) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir } 192cdf0e10cSrcweir } 193cdf0e10cSrcweir #endif 194cdf0e10cSrcweir } 195cdf0e10cSrcweir } catch (RuntimeException e) { 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir #endif // GNOME_VFS_ENABLED 199cdf0e10cSrcweir 200cdf0e10cSrcweir return ret;; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir Reference< XMultiServiceFactory > Desktop::CreateApplicationServiceManager() 204cdf0e10cSrcweir { 205cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::createApplicationServiceManager" ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir try 208cdf0e10cSrcweir { 209cdf0e10cSrcweir Reference<XComponentContext> xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext(); 210cdf0e10cSrcweir Reference<XMultiServiceFactory> xMS(xComponentContext->getServiceManager(), UNO_QUERY); 211cdf0e10cSrcweir 212cdf0e10cSrcweir return xMS; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir catch( ::com::sun::star::uno::Exception& ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir return Reference< XMultiServiceFactory >(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir void Desktop::DestroyApplicationServiceManager( Reference< XMultiServiceFactory >& xSMgr ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir Reference< XPropertySet > xProps( xSMgr, UNO_QUERY ); 224cdf0e10cSrcweir if ( xProps.is() ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir try 227cdf0e10cSrcweir { 228cdf0e10cSrcweir Reference< XComponent > xComp; 229cdf0e10cSrcweir if (xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComp ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir xComp->dispose(); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir catch ( UnknownPropertyException& ) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir } 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir void Desktop::RegisterServices( Reference< XMultiServiceFactory >& xSMgr ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir if( !m_bServicesRegistered ) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::registerServices" ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir // read command line parameters 247cdf0e10cSrcweir ::rtl::OUString conDcp; 248cdf0e10cSrcweir ::rtl::OUString aClientDisplay; 249cdf0e10cSrcweir ::rtl::OUString aTmpString; 250cdf0e10cSrcweir sal_Bool bHeadlessMode = sal_False; 251cdf0e10cSrcweir 252cdf0e10cSrcweir // interpret command line arguments 253cdf0e10cSrcweir CommandLineArgs* pCmdLine = GetCommandLineArgs(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir // read accept string from configuration 256cdf0e10cSrcweir conDcp = SvtStartOptions().GetConnectionURL(); 257cdf0e10cSrcweir 258cdf0e10cSrcweir if ( pCmdLine->GetAcceptString( aTmpString )) 259cdf0e10cSrcweir conDcp = aTmpString; 260cdf0e10cSrcweir 261cdf0e10cSrcweir // Headless mode for FAT Office 262cdf0e10cSrcweir bHeadlessMode = pCmdLine->IsHeadless(); 263cdf0e10cSrcweir if ( bHeadlessMode ) 264cdf0e10cSrcweir Application::EnableHeadlessMode(); 265cdf0e10cSrcweir 266cdf0e10cSrcweir if ( conDcp.getLength() > 0 ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir // accept incoming connections (scripting and one rvp) 269cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "desktop (lo119109) desktop::Desktop::createAcceptor()" ); 270cdf0e10cSrcweir createAcceptor(conDcp); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir // improves parallel processing on Sun ONE Webtop 274cdf0e10cSrcweir // servicemanager up -> copy user installation 275cdf0e10cSrcweir if ( pCmdLine->IsServer() ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir // Check some mandatory environment states if "-server" is possible. Otherwise ignore 278cdf0e10cSrcweir // this parameter. 279cdf0e10cSrcweir Reference< com::sun::star::container::XContentEnumerationAccess > rContent( xSMgr , UNO_QUERY ); 280cdf0e10cSrcweir if( rContent.is() ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir OUString sPortalService = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.portal.InstallUser" ) ); 283cdf0e10cSrcweir Reference < com::sun::star::container::XEnumeration > rEnum = rContent->createContentEnumeration( sPortalService ); 284cdf0e10cSrcweir if ( !rEnum.is() ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir // Reset server parameter so it is ignored in the furthermore startup process 287cdf0e10cSrcweir pCmdLine->SetBoolParam( CommandLineArgs::CMD_BOOLPARAM_SERVER, sal_False ); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir } 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir ::rtl::OUString aPortalConnect; 293cdf0e10cSrcweir bool bServer = (bool)pCmdLine->IsServer(); 294cdf0e10cSrcweir 295cdf0e10cSrcweir pCmdLine->GetPortalConnectString( aPortalConnect ); 296cdf0e10cSrcweir if ( !configureUcb( bServer, aPortalConnect ) ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir DBG_ERROR( "Can't configure UCB" ); 299cdf0e10cSrcweir throw com::sun::star::uno::Exception(rtl::OUString::createFromAscii("RegisterServices, configureUcb"), NULL); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir CreateTemporaryDirectory(); 303cdf0e10cSrcweir m_bServicesRegistered = true; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir namespace 308cdf0e10cSrcweir { 309cdf0e10cSrcweir struct acceptorMap : public rtl::Static< AcceptorMap, acceptorMap > {}; 310cdf0e10cSrcweir struct CurrentTempURL : public rtl::Static< String, CurrentTempURL > {}; 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir static sal_Bool bAccept = sal_False; 314cdf0e10cSrcweir 315cdf0e10cSrcweir void Desktop::createAcceptor(const OUString& aAcceptString) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir // check whether the requested acceptor already exists 318cdf0e10cSrcweir AcceptorMap &rMap = acceptorMap::get(); 319cdf0e10cSrcweir AcceptorMap::const_iterator pIter = rMap.find(aAcceptString); 320cdf0e10cSrcweir if (pIter == rMap.end() ) { 321cdf0e10cSrcweir 322cdf0e10cSrcweir Sequence< Any > aSeq( 2 ); 323cdf0e10cSrcweir aSeq[0] <<= aAcceptString; 324cdf0e10cSrcweir aSeq[1] <<= bAccept; 325cdf0e10cSrcweir Reference<XInitialization> rAcceptor( 326cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( 327cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.office.Acceptor" )), UNO_QUERY ); 328cdf0e10cSrcweir if ( rAcceptor.is() ) { 329cdf0e10cSrcweir try{ 330cdf0e10cSrcweir rAcceptor->initialize( aSeq ); 331cdf0e10cSrcweir rMap.insert(AcceptorMap::value_type(aAcceptString, rAcceptor)); 332cdf0e10cSrcweir } catch (com::sun::star::uno::Exception&) { 333cdf0e10cSrcweir // no error handling needed... 334cdf0e10cSrcweir // acceptor just won't come up 335cdf0e10cSrcweir OSL_ENSURE(sal_False, "Acceptor could not be created."); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } else { 338cdf0e10cSrcweir // there is already an acceptor with this description 339cdf0e10cSrcweir OSL_ENSURE(sal_False, "Acceptor already exists."); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir class enable 346cdf0e10cSrcweir { 347cdf0e10cSrcweir private: 348cdf0e10cSrcweir Sequence<Any> m_aSeq; 349cdf0e10cSrcweir public: 350cdf0e10cSrcweir enable() : m_aSeq(1) { 351cdf0e10cSrcweir m_aSeq[0] <<= sal_True; 352cdf0e10cSrcweir } 353cdf0e10cSrcweir void operator() (const AcceptorMap::value_type& val) { 354cdf0e10cSrcweir if (val.second.is()) { 355cdf0e10cSrcweir val.second->initialize(m_aSeq); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir } 358cdf0e10cSrcweir }; 359cdf0e10cSrcweir 360cdf0e10cSrcweir void Desktop::enableAcceptors() 361cdf0e10cSrcweir { 362cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "desktop (lo119109) Desktop::enableAcceptors"); 363cdf0e10cSrcweir if (!bAccept) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir // from now on, all new acceptors are enabled 366cdf0e10cSrcweir bAccept = sal_True; 367cdf0e10cSrcweir // enable existing acceptors by calling initialize(true) 368cdf0e10cSrcweir // on all existing acceptors 369cdf0e10cSrcweir AcceptorMap &rMap = acceptorMap::get(); 370cdf0e10cSrcweir std::for_each(rMap.begin(), rMap.end(), enable()); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir void Desktop::destroyAcceptor(const OUString& aAcceptString) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir // special case stop all acceptors 377cdf0e10cSrcweir AcceptorMap &rMap = acceptorMap::get(); 378cdf0e10cSrcweir if (aAcceptString.compareToAscii("all") == 0) { 379cdf0e10cSrcweir rMap.clear(); 380cdf0e10cSrcweir 381cdf0e10cSrcweir } else { 382cdf0e10cSrcweir // try to remove acceptor from map 383cdf0e10cSrcweir AcceptorMap::const_iterator pIter = rMap.find(aAcceptString); 384cdf0e10cSrcweir if (pIter != rMap.end() ) { 385cdf0e10cSrcweir // remove reference from map 386cdf0e10cSrcweir // this is the last reference and the acceptor will be destructed 387cdf0e10cSrcweir rMap.erase(aAcceptString); 388cdf0e10cSrcweir } else { 389cdf0e10cSrcweir OSL_ENSURE(sal_False, "Found no acceptor to remove"); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir } 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir 395cdf0e10cSrcweir void Desktop::DeregisterServices() 396cdf0e10cSrcweir { 397cdf0e10cSrcweir // stop all acceptors by clearing the map 398cdf0e10cSrcweir acceptorMap::get().clear(); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir void Desktop::CreateTemporaryDirectory() 402cdf0e10cSrcweir { 403cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::createTemporaryDirectory" ); 404cdf0e10cSrcweir 405cdf0e10cSrcweir ::rtl::OUString aTempBaseURL; 406cdf0e10cSrcweir try 407cdf0e10cSrcweir { 408cdf0e10cSrcweir SvtPathOptions aOpt; 409cdf0e10cSrcweir aTempBaseURL = aOpt.GetTempPath(); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir catch ( RuntimeException& e ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir // Catch runtime exception here: We have to add language dependent info 414cdf0e10cSrcweir // to the exception message. Fallback solution uses hard coded string. 415cdf0e10cSrcweir OUString aMsg; 416cdf0e10cSrcweir DesktopResId aResId( STR_BOOTSTRAP_ERR_NO_PATHSET_SERVICE ); 417cdf0e10cSrcweir aResId.SetRT( RSC_STRING ); 418cdf0e10cSrcweir if ( aResId.GetResMgr()->IsAvailable( aResId )) 419cdf0e10cSrcweir aMsg = String( aResId ); 420cdf0e10cSrcweir else 421cdf0e10cSrcweir aMsg = OUString( RTL_CONSTASCII_USTRINGPARAM( "The path manager is not available.\n" )); 422cdf0e10cSrcweir e.Message = aMsg + e.Message; 423cdf0e10cSrcweir throw e; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir // remove possible old directory and base directory 427cdf0e10cSrcweir SvtInternalOptions aInternalOpt; 428cdf0e10cSrcweir 429cdf0e10cSrcweir // set temp base directory 430cdf0e10cSrcweir sal_Int32 nLength = aTempBaseURL.getLength(); 431cdf0e10cSrcweir if ( aTempBaseURL.matchAsciiL( "/", 1, nLength-1 ) ) 432cdf0e10cSrcweir aTempBaseURL = aTempBaseURL.copy( 0, nLength - 1 ); 433cdf0e10cSrcweir 434cdf0e10cSrcweir String aOldTempURL = aInternalOpt.GetCurrentTempURL(); 435cdf0e10cSrcweir if ( aOldTempURL.Len() > 0 ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir // remove old temporary directory 438cdf0e10cSrcweir ::utl::UCBContentHelper::Kill( aOldTempURL ); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir String aRet; 442cdf0e10cSrcweir ::rtl::OUString aTempPath( aTempBaseURL ); 443cdf0e10cSrcweir 444cdf0e10cSrcweir // create new current temporary directory 445cdf0e10cSrcweir ::utl::LocalFileHelper::ConvertURLToPhysicalName( aTempBaseURL, aRet ); 446cdf0e10cSrcweir ::osl::FileBase::getFileURLFromSystemPath( aRet, aTempPath ); 447cdf0e10cSrcweir aTempPath = ::utl::TempFile::SetTempNameBaseDirectory( aTempPath ); 448cdf0e10cSrcweir if ( !aTempPath.getLength() ) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir ::osl::File::getTempDirURL( aTempBaseURL ); 451cdf0e10cSrcweir 452cdf0e10cSrcweir nLength = aTempBaseURL.getLength(); 453cdf0e10cSrcweir if ( aTempBaseURL.matchAsciiL( "/", 1, nLength-1 ) ) 454cdf0e10cSrcweir aTempBaseURL = aTempBaseURL.copy( 0, nLength - 1 ); 455cdf0e10cSrcweir 456cdf0e10cSrcweir aTempPath = aTempBaseURL; 457cdf0e10cSrcweir ::osl::FileBase::getFileURLFromSystemPath( aRet, aTempPath ); 458cdf0e10cSrcweir aTempPath = ::utl::TempFile::SetTempNameBaseDirectory( aTempPath ); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir // set new current temporary directory 462cdf0e10cSrcweir ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aTempPath, aRet ); 463cdf0e10cSrcweir aInternalOpt.SetCurrentTempURL( aRet ); 464cdf0e10cSrcweir CurrentTempURL::get() = aRet; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir void Desktop::RemoveTemporaryDirectory() 468cdf0e10cSrcweir { 469cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::removeTemporaryDirectory" ); 470cdf0e10cSrcweir 471cdf0e10cSrcweir // remove current temporary directory 472cdf0e10cSrcweir String &rCurrentTempURL = CurrentTempURL::get(); 473cdf0e10cSrcweir if ( rCurrentTempURL.Len() > 0 ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir if ( ::utl::UCBContentHelper::Kill( rCurrentTempURL ) ) 476cdf0e10cSrcweir SvtInternalOptions().SetCurrentTempURL( String() ); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir } // namespace desktop 481