Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
vncserver.h
Go to the documentation of this file.
1 /*
2  * vncserver.h
3  *
4  * Created on: 24.01.2013
5  * Author: sr
6  */
7 
8 #ifndef VNCSERVER_H_
9 #define VNCSERVER_H_
10 
11 #include <QtCore>
12 #include <QSharedPointer>
13 
14 class VncServer;
15 
16 class VncServer : public QObject
17 {
18  Q_OBJECT
19 
20 private:
21  QProcess *_process;
22  QString _ropass;
23  QString _rwpass;
24  int _port;
25  int _timerId;
26 
27  VncServer();
28  ~VncServer() override;
29  static QSharedPointer<QFile> createPwFile(const QDir& dir);
30 
31  static VncServer *me;
32 
33 public:
34  static VncServer *instance();
35 
36  inline bool isVncServerRunning() const { return _port > 0; }
37  void start();
38  void stop();
39 
40 protected:
41  void timerEvent(QTimerEvent *event) override;
42 
43 signals:
44  // Emited when started succesfully, or if startup failed. port will be <= 0 if it failed.
45  void started(int port, const QString& ropass, const QString& rwpass);
46 
47 private slots:
48  void onStdOut();
49  void onStdErr();
50  void onFinished(int exitCode, QProcess::ExitStatus exitStatus);
51  void onError(QProcess::ProcessError error);
52 
53 };
54 
55 #endif /* VNCSERVER_H_ */
void stop()
VncServer::stop.
Definition: vncserver.cpp:139
void started(int port, const QString &ropass, const QString &rwpass)
QProcess * _process
Definition: vncserver.h:21
void onStdOut()
VncServer::onStdOut.
Definition: vncserver.cpp:190
int _port
Definition: vncserver.h:24
void onFinished(int exitCode, QProcess::ExitStatus exitStatus)
VncServer::onFinished.
Definition: vncserver.cpp:239
static VncServer * me
Definition: vncserver.h:31
~VncServer() override
VncServer::~VncServer.
QString _rwpass
Definition: vncserver.h:23
void start()
VncServer::start.
Definition: vncserver.cpp:77
static QSharedPointer< QFile > createPwFile(const QDir &dir)
Definition: vncserver.cpp:62
int _timerId
Definition: vncserver.h:25
void timerEvent(QTimerEvent *event) override
Timer event, currently only used to assume VNC server setup failed after 3 seconds...
Definition: vncserver.cpp:174
void onStdErr()
VncServer::onStdErr.
Definition: vncserver.cpp:216
void onError(QProcess::ProcessError error)
VncServer::onError.
Definition: vncserver.cpp:229
VncServer()
VncServer::VncServer.
Definition: vncserver.cpp:55
QString _ropass
Definition: vncserver.h:22
bool isVncServerRunning() const
Definition: vncserver.h:36
static VncServer * instance()
VncServer::instance.
Definition: vncserver.cpp:25