Fix compilation warnings in smtp.h (cgreco)

This commit is contained in:
Christophe Dumez
2011-06-05 16:08:30 +00:00
parent 53900c386b
commit 02fbd6a135
87 changed files with 11700 additions and 9106 deletions

View File

@@ -53,6 +53,11 @@
#include "iconprovider.h"
#include "dnsupdater.h"
#ifndef QT_NO_OPENSSL
#include <QSslKey>
#include <QSslCertificate>
#endif
using namespace libtorrent;
// Constructor
@@ -111,6 +116,9 @@ options_imp::options_imp(QWidget *parent):
#if !defined(Q_WS_X11)
label_trayIconStyle->setVisible(false);
comboTrayIcon->setVisible(false);
#endif
#if defined(QT_NO_OPENSSL)
checkWebUiHttps->setVisible(false);
#endif
// Connect signals / slots
// Proxy tab
@@ -206,6 +214,9 @@ options_imp::options_imp(QWidget *parent):
connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinWebUiPort, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton()));
connect(checkWebUIUPnP, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
connect(checkWebUiHttps, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
connect(btnWebUiKey, SIGNAL(clicked()), SLOT(enableApplyButton()));
connect(btnWebUiCrt, SIGNAL(clicked()), SLOT(enableApplyButton()));
connect(textWebUiUsername, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textWebUiPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkBypassLocalAuth, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@@ -443,6 +454,12 @@ void options_imp::saveOptions(){
{
pref.setWebUiPort(webUiPort());
pref.setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
pref.setWebUiHttpsEnabled(checkWebUiHttps->isChecked());
if(checkWebUiHttps->isChecked())
{
pref.setWebUiHttpsCertificate(m_sslCert);
pref.setWebUiHttpsKey(m_sslKey);
}
pref.setWebUiUsername(webUiUsername());
// FIXME: Check that the password is valid (not empty at least)
pref.setWebUiPassword(webUiPassword());
@@ -693,6 +710,9 @@ void options_imp::loadOptions(){
checkWebUi->setChecked(pref.isWebUiEnabled());
spinWebUiPort->setValue(pref.getWebUiPort());
checkWebUIUPnP->setChecked(pref.useUPnPForWebUIPort());
checkWebUiHttps->setChecked(pref.isWebUiHttpsEnabled());
setSslCertificate(pref.getWebUiHttpsCertificate(), false);
setSslKey(pref.getWebUiHttpsKey(), false);
textWebUiUsername->setText(pref.getWebUiUsername());
textWebUiPassword->setText(pref.getWebUiPassword());
checkBypassLocalAuth->setChecked(!pref.isWebUiLocalAuthEnabled());
@@ -1128,6 +1148,28 @@ void options_imp::showConnectionTab()
tabSelection->setCurrentRow(2);
}
void options_imp::on_btnWebUiCrt_clicked() {
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Certificate (*.crt *.pem)"));
if(filename.isNull())
return;
QFile file(filename);
if (file.open(QIODevice::ReadOnly)) {
setSslCertificate(file.readAll());
file.close();
}
}
void options_imp::on_btnWebUiKey_clicked() {
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Key (*.key *.pem)"));
if(filename.isNull())
return;
QFile file(filename);
if (file.open(QIODevice::ReadOnly)) {
setSslKey(file.readAll());
file.close();
}
}
void options_imp::on_registerDNSBtn_clicked() {
QDesktopServices::openUrl(DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
}
@@ -1207,3 +1249,33 @@ QString options_imp::languageToLocalizedString(QLocale::Language language, const
}
}
}
void options_imp::setSslKey(const QByteArray &key, bool interactive)
{
#ifndef QT_NO_OPENSSL
if (!key.isEmpty() && !QSslKey(key, QSsl::Rsa).isNull()) {
lblSslKeyStatus->setPixmap(QPixmap(":/Icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
m_sslKey = key;
} else {
lblSslKeyStatus->setPixmap(QPixmap(":/Icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
m_sslKey.clear();
if (interactive)
QMessageBox::warning(this, tr("Invalid key"), tr("This is not a valid SSL key."));
}
#endif
}
void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
{
#ifndef QT_NO_OPENSSL
if (!cert.isEmpty() && !QSslCertificate(cert).isNull()) {
lblSslCertStatus->setPixmap(QPixmap(":/Icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
m_sslCert = cert;
} else {
lblSslCertStatus->setPixmap(QPixmap(":/Icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
m_sslCert.clear();
if (interactive)
QMessageBox::warning(this, tr("Invalid certificate"), tr("This is not a valid SSL certificate."));
}
#endif
}