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