Network chat: default-initialize or direct-initialize members
Where possible Task-number: QTBUG-108873 Change-Id: I8125ffd63cd0ad1970575fb1a6b85021c03c38d5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
This commit is contained in:
parent
c437c33f29
commit
3ece5e30b7
@ -8,8 +8,8 @@
|
|||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
|
|
||||||
Client::Client()
|
Client::Client()
|
||||||
|
: peerManager(new PeerManager(this))
|
||||||
{
|
{
|
||||||
peerManager = new PeerManager(this);
|
|
||||||
peerManager->setServerPort(server.serverPort());
|
peerManager->setServerPort(server.serverPort());
|
||||||
peerManager->startBroadcasting();
|
peerManager->startBroadcasting();
|
||||||
|
|
||||||
|
@ -27,12 +27,6 @@ static const int PingInterval = 5 * 1000;
|
|||||||
Connection::Connection(QObject *parent)
|
Connection::Connection(QObject *parent)
|
||||||
: QTcpSocket(parent), writer(this)
|
: QTcpSocket(parent), writer(this)
|
||||||
{
|
{
|
||||||
greetingMessage = tr("undefined");
|
|
||||||
username = tr("unknown");
|
|
||||||
state = WaitingForGreeting;
|
|
||||||
currentDataType = Undefined;
|
|
||||||
transferTimerId = -1;
|
|
||||||
isGreetingMessageSent = false;
|
|
||||||
pingTimer.setInterval(PingInterval);
|
pingTimer.setInterval(PingInterval);
|
||||||
|
|
||||||
connect(this, &QTcpSocket::readyRead, this,
|
connect(this, &QTcpSocket::readyRead, this,
|
||||||
|
@ -59,15 +59,15 @@ private:
|
|||||||
|
|
||||||
QCborStreamReader reader;
|
QCborStreamReader reader;
|
||||||
QCborStreamWriter writer;
|
QCborStreamWriter writer;
|
||||||
QString greetingMessage;
|
QString greetingMessage = tr("undefined");
|
||||||
QString username;
|
QString username = tr("unknown");
|
||||||
QTimer pingTimer;
|
QTimer pingTimer;
|
||||||
QElapsedTimer pongTime;
|
QElapsedTimer pongTime;
|
||||||
QString buffer;
|
QString buffer;
|
||||||
ConnectionState state;
|
ConnectionState state = WaitingForGreeting;
|
||||||
DataType currentDataType;
|
DataType currentDataType = Undefined;
|
||||||
int transferTimerId;
|
int transferTimerId = -1;
|
||||||
bool isGreetingMessageSent;
|
bool isGreetingMessageSent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,10 +12,8 @@ static const qint32 BroadcastInterval = 2000;
|
|||||||
static const unsigned broadcastPort = 45000;
|
static const unsigned broadcastPort = 45000;
|
||||||
|
|
||||||
PeerManager::PeerManager(Client *client)
|
PeerManager::PeerManager(Client *client)
|
||||||
: QObject(client)
|
: QObject(client), client(client)
|
||||||
{
|
{
|
||||||
this->client = client;
|
|
||||||
|
|
||||||
static const char *envVariables[] = {
|
static const char *envVariables[] = {
|
||||||
"USERNAME", "USER", "USERDOMAIN", "HOSTNAME", "DOMAINNAME"
|
"USERNAME", "USER", "USERDOMAIN", "HOSTNAME", "DOMAINNAME"
|
||||||
};
|
};
|
||||||
@ -30,7 +28,6 @@ PeerManager::PeerManager(Client *client)
|
|||||||
username = "unknown";
|
username = "unknown";
|
||||||
|
|
||||||
updateAddresses();
|
updateAddresses();
|
||||||
serverPort = 0;
|
|
||||||
|
|
||||||
broadcastSocket.bind(QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress
|
broadcastSocket.bind(QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress
|
||||||
| QUdpSocket::ReuseAddressHint);
|
| QUdpSocket::ReuseAddressHint);
|
||||||
|
@ -35,13 +35,13 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void updateAddresses();
|
void updateAddresses();
|
||||||
|
|
||||||
Client *client;
|
Client *client = nullptr;
|
||||||
QList<QHostAddress> broadcastAddresses;
|
QList<QHostAddress> broadcastAddresses;
|
||||||
QList<QHostAddress> ipAddresses;
|
QList<QHostAddress> ipAddresses;
|
||||||
QUdpSocket broadcastSocket;
|
QUdpSocket broadcastSocket;
|
||||||
QTimer broadcastTimer;
|
QTimer broadcastTimer;
|
||||||
QString username;
|
QString username;
|
||||||
int serverPort;
|
int serverPort = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user