]> git.lyx.org Git - lyx.git/blob - development/lyxserver/server_monitor.h
ctest: invert es/Intro_docbook5
[lyx.git] / development / lyxserver / server_monitor.h
1 /**
2  * \file server_monitor.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Enrico Forestieri
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #ifndef SERVER_MONITOR_H
12 #define SERVER_MONITOR_H
13
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <unistd.h>
17
18 #include <QDialog>
19 #include <QFile>
20 #include <QLineEdit>
21
22 #ifdef _WIN32
23 #include <windows.h>
24 #ifdef _MSC_VER
25 #include <io.h>
26 #define open _open
27 #define close _close
28 #define read _read
29 #define write _write
30 #define snprintf _snprintf
31 #define O_RDONLY _O_RDONLY
32 #define O_WRONLY _O_WRONLY
33 #endif
34 #endif
35
36 class QGroupBox;
37 class QLabel;
38 class QPushButton;
39 class ReadPipe;
40
41 class LyXServerMonitor : public QDialog
42 {
43         Q_OBJECT
44
45         enum { BUFSIZE = 512 };
46
47 public:
48         LyXServerMonitor();
49         ///
50         ~LyXServerMonitor();
51         ///
52         void readPipe();
53         ///
54         QString inPipeName() { return pipeNameLE->text() + ".in"; }
55         ///
56         QString outPipeName() { return pipeNameLE->text() + ".out"; }
57
58 public Q_SLOTS:
59         void openPipes();
60         void closePipes();
61         void submitCommand();
62         void showInfo(QString const &);
63         void showNotice(QString const &);
64
65 private:
66         void createCmdsGroupBox();
67         void createGridGroupBox();
68         bool event(QEvent *);
69
70         QGroupBox * horizontalGB;
71         QGroupBox * gridGB;
72         QLabel * labels[6];
73         QLineEdit * pipeNameLE;
74         QLineEdit * clientNameLE;
75         QLineEdit * commandLE;
76         QLineEdit * argumentLE;
77         QLabel * infoLB;
78         QLabel * notifyLB;
79         QPushButton * openPipesPB;
80         QPushButton * closePipesPB;
81         QPushButton * submitCommandPB;
82         QPushButton * donePB;
83
84         int pipein;
85         int pipeout;
86         bool thread_exit;
87         bool lyx_listen;
88         char buffer[BUFSIZE];
89         char pipedata[BUFSIZE];
90         ReadPipe * pipethread;
91 };
92
93
94 class ReadPipe : public QThread
95 {
96         Q_OBJECT
97
98 public:
99         ReadPipe(LyXServerMonitor * monitor) : lyxmonitor(monitor) {}
100         ///
101         void run() { lyxmonitor->readPipe(); }
102         ///
103         void emitInfo(QString const & msg) { emit info(msg); }
104         ///
105         void emitNotice(QString const & msg) { emit notice(msg); }
106         ///
107         void emitClosing() { emit closing(); }
108
109 signals:
110         void info(QString const &);
111         void notice(QString const &);
112         void closing();
113
114 private:
115         LyXServerMonitor * lyxmonitor;
116 };
117
118 #endif