1 /*****************************************************************************
2 ** QNapi
3 ** Copyright (C) 2008-2017 Piotr Krzemiński <pio.krzeminski@gmail.com>
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 **
13 *****************************************************************************/
14 
15 #ifndef _QINTER_PROCESS_CHANNEL_H_
16 #define _QINTER_PROCESS_CHANNEL_H_
17 
18 #include "qcumber.h"
19 #include "qmanagedrequest.h"
20 
21 #include <QApplication>
22 #include <QByteArray>
23 #include <QString>
24 #include <QThread>
25 
26 #include <qt_windows.h>
27 
28 /*!
29     \file qinterprocesschannel.h
30 
31     \brief Definition of the QInterProcessChannel class.
32 */
33 
34 // buffer size for input/output pipes
35 static const int bufferSize = 2048;
36 
37 class QCUMBER_EXPORT QInterProcessChannel : public QThread {
38   Q_OBJECT
39 
40  public:
41   QInterProcessChannel(QObject* p = 0);
42   virtual ~QInterProcessChannel();
43 
44   bool isServer() const;
45 
46   QString messageBuffer() const;
47 
48  public slots:
49   void close();
50 
51   void sendMessage();
52   void sendMessage(const QString& s);
53   void sendMessage(const QByteArray& b);
54 
55   void setMessageBuffer(const QString& s);
56 
57  signals:
58   void message(const QString& s);
59   void request(const QStringList& l);
60 
61  protected:
62   virtual void run();
63 
64  private slots:
65   void init();
66 
67  private:
68   QString uniqPrefix, pipeName, globalMutexStr, blockerMutexStr;
69   QString sMsg;
70   bool serverMode;
71 };
72 
73 #endif  // _QINTER_PROCESS_CHANNEL_H_
74