]> git.lyx.org Git - lyx.git/blob - development/lyxserver/server_monitor.h
Customization: correct some color names.
[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
17 #include <QDialog>
18 #include <QFile>
19 #include <QLineEdit>
20
21 #ifdef _WIN32
22 #include <windows.h>
23 #ifdef _MSC_VER
24 #include <io.h>
25 #define open _open
26 #define close _close
27 #define read _read
28 #define write _write
29 #define snprintf _snprintf
30 #define O_RDONLY _O_RDONLY
31 #define O_WRONLY _O_WRONLY
32 #endif
33 #endif
34
35 class QGroupBox;
36 class QLabel;
37 class QPushButton;
38 class ReadPipe;
39
40 class LyXServerMonitor : public QDialog
41 {
42         Q_OBJECT
43
44         enum { BUFSIZE = 512 };
45
46 public:
47         LyXServerMonitor();
48         ///
49         ~LyXServerMonitor();
50         ///
51         void readPipe();
52         ///
53         QString inPipeName() { return pipeNameLE->text() + ".in"; }
54         ///
55         QString outPipeName() { return pipeNameLE->text() + ".out"; }
56
57 public Q_SLOTS:
58         void openPipes();
59         void closePipes();
60         void submitCommand();
61         void showInfo(QString const &);
62         void showNotice(QString const &);
63
64 private:
65         void createCmdsGroupBox();
66         void createGridGroupBox();
67         bool event(QEvent *);
68
69         QGroupBox * horizontalGB;
70         QGroupBox * gridGB;
71         QLabel * labels[6];
72         QLineEdit * pipeNameLE;
73         QLineEdit * clientNameLE;
74         QLineEdit * commandLE;
75         QLineEdit * argumentLE;
76         QLabel * infoLB;
77         QLabel * notifyLB;
78         QPushButton * openPipesPB;
79         QPushButton * closePipesPB;
80         QPushButton * submitCommandPB;
81         QPushButton * donePB;
82
83         int pipein;
84         int pipeout;
85         bool thread_exit;
86         bool lyx_listen;
87         char buffer[BUFSIZE];
88         char pipedata[BUFSIZE];
89         ReadPipe * pipethread;
90 };
91
92
93 class ReadPipe : public QThread
94 {
95         Q_OBJECT
96
97 public:
98         ReadPipe(LyXServerMonitor * monitor) : lyxmonitor(monitor) {}
99         ///
100         void run() { lyxmonitor->readPipe(); }
101         ///
102         void emitInfo(QString const & msg) { emit info(msg); }
103         ///
104         void emitNotice(QString const & msg) { emit notice(msg); }
105         ///
106         void emitClosing() { emit closing(); }
107
108 signals:
109         void info(QString const &);
110         void notice(QString const &);
111         void closing();
112
113 private:
114         LyXServerMonitor * lyxmonitor;
115 };
116
117 #endif