Rename OfficeIPCThread to RequestHandler
Change-Id: I2076d903e83a0b8eb3aa0ce2413630e2c5415b15
This commit is contained in:
parent
a91272a6a4
commit
dde79dd504
@ -112,8 +112,8 @@ bool DeletedSpecial::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
|
||||
|| whitelist(decl, "SwLineInfo", "sw/source/core/text/inftxt.hxx")
|
||||
|| whitelist(decl, "XRenderPeer", "vcl/unx/generic/gdi/xrender_peer.hxx")
|
||||
|| whitelist(decl, "desktop::DispatchWatcher", "desktop/source/app/dispatchwatcher.hxx")
|
||||
|| whitelist(decl, "desktop::OfficeIPCThread", "desktop/source/app/officeipcthread.hxx")
|
||||
|| whitelist(decl, "desktop::OfficeIPCThread", "desktop/source/lib/../app/officeipcthread.hxx")
|
||||
|| whitelist(decl, "desktop::RequestHandler", "desktop/source/app/officeipcthread.hxx")
|
||||
|| whitelist(decl, "desktop::RequestHandler", "desktop/source/lib/../app/officeipcthread.hxx")
|
||||
|| whitelist(decl, "sd::DiscoveryService", "sd/source/ui/remotecontrol/DiscoveryService.hxx")
|
||||
|| whitelist(decl, "sd::IconCache", "sd/source/ui/inc/tools/IconCache.hxx")
|
||||
|| whitelist(decl, "sd::RemoteServer", "sd/source/ui/inc/RemoteServer.hxx")
|
||||
|
@ -199,7 +199,7 @@ namespace {
|
||||
// removed cache data is recreated.
|
||||
//
|
||||
// Multiple instances of soffice.bin can execute this code in parallel for a
|
||||
// single UserInstallation, as it is called before OfficeIPCThread is set up.
|
||||
// single UserInstallation, as it is called before RequestHandler is set up.
|
||||
// Therefore, any errors here only lead to SAL_WARNs.
|
||||
//
|
||||
// At least in theory, this function could be removed again once no
|
||||
@ -576,8 +576,8 @@ void Desktop::Init()
|
||||
const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
|
||||
|
||||
// start ipc thread only for non-remote offices
|
||||
OfficeIPCThread::Status aStatus = OfficeIPCThread::EnableOfficeIPCThread();
|
||||
if ( aStatus == OfficeIPCThread::IPC_STATUS_PIPE_ERROR )
|
||||
RequestHandler::Status aStatus = RequestHandler::Enable();
|
||||
if ( aStatus == RequestHandler::IPC_STATUS_PIPE_ERROR )
|
||||
{
|
||||
#if HAVE_FEATURE_MACOSX_SANDBOX
|
||||
// In a sandboxed LO, on 10.8.2 at least, creating the
|
||||
@ -599,11 +599,11 @@ void Desktop::Init()
|
||||
SetBootstrapError( BE_PATHINFO_MISSING, OUString() );
|
||||
#endif
|
||||
}
|
||||
else if ( aStatus == OfficeIPCThread::IPC_STATUS_BOOTSTRAP_ERROR )
|
||||
else if ( aStatus == RequestHandler::IPC_STATUS_BOOTSTRAP_ERROR )
|
||||
{
|
||||
SetBootstrapError( BE_PATHINFO_MISSING, OUString() );
|
||||
}
|
||||
else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE )
|
||||
else if ( aStatus == RequestHandler::IPC_STATUS_2ND_OFFICE )
|
||||
{
|
||||
// 2nd office startup should terminate after sending cmdlineargs through pipe
|
||||
SetBootstrapStatus(BS_TERMINATE);
|
||||
@ -612,7 +612,7 @@ void Desktop::Init()
|
||||
|| rCmdLineArgs.IsHelp() || rCmdLineArgs.IsVersion() )
|
||||
{
|
||||
// disable IPC thread in an instance that is just showing a help message
|
||||
OfficeIPCThread::DisableOfficeIPCThread();
|
||||
RequestHandler::Disable();
|
||||
}
|
||||
pSignalHandler = osl_addSignalHandler(SalMainPipeExchangeSignal_impl, nullptr);
|
||||
}
|
||||
@ -641,7 +641,7 @@ void Desktop::DeInit()
|
||||
// clear lockfile
|
||||
m_xLockfile.reset();
|
||||
|
||||
OfficeIPCThread::DisableOfficeIPCThread();
|
||||
RequestHandler::Disable();
|
||||
if( pSignalHandler )
|
||||
osl_removeSignalHandler( pSignalHandler );
|
||||
} catch (const RuntimeException&) {
|
||||
@ -677,9 +677,9 @@ bool Desktop::QueryExit()
|
||||
FlushConfiguration();
|
||||
try
|
||||
{
|
||||
// it is no problem to call DisableOfficeIPCThread() more than once
|
||||
// it is no problem to call RequestHandler::Disable() more than once
|
||||
// it also looks to be threadsafe
|
||||
OfficeIPCThread::DisableOfficeIPCThread();
|
||||
RequestHandler::Disable();
|
||||
}
|
||||
catch ( const RuntimeException& )
|
||||
{
|
||||
@ -1154,7 +1154,7 @@ namespace {
|
||||
|
||||
void restartOnMac(bool passArguments) {
|
||||
#if defined MACOSX
|
||||
OfficeIPCThread::DisableOfficeIPCThread();
|
||||
RequestHandler::Disable();
|
||||
#if HAVE_FEATURE_MACOSX_SANDBOX
|
||||
(void) passArguments; // avoid warnings
|
||||
ResMgr *resMgr = Desktop::GetDesktopResManager();
|
||||
@ -1279,7 +1279,7 @@ void Desktop::Exception(sal_uInt16 nError)
|
||||
|
||||
if( bRestart )
|
||||
{
|
||||
OfficeIPCThread::DisableOfficeIPCThread();
|
||||
RequestHandler::Disable();
|
||||
if( pSignalHandler )
|
||||
osl_removeSignalHandler( pSignalHandler );
|
||||
|
||||
@ -1613,7 +1613,7 @@ int Desktop::Main()
|
||||
try
|
||||
{
|
||||
if ( xDesktop.is() )
|
||||
xDesktop->addTerminateListener( new OfficeIPCThreadController );
|
||||
xDesktop->addTerminateListener( new RequestHandlerController );
|
||||
SetSplashScreenProgress(100);
|
||||
}
|
||||
catch ( const css::uno::Exception& e )
|
||||
@ -1659,27 +1659,27 @@ int Desktop::Main()
|
||||
}
|
||||
catch(const css::document::CorruptedFilterConfigurationException& exFilterCfg)
|
||||
{
|
||||
OfficeIPCThread::SetDowning();
|
||||
RequestHandler::SetDowning();
|
||||
FatalError( MakeStartupErrorMessage(exFilterCfg.Message) );
|
||||
}
|
||||
catch(const css::configuration::CorruptedConfigurationException& exAnyCfg)
|
||||
{
|
||||
OfficeIPCThread::SetDowning();
|
||||
RequestHandler::SetDowning();
|
||||
FatalError( MakeStartupErrorMessage(exAnyCfg.Message) );
|
||||
}
|
||||
catch( const css::uno::Exception& exUNO)
|
||||
{
|
||||
OfficeIPCThread::SetDowning();
|
||||
RequestHandler::SetDowning();
|
||||
FatalError( exUNO.Message);
|
||||
}
|
||||
catch( const std::exception& exSTD)
|
||||
{
|
||||
OfficeIPCThread::SetDowning();
|
||||
RequestHandler::SetDowning();
|
||||
FatalError( OUString::createFromAscii( exSTD.what()));
|
||||
}
|
||||
catch( ...)
|
||||
{
|
||||
OfficeIPCThread::SetDowning();
|
||||
RequestHandler::SetDowning();
|
||||
FatalError( "Caught Unknown Exception: Aborting!");
|
||||
}
|
||||
}
|
||||
@ -1943,7 +1943,7 @@ IMPL_LINK_NOARG_TYPED(Desktop, OpenClients_Impl, void*, void)
|
||||
try {
|
||||
OpenClients();
|
||||
|
||||
OfficeIPCThread::SetReady();
|
||||
RequestHandler::SetReady();
|
||||
|
||||
CloseSplashScreen();
|
||||
CheckFirstRun( );
|
||||
@ -2351,7 +2351,7 @@ void Desktop::OpenClients()
|
||||
CrashReporter::writeCommonInfo();
|
||||
#endif
|
||||
|
||||
OfficeIPCThread::EnableRequests();
|
||||
RequestHandler::EnableRequests();
|
||||
|
||||
ProcessDocumentsRequest aRequest(rArgs.getCwdUrl());
|
||||
aRequest.aOpenList = rArgs.GetOpenList();
|
||||
@ -2407,7 +2407,7 @@ void Desktop::OpenClients()
|
||||
}
|
||||
|
||||
// Process request
|
||||
if ( OfficeIPCThread::ExecuteCmdLineRequests(aRequest, false) )
|
||||
if ( RequestHandler::ExecuteCmdLineRequests(aRequest, false) )
|
||||
{
|
||||
// Don't do anything if we have successfully called terminate at desktop:
|
||||
return;
|
||||
@ -2481,7 +2481,7 @@ void Desktop::OpenDefault()
|
||||
|
||||
ProcessDocumentsRequest aRequest(rArgs.getCwdUrl());
|
||||
aRequest.aOpenList.push_back(aName);
|
||||
OfficeIPCThread::ExecuteCmdLineRequests(aRequest, false);
|
||||
RequestHandler::ExecuteCmdLineRequests(aRequest, false);
|
||||
}
|
||||
|
||||
|
||||
@ -2604,7 +2604,7 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
|
||||
std::vector<OUString> const & data(rAppEvent.GetStringsData());
|
||||
docsRequest.aOpenList.insert(
|
||||
docsRequest.aOpenList.end(), data.begin(), data.end());
|
||||
OfficeIPCThread::ExecuteCmdLineRequests(docsRequest, false);
|
||||
RequestHandler::ExecuteCmdLineRequests(docsRequest, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2621,7 +2621,7 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
|
||||
std::vector<OUString> const & data(rAppEvent.GetStringsData());
|
||||
docsRequest.aPrintList.insert(
|
||||
docsRequest.aPrintList.end(), data.begin(), data.end());
|
||||
OfficeIPCThread::ExecuteCmdLineRequests(docsRequest, false);
|
||||
RequestHandler::ExecuteCmdLineRequests(docsRequest, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -201,7 +201,7 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
|
||||
{
|
||||
bSetInputFilter = true;
|
||||
aForcedInputFilter = aDispatchRequest.aURL;
|
||||
OfficeIPCThread::RequestsCompleted();
|
||||
RequestHandler::RequestsCompleted();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
|
||||
aDispatchRequest.aRequestType == REQUEST_FORCENEW )
|
||||
{
|
||||
// request is completed
|
||||
OfficeIPCThread::RequestsCompleted();
|
||||
RequestHandler::RequestsCompleted();
|
||||
}
|
||||
else if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
|
||||
aDispatchRequest.aRequestType == REQUEST_PRINTTO ||
|
||||
@ -662,7 +662,7 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
|
||||
}
|
||||
|
||||
// request is completed
|
||||
OfficeIPCThread::RequestsCompleted();
|
||||
RequestHandler::RequestsCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -727,8 +727,8 @@ void SAL_CALL DispatchWatcher::dispatchFinished( const DispatchResultEvent& ) th
|
||||
osl::ClearableMutexGuard aGuard(m_mutex);
|
||||
sal_Int16 nCount = --m_nRequestCount;
|
||||
aGuard.clear();
|
||||
OfficeIPCThread::RequestsCompleted();
|
||||
if ( !nCount && !OfficeIPCThread::AreRequestsPending() )
|
||||
RequestHandler::RequestsCompleted();
|
||||
if ( !nCount && !RequestHandler::AreRequestsPending() )
|
||||
{
|
||||
// We have to check if we have an open task otherwise we have to shutdown the office.
|
||||
Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( ::comphelper::getProcessComponentContext() );
|
||||
|
@ -242,7 +242,7 @@ bool addArgument(OStringBuffer &rArguments, char prefix,
|
||||
|
||||
}
|
||||
|
||||
rtl::Reference< OfficeIPCThread > OfficeIPCThread::pGlobalOfficeIPCThread;
|
||||
rtl::Reference< RequestHandler > RequestHandler::pGlobal;
|
||||
|
||||
// Turns a string in aMsg such as file:///home/foo/.libreoffice/3
|
||||
// Into a hex string of well known length ff132a86...
|
||||
@ -290,9 +290,9 @@ IMPL_STATIC_LINK_TYPED( ProcessEventsClass_Impl, CallEvent, void*, pEvent, void
|
||||
|
||||
IMPL_STATIC_LINK_TYPED( ProcessEventsClass_Impl, ProcessDocumentsEvent, void*, pEvent, void )
|
||||
{
|
||||
// Documents requests are processed by the OfficeIPCThread implementation
|
||||
// Documents requests are processed by the RequestHandler implementation
|
||||
ProcessDocumentsRequest* pDocsRequest = static_cast<ProcessDocumentsRequest*>(pEvent);
|
||||
OfficeIPCThread::ExecuteCmdLineRequests(*pDocsRequest, false);
|
||||
RequestHandler::ExecuteCmdLineRequests(*pDocsRequest, false);
|
||||
delete pDocsRequest;
|
||||
}
|
||||
|
||||
@ -309,34 +309,34 @@ void ImplPostProcessDocumentsEvent( ProcessDocumentsRequest* pEvent )
|
||||
oslSignalAction SAL_CALL SalMainPipeExchangeSignal_impl(void* /*pData*/, oslSignalInfo* pInfo)
|
||||
{
|
||||
if( pInfo->Signal == osl_Signal_Terminate )
|
||||
OfficeIPCThread::DisableOfficeIPCThread(false);
|
||||
RequestHandler::Disable(false);
|
||||
return osl_Signal_ActCallNextHdl;
|
||||
}
|
||||
|
||||
|
||||
// The OfficeIPCThreadController implementation is a bookkeeper for all pending requests
|
||||
// that were created by the OfficeIPCThread. The requests are waiting to be processed by
|
||||
// The RequestHandlerController implementation is a bookkeeper for all pending requests
|
||||
// that were created by the RequestHandler. The requests are waiting to be processed by
|
||||
// our framework loadComponentFromURL function (e.g. open/print request).
|
||||
// During shutdown the framework is asking OfficeIPCThreadController about pending requests.
|
||||
// During shutdown the framework is asking RequestHandlerController about pending requests.
|
||||
// If there are pending requests framework has to stop the shutdown process. It is waiting
|
||||
// for these requests because framework is not able to handle shutdown and open a document
|
||||
// concurrently.
|
||||
|
||||
|
||||
// XServiceInfo
|
||||
OUString SAL_CALL OfficeIPCThreadController::getImplementationName()
|
||||
OUString SAL_CALL RequestHandlerController::getImplementationName()
|
||||
throw ( RuntimeException, std::exception )
|
||||
{
|
||||
return OUString( "com.sun.star.comp.OfficeIPCThreadController" );
|
||||
return OUString( "com.sun.star.comp.RequestHandlerController" );
|
||||
}
|
||||
|
||||
sal_Bool OfficeIPCThreadController::supportsService(
|
||||
sal_Bool RequestHandlerController::supportsService(
|
||||
OUString const & ServiceName) throw (css::uno::RuntimeException, std::exception)
|
||||
{
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
Sequence< OUString > SAL_CALL OfficeIPCThreadController::getSupportedServiceNames()
|
||||
Sequence< OUString > SAL_CALL RequestHandlerController::getSupportedServiceNames()
|
||||
throw ( RuntimeException, std::exception )
|
||||
{
|
||||
Sequence< OUString > aSeq( 0 );
|
||||
@ -344,33 +344,33 @@ throw ( RuntimeException, std::exception )
|
||||
}
|
||||
|
||||
// XEventListener
|
||||
void SAL_CALL OfficeIPCThreadController::disposing( const EventObject& )
|
||||
void SAL_CALL RequestHandlerController::disposing( const EventObject& )
|
||||
throw( RuntimeException, std::exception )
|
||||
{
|
||||
}
|
||||
|
||||
// XTerminateListener
|
||||
void SAL_CALL OfficeIPCThreadController::queryTermination( const EventObject& )
|
||||
void SAL_CALL RequestHandlerController::queryTermination( const EventObject& )
|
||||
throw( TerminationVetoException, RuntimeException, std::exception )
|
||||
{
|
||||
// Desktop ask about pending request through our office ipc pipe. We have to
|
||||
// be sure that no pending request is waiting because framework is not able to
|
||||
// handle shutdown and open a document concurrently.
|
||||
|
||||
if ( OfficeIPCThread::AreRequestsPending() )
|
||||
if ( RequestHandler::AreRequestsPending() )
|
||||
throw TerminationVetoException();
|
||||
else
|
||||
OfficeIPCThread::SetDowning();
|
||||
RequestHandler::SetDowning();
|
||||
}
|
||||
|
||||
void SAL_CALL OfficeIPCThreadController::notifyTermination( const EventObject& )
|
||||
void SAL_CALL RequestHandlerController::notifyTermination( const EventObject& )
|
||||
throw( RuntimeException, std::exception )
|
||||
{
|
||||
}
|
||||
|
||||
class PipeReaderThread: public salhelper::Thread {
|
||||
public:
|
||||
PipeReaderThread(OfficeIPCThread & ipc, osl::Pipe const & pipe):
|
||||
PipeReaderThread(RequestHandler & ipc, osl::Pipe const & pipe):
|
||||
Thread("PipeReader"), ipc_(ipc), pipe_(pipe)
|
||||
{}
|
||||
|
||||
@ -381,75 +381,75 @@ private:
|
||||
|
||||
void execute() override;
|
||||
|
||||
OfficeIPCThread & ipc_;
|
||||
RequestHandler & ipc_;
|
||||
osl::Pipe pipe_;
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
class theOfficeIPCThreadMutex
|
||||
: public rtl::Static<osl::Mutex, theOfficeIPCThreadMutex> {};
|
||||
class theRequestHandlerMutex
|
||||
: public rtl::Static<osl::Mutex, theRequestHandlerMutex> {};
|
||||
}
|
||||
|
||||
::osl::Mutex& OfficeIPCThread::GetMutex()
|
||||
::osl::Mutex& RequestHandler::GetMutex()
|
||||
{
|
||||
return theOfficeIPCThreadMutex::get();
|
||||
return theRequestHandlerMutex::get();
|
||||
}
|
||||
|
||||
void OfficeIPCThread::SetDowning()
|
||||
void RequestHandler::SetDowning()
|
||||
{
|
||||
// We have the order to block all incoming requests. Framework
|
||||
// wants to shutdown and we have to make sure that no loading/printing
|
||||
// requests are executed anymore.
|
||||
::osl::MutexGuard aGuard( GetMutex() );
|
||||
|
||||
if ( pGlobalOfficeIPCThread.is() )
|
||||
pGlobalOfficeIPCThread->mState = State::Downing;
|
||||
if ( pGlobal.is() )
|
||||
pGlobal->mState = State::Downing;
|
||||
}
|
||||
|
||||
void OfficeIPCThread::EnableRequests()
|
||||
void RequestHandler::EnableRequests()
|
||||
{
|
||||
// switch between just queueing the requests and executing them
|
||||
::osl::MutexGuard aGuard( GetMutex() );
|
||||
|
||||
if ( pGlobalOfficeIPCThread.is() )
|
||||
if ( pGlobal.is() )
|
||||
{
|
||||
if (pGlobalOfficeIPCThread->mState != State::Downing) {
|
||||
pGlobalOfficeIPCThread->mState = State::RequestsEnabled;
|
||||
if (pGlobal->mState != State::Downing) {
|
||||
pGlobal->mState = State::RequestsEnabled;
|
||||
}
|
||||
// hit the compiler over the head
|
||||
ProcessDocumentsRequest aEmptyReq = ProcessDocumentsRequest( boost::optional< OUString >() );
|
||||
// trigger already queued requests
|
||||
OfficeIPCThread::ExecuteCmdLineRequests(aEmptyReq, true);
|
||||
RequestHandler::ExecuteCmdLineRequests(aEmptyReq, true);
|
||||
}
|
||||
}
|
||||
|
||||
bool OfficeIPCThread::AreRequestsPending()
|
||||
bool RequestHandler::AreRequestsPending()
|
||||
{
|
||||
// Give info about pending requests
|
||||
::osl::MutexGuard aGuard( GetMutex() );
|
||||
if ( pGlobalOfficeIPCThread.is() )
|
||||
return ( pGlobalOfficeIPCThread->mnPendingRequests > 0 );
|
||||
if ( pGlobal.is() )
|
||||
return ( pGlobal->mnPendingRequests > 0 );
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void OfficeIPCThread::RequestsCompleted()
|
||||
void RequestHandler::RequestsCompleted()
|
||||
{
|
||||
// Remove nCount pending requests from our internal counter
|
||||
::osl::MutexGuard aGuard( GetMutex() );
|
||||
if ( pGlobalOfficeIPCThread.is() )
|
||||
if ( pGlobal.is() )
|
||||
{
|
||||
if ( pGlobalOfficeIPCThread->mnPendingRequests > 0 )
|
||||
pGlobalOfficeIPCThread->mnPendingRequests --;
|
||||
if ( pGlobal->mnPendingRequests > 0 )
|
||||
pGlobal->mnPendingRequests --;
|
||||
}
|
||||
}
|
||||
|
||||
OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
|
||||
RequestHandler::Status RequestHandler::Enable()
|
||||
{
|
||||
::osl::MutexGuard aGuard( GetMutex() );
|
||||
|
||||
if( pGlobalOfficeIPCThread.is() )
|
||||
if( pGlobal.is() )
|
||||
return IPC_STATUS_OK;
|
||||
|
||||
#if HAVE_FEATURE_DESKTOP
|
||||
@ -462,7 +462,7 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
|
||||
|
||||
// In LibreOfficeKit-based programs we want to be totally independent from any other LibreOffice
|
||||
// instance or LOKit-using program. Certainly no need for any IPC pipes by definition, as we
|
||||
// don't have any reason to do any IPC. Why we even call this EnableOfficeIPCThread function
|
||||
// don't have any reason to do any IPC. Why we even call this Enable function
|
||||
// from LibreOfficeKit's lo_initialize() I am not completely sure, but that code, and this, is
|
||||
// such horrible crack that I don't want to change it too much.
|
||||
|
||||
@ -584,9 +584,9 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
|
||||
if ( nPipeMode == PIPEMODE_CREATED )
|
||||
{
|
||||
// Seems we are the one and only, so start listening thread
|
||||
rtl::Reference< OfficeIPCThread > pThread(new OfficeIPCThread);
|
||||
rtl::Reference< RequestHandler > pThread(new RequestHandler);
|
||||
pThread->mPipeReaderThread = new PipeReaderThread(*pThread, pipe);
|
||||
pGlobalOfficeIPCThread = pThread;
|
||||
pGlobal = pThread;
|
||||
pThread->mPipeReaderThread->launch();
|
||||
}
|
||||
else
|
||||
@ -627,67 +627,66 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
|
||||
return IPC_STATUS_2ND_OFFICE;
|
||||
}
|
||||
#else
|
||||
rtl::Reference< OfficeIPCThread > pThread(new OfficeIPCThread);
|
||||
pGlobalOfficeIPCThread = pThread;
|
||||
rtl::Reference< RequestHandler > pThread(new RequestHandler);
|
||||
pGlobal = pThread;
|
||||
#endif
|
||||
return IPC_STATUS_OK;
|
||||
}
|
||||
|
||||
void OfficeIPCThread::DisableOfficeIPCThread(bool join)
|
||||
void RequestHandler::Disable(bool join)
|
||||
{
|
||||
osl::ClearableMutexGuard aMutex( GetMutex() );
|
||||
|
||||
if( pGlobalOfficeIPCThread.is() )
|
||||
if( pGlobal.is() )
|
||||
{
|
||||
rtl::Reference< OfficeIPCThread > pOfficeIPCThread(
|
||||
pGlobalOfficeIPCThread);
|
||||
pGlobalOfficeIPCThread.clear();
|
||||
rtl::Reference< RequestHandler > handler(pGlobal);
|
||||
pGlobal.clear();
|
||||
|
||||
pOfficeIPCThread->mState = State::Downing;
|
||||
if (pOfficeIPCThread->mPipeReaderThread.is()) {
|
||||
pOfficeIPCThread->mPipeReaderThread->close();
|
||||
handler->mState = State::Downing;
|
||||
if (handler->mPipeReaderThread.is()) {
|
||||
handler->mPipeReaderThread->close();
|
||||
}
|
||||
|
||||
// release mutex to avoid deadlocks
|
||||
aMutex.clear();
|
||||
|
||||
pOfficeIPCThread->cReady.set();
|
||||
handler->cReady.set();
|
||||
|
||||
// exit gracefully and join
|
||||
if (join && pOfficeIPCThread->mPipeReaderThread.is())
|
||||
if (join && handler->mPipeReaderThread.is())
|
||||
{
|
||||
pOfficeIPCThread->mPipeReaderThread->join();
|
||||
pOfficeIPCThread->mPipeReaderThread.clear();
|
||||
handler->mPipeReaderThread->join();
|
||||
handler->mPipeReaderThread.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OfficeIPCThread::OfficeIPCThread() :
|
||||
RequestHandler::RequestHandler() :
|
||||
mState( State::Starting ),
|
||||
mnPendingRequests( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
OfficeIPCThread::~OfficeIPCThread()
|
||||
RequestHandler::~RequestHandler()
|
||||
{
|
||||
assert(!mPipeReaderThread.is());
|
||||
}
|
||||
|
||||
void OfficeIPCThread::SetReady()
|
||||
void RequestHandler::SetReady()
|
||||
{
|
||||
osl::MutexGuard g(GetMutex());
|
||||
if (pGlobalOfficeIPCThread.is())
|
||||
if (pGlobal.is())
|
||||
{
|
||||
pGlobalOfficeIPCThread->cReady.set();
|
||||
pGlobal->cReady.set();
|
||||
}
|
||||
}
|
||||
|
||||
void OfficeIPCThread::WaitForReady()
|
||||
void RequestHandler::WaitForReady()
|
||||
{
|
||||
rtl::Reference<OfficeIPCThread> t;
|
||||
rtl::Reference<RequestHandler> t;
|
||||
{
|
||||
osl::MutexGuard g(GetMutex());
|
||||
t = pGlobalOfficeIPCThread;
|
||||
t = pGlobal;
|
||||
}
|
||||
if (t.is())
|
||||
{
|
||||
@ -695,10 +694,10 @@ void OfficeIPCThread::WaitForReady()
|
||||
}
|
||||
}
|
||||
|
||||
bool OfficeIPCThread::IsEnabled()
|
||||
bool RequestHandler::IsEnabled()
|
||||
{
|
||||
osl::MutexGuard g(GetMutex());
|
||||
return pGlobalOfficeIPCThread.is();
|
||||
return pGlobal.is();
|
||||
}
|
||||
|
||||
void PipeReaderThread::execute()
|
||||
@ -723,13 +722,13 @@ void PipeReaderThread::execute()
|
||||
ipc_.cReady.wait();
|
||||
|
||||
// we might have decided to shutdown while we were sleeping
|
||||
if (!ipc_.pGlobalOfficeIPCThread.is()) return;
|
||||
if (!ipc_.pGlobal.is()) return;
|
||||
|
||||
// only lock the mutex when processing starts, othewise we deadlock when the office goes
|
||||
// down during wait
|
||||
osl::ClearableMutexGuard aGuard( OfficeIPCThread::GetMutex() );
|
||||
osl::ClearableMutexGuard aGuard( RequestHandler::GetMutex() );
|
||||
|
||||
if ( ipc_.mState == OfficeIPCThread::State::Downing )
|
||||
if ( ipc_.mState == RequestHandler::State::Downing )
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -967,8 +966,8 @@ void PipeReaderThread::execute()
|
||||
else
|
||||
{
|
||||
{
|
||||
osl::MutexGuard aGuard( OfficeIPCThread::GetMutex() );
|
||||
if ( ipc_.mState == OfficeIPCThread::State::Downing )
|
||||
osl::MutexGuard aGuard( RequestHandler::GetMutex() );
|
||||
if ( ipc_.mState == RequestHandler::State::Downing )
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -1049,7 +1048,7 @@ static void AddConversionsToDispatchList(
|
||||
}
|
||||
|
||||
|
||||
bool OfficeIPCThread::ExecuteCmdLineRequests(
|
||||
bool RequestHandler::ExecuteCmdLineRequests(
|
||||
ProcessDocumentsRequest& aRequest, bool noTerminate)
|
||||
{
|
||||
// protect the dispatch list
|
||||
@ -1069,18 +1068,18 @@ bool OfficeIPCThread::ExecuteCmdLineRequests(
|
||||
AddConversionsToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aConversionList, aRequest.aConversionParams, aRequest.aPrinterName, aRequest.aModule, aRequest.aConversionOut, aRequest.bTextCat );
|
||||
bool bShutdown( false );
|
||||
|
||||
if ( pGlobalOfficeIPCThread.is() )
|
||||
if ( pGlobal.is() )
|
||||
{
|
||||
if( ! pGlobalOfficeIPCThread->AreRequestsEnabled() )
|
||||
if( ! pGlobal->AreRequestsEnabled() )
|
||||
return bShutdown;
|
||||
|
||||
pGlobalOfficeIPCThread->mnPendingRequests += aDispatchList.size();
|
||||
if ( !pGlobalOfficeIPCThread->mpDispatchWatcher.is() )
|
||||
pGlobal->mnPendingRequests += aDispatchList.size();
|
||||
if ( !pGlobal->mpDispatchWatcher.is() )
|
||||
{
|
||||
pGlobalOfficeIPCThread->mpDispatchWatcher = new DispatchWatcher;
|
||||
pGlobal->mpDispatchWatcher = new DispatchWatcher;
|
||||
}
|
||||
rtl::Reference<DispatchWatcher> dispatchWatcher(
|
||||
pGlobalOfficeIPCThread->mpDispatchWatcher);
|
||||
pGlobal->mpDispatchWatcher);
|
||||
|
||||
// copy for execute
|
||||
std::vector<DispatchWatcher::DispatchRequest> aTempList( aDispatchList );
|
||||
|
@ -69,12 +69,12 @@ struct ProcessDocumentsRequest
|
||||
class DispatchWatcher;
|
||||
class PipeReaderThread;
|
||||
|
||||
class OfficeIPCThread: public salhelper::SimpleReferenceObject
|
||||
class RequestHandler: public salhelper::SimpleReferenceObject
|
||||
{
|
||||
friend PipeReaderThread;
|
||||
|
||||
private:
|
||||
static rtl::Reference< OfficeIPCThread > pGlobalOfficeIPCThread;
|
||||
static rtl::Reference< RequestHandler > pGlobal;
|
||||
|
||||
enum class State { Starting, RequestsEnabled, Downing };
|
||||
|
||||
@ -93,9 +93,9 @@ class OfficeIPCThread: public salhelper::SimpleReferenceObject
|
||||
|
||||
static ::osl::Mutex& GetMutex();
|
||||
|
||||
OfficeIPCThread();
|
||||
RequestHandler();
|
||||
|
||||
virtual ~OfficeIPCThread();
|
||||
virtual ~RequestHandler();
|
||||
|
||||
public:
|
||||
enum Status
|
||||
@ -115,8 +115,8 @@ class OfficeIPCThread: public salhelper::SimpleReferenceObject
|
||||
ProcessDocumentsRequest&, bool noTerminate);
|
||||
|
||||
// return sal_False if second office
|
||||
static Status EnableOfficeIPCThread();
|
||||
static void DisableOfficeIPCThread(bool join = true);
|
||||
static Status Enable();
|
||||
static void Disable(bool join = true);
|
||||
// start dispatching events...
|
||||
static void SetReady();
|
||||
static void WaitForReady();
|
||||
@ -126,13 +126,13 @@ class OfficeIPCThread: public salhelper::SimpleReferenceObject
|
||||
};
|
||||
|
||||
|
||||
class OfficeIPCThreadController : public ::cppu::WeakImplHelper<
|
||||
class RequestHandlerController : public ::cppu::WeakImplHelper<
|
||||
css::lang::XServiceInfo,
|
||||
css::frame::XTerminateListener >
|
||||
{
|
||||
public:
|
||||
OfficeIPCThreadController() {}
|
||||
virtual ~OfficeIPCThreadController() {}
|
||||
RequestHandlerController() {}
|
||||
virtual ~RequestHandlerController() {}
|
||||
|
||||
// XServiceInfo
|
||||
virtual OUString SAL_CALL getImplementationName()
|
||||
|
@ -1921,7 +1921,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
|
||||
}
|
||||
|
||||
// This is horrible crack. I really would want to go back to simply just call
|
||||
// InitVCL() here. The OfficeIPCThread thing is just horrible.
|
||||
// InitVCL() here. The RequestHandler thing is just horrible.
|
||||
|
||||
// We could use InitVCL() here -- and used to before using soffice_main,
|
||||
// however that now deals with the initialisation for us (and it's not
|
||||
@ -1934,25 +1934,25 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
|
||||
// functions depend on VCL being ready -- the deadlocks would happen
|
||||
// if you try to use loadDocument too early.
|
||||
|
||||
// The OfficeIPCThread is specifically set to be ready when all the other
|
||||
// The RequestHandler is specifically set to be ready when all the other
|
||||
// init in Desktop::Main (run from soffice_main) is done. We can "enable"
|
||||
// the Thread from wherever (it's done again in Desktop::Main), and can
|
||||
// then use it to wait until we're definitely ready to continue.
|
||||
|
||||
if (eStage != PRE_INIT)
|
||||
{
|
||||
SAL_INFO("lok", "Enabling OfficeIPCThread");
|
||||
OfficeIPCThread::EnableOfficeIPCThread();
|
||||
SAL_INFO("lok", "Enabling RequestHandler");
|
||||
RequestHandler::Enable();
|
||||
SAL_INFO("lok", "Starting soffice_main");
|
||||
pLib->maThread = osl_createThread(lo_startmain, nullptr);
|
||||
SAL_INFO("lok", "Waiting for OfficeIPCThread");
|
||||
OfficeIPCThread::WaitForReady();
|
||||
SAL_INFO("lok", "OfficeIPCThread ready -- continuing");
|
||||
SAL_INFO("lok", "Waiting for RequestHandler");
|
||||
RequestHandler::WaitForReady();
|
||||
SAL_INFO("lok", "RequestHandler ready -- continuing");
|
||||
|
||||
// If the Thread has been disabled again that indicates that a
|
||||
// restart is required (or in any case we don't have a useable
|
||||
// process around).
|
||||
if (!OfficeIPCThread::IsEnabled())
|
||||
if (!RequestHandler::IsEnabled())
|
||||
{
|
||||
fprintf(stderr, "LOK init failed -- restart required\n");
|
||||
return false;
|
||||
|
@ -385,7 +385,7 @@ void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::fra
|
||||
m_xSfxTerminator = xListener;
|
||||
return;
|
||||
}
|
||||
if( sImplementationName == "com.sun.star.comp.OfficeIPCThreadController" )
|
||||
if( sImplementationName == "com.sun.star.comp.RequestHandlerController" )
|
||||
{
|
||||
m_xPipeTerminator = xListener;
|
||||
return;
|
||||
@ -424,7 +424,7 @@ void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::
|
||||
return;
|
||||
}
|
||||
|
||||
if( sImplementationName == "com.sun.star.comp.OfficeIPCThreadController" )
|
||||
if( sImplementationName == "com.sun.star.comp.RequestHandlerController" )
|
||||
{
|
||||
m_xPipeTerminator.clear();
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user