summaryrefslogtreecommitdiffstats
path: root/src/net/pvsDiscoveredServer.h
blob: d9f0c01afeb41d775f75e0779fb1fef775f83e42 (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
56
57
58
59
60
61
62
63
/*
# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# src/net/pvsDiscoveredServer.h
#    - represents an entry in the list of available servers
#	 - handles some extra things like validating the identity of the remote host
# -----------------------------------------------------------------------------
*/

#ifndef PVSDISCOVEREDSERVER_H_
#define PVSDISCOVEREDSERVER_H_

#include <QtNetwork/QSslSocket>
#include <QtNetwork/QHostAddress>
#include <QtCore/QDateTime>

class PVSDiscoveredServer;

class PVSDiscoveredServer : public QObject {
	Q_OBJECT

private:
	QHostAddress _host;
	int _port;
	QByteArray _fingerprint;
	bool _validated;
	QSslSocket *_socket;
	QDateTime _lastCheck;
	QDateTime _lastUpdate;
	QString _name;

public:
	PVSDiscoveredServer(QObject* parent, QHostAddress host, int port, QByteArray fingerprint, QString name);
	virtual ~PVSDiscoveredServer();
	bool isValid() { return _validated; }
	bool hasFingerprint(QByteArray &fingerprint);
	bool hasHost(QHostAddress &host);
	void update(int port);
	int getAge();
	QString getName();
	QHostAddress getHost() { return _host; }
	QByteArray getFingerprint() { return _fingerprint; }
	int getPort() { return _port; }
	void validateCertificate();

private Q_SLOTS:
    void ssl_Error( const QList<QSslError> & errors );
    void sock_dataArrival();
    void sock_connected();

Q_SIGNALS:
    void validated(PVSDiscoveredServer*);
};

#endif /* PVSDISCOVEREDSERVER_H_ */