1 /****************************************************************************
2 **
3 ** Copyright (C) 2006-2008 fullmetalcoder <fullmetalcoder@hotmail.fr>
4 **
5 ** This file is part of the Edyuk project <http://edyuk.org>
6 **
7 ** This file may be used under the terms of the GNU General Public License
8 ** version 2 as published by the Free Software Foundation and appearing in the
9 ** file GPL.txt included in the packaging of this file.
10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 **
14 ****************************************************************************/
15 
16 #ifndef _QINTER_PROCESS_CHANNEL_H_
17 #define _QINTER_PROCESS_CHANNEL_H_
18 
19 #include "qcumber.h"
20 
21 /*!
22     \file qinterprocesschannel.h
23 
24     \brief Definition of the QInterProcessChannel class.
25 */
26 
27 #include <QByteArray>
28 #include <QHostAddress>
29 #include <QString>
30 #include <QThread>
31 
32 class QTimer;
33 class QTcpServer;
34 class QManagedSocket;
35 
36 class QCUMBER_EXPORT QInterProcessChannel : public QThread {
37   Q_OBJECT
38 
39  public:
40   QInterProcessChannel(QObject* p = 0);
41   virtual ~QInterProcessChannel();
42 
43   bool isServer() const;
44 
45   QString messageBuffer() const;
46 
47  public slots:
48   void close();
49   void reconnect();
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 connectionLost();
59 
60   void message(const QString& s);
61   void request(const QStringList& l);
62 
63   void gotServerRole();
64   void serverRoleChanged(bool y);
65 
66  protected:
67   QString rcFile;
68   virtual void run();
69 
70  private slots:
71   void init();
72   void check();
73   void connection();
74   void message(const QString& m, QManagedSocket* s);
75 
76  private:
77   QString sMsg;
78   QHostAddress m_addr;
79   quint16 m_port, m_max;
80 
81   QTcpServer* pServer;
82   QTimer* pServerTimer;
83 };
84 
85 #endif  // !_QINTER_PROCESS_CHANNEL_H_
86