mumble/src/Connection.h
Robert 56db3410c5 MAINT: Update copyright notice to 2021 (Part II)
Apparently the first commit (59ae429972)
did not include all files.

Furthermore the used script tended to produce funny results in certain
cases. This has been fixed and as a result thereof a few more changes
were made in this second run.
2021-04-09 15:41:49 +02:00

97 lines
2.4 KiB
C++

// Copyright 2007-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_CONNECTION_H_
#define MUMBLE_CONNECTION_H_
#include <QtCore/QtGlobal>
#ifdef Q_OS_WIN
# include "win.h"
#endif
#include "crypto/CryptState.h"
#include "crypto/CryptStateOCB2.h"
#include <QtCore/QElapsedTimer>
#include <QtCore/QList>
#include <QtCore/QMutex>
#include <QtCore/QObject>
#include <QtNetwork/QSslSocket>
#include <memory>
#ifdef Q_OS_WIN
# include <ws2tcpip.h>
#endif
namespace google {
namespace protobuf {
class Message;
}
} // namespace google
class Connection : public QObject {
private:
Q_OBJECT
Q_DISABLE_COPY(Connection)
protected:
QSslSocket *qtsSocket;
QElapsedTimer qtLastPacket;
unsigned int uiType;
int iPacketLength;
#ifdef Q_OS_WIN
static HANDLE hQoS;
DWORD dwFlow;
#endif
protected slots:
void socketRead();
void socketError(QAbstractSocket::SocketError);
void socketDisconnected();
void socketSslErrors(const QList< QSslError > &errors);
public slots:
void proceedAnyway();
signals:
void encrypted();
void connectionClosed(QAbstractSocket::SocketError, const QString &reason);
void message(unsigned int type, const QByteArray &);
void handleSslErrors(const QList< QSslError > &);
public:
Connection(QObject *parent, QSslSocket *qtsSocket);
~Connection();
static void messageToNetwork(const ::google::protobuf::Message &msg, unsigned int msgType, QByteArray &cache);
void sendMessage(const ::google::protobuf::Message &msg, unsigned int msgType, QByteArray &cache);
void sendMessage(const QByteArray &qbaMsg);
void disconnectSocket(bool force = false);
void forceFlush();
qint64 activityTime() const;
void resetActivityTime();
#ifdef MURMUR
/// qmCrypt locks access to csCrypt.
QMutex qmCrypt;
#endif
std::unique_ptr< CryptState > csCrypt;
QList< QSslCertificate > peerCertificateChain() const;
QSslCipher sessionCipher() const;
QSsl::SslProtocol sessionProtocol() const;
QString sessionProtocolString() const;
QHostAddress peerAddress() const;
quint16 peerPort() const;
/// Look up the local address of this Connection.
QHostAddress localAddress() const;
/// Look up the local port of this Connection.
quint16 localPort() const;
bool bDisconnectedEmitted;
void setToS();
#ifdef Q_OS_WIN
static void setQoS(HANDLE hParentQoS);
#endif
};
#endif