LibreOffice Module desktop (master)  1
officeipcthread.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
21 #define INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
22 
23 #include <sal/config.h>
24 
25 #include <vector>
26 
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/frame/XTerminateListener.hpp>
29 #include <osl/pipe.hxx>
30 #include <osl/security.hxx>
31 #include <osl/signal.h>
32 #include <rtl/ref.hxx>
33 #include <rtl/ustring.hxx>
34 #include <cppuhelper/implbase.hxx>
35 #include <osl/conditn.hxx>
36 #include <salhelper/thread.hxx>
37 #include <boost/optional.hpp>
38 
39 namespace desktop
40 {
41 
42 oslSignalAction SalMainPipeExchangeSignal_impl(void* /*pData*/, oslSignalInfo* pInfo);
43 
44 // A request for the current office
45 // that was given by command line or by IPC pipe communication.
47 {
49  aCwdUrl(cwdUrl), pcProcessed( nullptr ), bTextCat( false ), bScriptCat( false ) {}
50 
52  OUString aModule;
53  std::vector< OUString > aOpenList; // Documents that should be opened in the default way
54  std::vector< OUString > aViewList; // Documents that should be opened in viewmode
55  std::vector< OUString > aStartList; // Documents/Presentations that should be started
56  std::vector< OUString > aPrintList; // Documents that should be printed on default printer
57  std::vector< OUString > aForceOpenList; // Documents that should be forced to open for editing (even templates)
58  std::vector< OUString > aForceNewList; // Documents that should be forced to create a new document
59  OUString aPrinterName; // The printer name that should be used for printing
60  std::vector< OUString > aPrintToList; // Documents that should be printed on the given printer
61  std::vector< OUString > aConversionList;
63  OUString aConversionOut;
65  std::vector< OUString > aInFilter;
66  ::osl::Condition *pcProcessed; // pointer condition to be set when the request has been processed
67  bool* mpbSuccess = nullptr; // pointer to boolean receiving if the processing was successful
68  bool bTextCat; // boolean flag indicating whether to dump text content to console
69  bool bScriptCat; // boolean flag indicating whether to dump script content to console
70 };
71 
72 class DispatchWatcher;
73 class IpcThread;
74 class PipeIpcThread;
75 class DbusIpcThread;
76 
78 {
79  friend IpcThread;
80  friend PipeIpcThread;
81  friend DbusIpcThread;
82 
83  private:
85 
87 
92 
93  /* condition to be set when the request has been processed */
94  ::osl::Condition cProcessed;
95  /* receives if the processing was successful (may be false e.g. when shutting down) */
96  bool mbSuccess = false;
97 
98  /* condition to be set when the main event loop is ready
99  otherwise an error dialogs event loop could eat away
100  requests from a 2nd office */
101  ::osl::Condition cReady;
102 
103  static ::osl::Mutex& GetMutex();
104 
105  RequestHandler();
106 
107  virtual ~RequestHandler() override;
108 
109  public:
110  enum Status
111  {
116  };
117 
118  // controlling pipe communication during shutdown
119  static void SetDowning();
120  static void EnableRequests();
121  static bool AreRequestsPending();
122  static void RequestsCompleted();
123  static bool ExecuteCmdLineRequests(
124  ProcessDocumentsRequest&, bool noTerminate);
125 
126  // return sal_False if second office
127  static Status Enable(bool ipc);
128  static void Disable();
129  // start dispatching events...
130  static void SetReady(bool bIsReady);
131  static void WaitForReady();
132 
133  bool AreRequestsEnabled() const { return mState == State::RequestsEnabled; }
134 };
135 
136 
137 class RequestHandlerController : public ::cppu::WeakImplHelper<
138  css::lang::XServiceInfo,
139  css::frame::XTerminateListener >
140 {
141  public:
143 
144  // XServiceInfo
145  virtual OUString SAL_CALL getImplementationName() override;
146  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
147  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
148 
149  // XEventListener
150  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
151 
152  // XTerminateListener
153  virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override;
154  virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override;
155 };
156 
157 }
158 
159 #endif // INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
160 
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< IpcThread > mIpcThread
std::vector< OUString > aOpenList
static bool ExecuteCmdLineRequests(ProcessDocumentsRequest &, bool noTerminate)
std::vector< OUString > aForceNewList
Definition: app.cxx:168
std::vector< OUString > aViewList
static rtl::Reference< RequestHandler > pGlobal
virtual void SAL_CALL queryTermination(const css::lang::EventObject &aEvent) override
rtl::Reference< DispatchWatcher > mpDispatchWatcher
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
std::vector< OUString > aForceOpenList
std::vector< OUString > aPrintToList
ProcessDocumentsRequest(boost::optional< OUString > const &cwdUrl)
static bool AreRequestsPending()
static void SetReady(bool bIsReady)
unsigned char sal_Bool
virtual ~RequestHandler() override
std::vector< OUString > aConversionList
std::vector< OUString > aStartList
boost::optional< OUString > aCwdUrl
bool AreRequestsEnabled() const
static Status Enable(bool ipc)
std::vector< OUString > aPrintList
::osl::Condition cProcessed
std::vector< OUString > aInFilter
oslSignalAction SalMainPipeExchangeSignal_impl(SAL_UNUSED_PARAMETER void *, oslSignalInfo *pInfo)