summaryrefslogtreecommitdiffstats
path: root/src/client/vnc/vncserver.h
blob: 1e71e2ef5fcd4b2b4f091f9b9bce0c76b0af6a4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * vncserver.h
 *
 *  Created on: 24.01.2013
 *      Author: sr
 */

#ifndef VNCSERVER_H_
#define VNCSERVER_H_

#include <QtCore>
#include <QSharedPointer>

class VncServer;

class VncServer : public QObject
{
	Q_OBJECT

private:
	QProcess *_process;
	QString _ropass;
	QString _rwpass;
	int _port;
	int _timerId;

	VncServer();
	~VncServer() override;
	static QSharedPointer<QFile> createPwFile(const QDir& dir);

	static VncServer *me;

public:
	static VncServer *instance();

	inline bool isVncServerRunning() const { return _port > 0; }
	void start();
	void stop();

protected:
	void timerEvent(QTimerEvent *event) override;

signals:
	// Emited when started succesfully, or if startup failed. port will be <= 0 if it failed.
	void started(int port, const QString& ropass, const QString& rwpass);

private slots:
	void onStdOut();
	void onStdErr();
	void onFinished(int exitCode, QProcess::ExitStatus exitStatus);
	void onError(QProcess::ProcessError error);

};

#endif /* VNCSERVER_H_ */