-
Notifications
You must be signed in to change notification settings - Fork 2
/
drserverinfodialog.cpp
113 lines (78 loc) · 3.58 KB
/
drserverinfodialog.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
Deriv is a cross-platform client for th Wired 2.0 protocol
Copyright (C) 2014 Rafael Warnault, [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDebug>
#include "drserverinfodialog.h"
#include "ui_drserverinfodialog.h"
#include "dr.h"
#pragma mark -
DRServerInfoDialog::DRServerInfoDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DRServerInfoDialog)
{
ui->setupUi(this);
this->connection = NULL;
}
DRServerInfoDialog::~DRServerInfoDialog()
{
delete ui;
}
#pragma mark -
void DRServerInfoDialog::close() {
DRServerInfoDialog::close();
this->ui->bannerButton->setIcon(QIcon());
this->ui->descriptionLabel->setText("");
this->ui->uptimeLabel->setText("");
}
#pragma mark -
void DRServerInfoDialog::setConnection(DRServerConnection *connection) {
if(connection->connected && connection->server != NULL) {
if(!connection->serverName.isNull())
this->setWindowTitle(connection->serverName);
if(!connection->server->banner.isNull())
this->ui->bannerButton->setIcon(connection->server->banner);
if(!connection->server->description.isNull())
this->ui->descriptionLabel->setText(connection->server->description);
qDebug() << connection->server->startTime.toString();
if(!connection->server->startTime.isNull())
this->ui->uptimeLabel->setText(DR::humanReadableElapsedTimeSinceDate(connection->server->startTime));
if(connection->url != NULL)
this->ui->urlLabel->setText(connection->URL());
if(connection->server->filesCount > 0)
this->ui->filesLabel->setText(QString::number(connection->server->filesCount));
else
this->ui->filesLabel->setText("No files");
this->ui->sizeLabel->setText(DR::humanReadableStringForSizeInBytes(connection->server->filesSize));
this->ui->versionLabel->setText(connection->server->versionString());
this->ui->protocolLabel->setText(QString("%1 %2").arg(
WSTOQS(wi_p7_socket_remote_protocol_name(connection->p7_socket)),
WSTOQS(wi_p7_socket_remote_protocol_version(connection->p7_socket))
));
if(WI_P7_ENCRYPTION_ENABLED(wi_p7_socket_options(connection->p7_socket))) {
this->ui->cipherLabel->setText(QString("%1 %2 bits").arg(
WSTOQS(wi_cipher_name(wi_p7_socket_cipher(connection->p7_socket))),
QString::number(wi_cipher_bits(wi_p7_socket_cipher(connection->p7_socket)))
));
} else {
this->ui->cipherLabel->setText("None");
}
if(WI_P7_COMPRESSION_ENABLED(wi_p7_socket_options(connection->p7_socket))) {
QString compressionString;
compressionString.sprintf("Yes, compression ratio %0.2f", wi_p7_socket_compression_ratio(connection->p7_socket));
this->ui->compressionLabel->setText(compressionString);
} else {
this->ui->compressionLabel->setText("No");
}
}
}