/***************************************************************************
- * Copyright (C) 2005-2016 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QFileDialog>
-#include <QIcon>
+#include <QMessageBox>
#include <QMimeData>
#include <QUrl>
-#include <QMessageBox>
-
-#if QT_VERSION < 0x050000
-# include <QDesktopServices>
-#else
-# include <QStandardPaths>
-#endif
+#include <QStandardPaths>
#include "client.h"
+#include "icon.h"
IdentityEditWidget::IdentityEditWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
- ui.addNick->setIcon(QIcon::fromTheme("list-add"));
- ui.deleteNick->setIcon(QIcon::fromTheme("edit-delete"));
- ui.renameNick->setIcon(QIcon::fromTheme("edit-rename"));
- ui.nickUp->setIcon(QIcon::fromTheme("go-up"));
- ui.nickDown->setIcon(QIcon::fromTheme("go-down"));
+ ui.addNick->setIcon(icon::get("list-add"));
+ ui.deleteNick->setIcon(icon::get("edit-delete"));
+ ui.renameNick->setIcon(icon::get("edit-rename"));
+ ui.nickUp->setIcon(icon::get("go-up"));
+ ui.nickDown->setIcon(icon::get("go-down"));
// We need to know whenever the state of input widgets changes...
connect(ui.realName, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged()));
addRow("AP", tr("AM/PM"), true);
addRow("dd", tr("day"), true);
addRow("MM", tr("month"), true);
-#if QT_VERSION > 0x050000
- // Alas, this was only added in Qt 5. We don't know what version the core has, just hope
- // for the best (Qt 4 will soon be dropped).
addRow("t", tr("current timezone"), true);
-#endif
formatTooltip << "</table>";
formatTooltip << "<p>" << tr("Example: Away since %%hh:mm%% on %%dd.MM%%.") << "</p>";
formatTooltip << "<p>" << tr("%%%% without anything inside represents %%. Other format "
QSslKey key;
if (ui.keyTypeLabel->property("sslKey").toByteArray().isEmpty())
- key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"),
-#if QT_VERSION < 0x050000
- QDesktopServices::storageLocation(QDesktopServices::HomeLocation)));
-#else
- QStandardPaths::writableLocation(QStandardPaths::HomeLocation)));
-#endif
+ key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation)));
showKeyState(key);
emit widgetHasChanged();
keyFile.close();
for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
+ // On Qt5.5+, support QSsl::KeyAlgorithm::Rsa (1), QSsl::KeyAlgorithm::Dsa (2), and QSsl::KeyAlgorithm::Ec (3)
+ for (int j = 1; j < 4; j++) {
key = QSslKey(keyRaw, (QSsl::KeyAlgorithm)j, (QSsl::EncodingFormat)i);
if (!key.isNull())
goto returnKey;
}
QMessageBox::information(this, tr("Failed to read key"), tr("Failed to read the key file. It is either incompatible or invalid. Note that the key file must not have a passphrase."));
returnKey:
+ if(!key.isNull() && key.algorithm() == QSsl::KeyAlgorithm::Ec && !Client::isCoreFeatureEnabled(Quassel::Feature::EcdsaCertfpKeys)) {
+ QMessageBox::information(this, tr("Core does not support ECDSA keys"), tr("You loaded an ECDSA key, but the core does not support ECDSA keys. Please contact the core administrator."));
+ key.clear();
+ }
return key;
}
case QSsl::Rsa:
ui.keyTypeLabel->setText(tr("RSA"));
break;
+ case QSsl::Ec:
+ ui.keyTypeLabel->setText(tr("ECDSA"));
+ break;
case QSsl::Dsa:
ui.keyTypeLabel->setText(tr("DSA"));
break;
default:
- ui.keyTypeLabel->setText(tr("No Key loaded"));
+ ui.keyTypeLabel->setText(tr("Invalid key or no key loaded"));
}
ui.clearOrLoadKeyButton->setText(tr("Clear"));
}
QSslCertificate cert;
if (ui.certOrgLabel->property("sslCert").toByteArray().isEmpty())
- cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"),
-#if QT_VERSION < 0x050000
- QDesktopServices::storageLocation(QDesktopServices::HomeLocation)));
-#else
- QStandardPaths::writableLocation(QStandardPaths::HomeLocation)));
-#endif
+ cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation)));
showCertState(cert);
emit widgetHasChanged();
}
ui.clearOrLoadCertButton->setText(tr("Load"));
}
else {
-#if QT_VERSION < 0x050000
- ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization));
- ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName));
-#else
ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization).join(", "));
ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName).join(", "));
-#endif
ui.clearOrLoadCertButton->setText(tr("Clear"));
}
ui.certOrgLabel->setProperty("sslCert", cert.toPem());