From 6fa73e073f05e5f826205375a8a2935e136891a7 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 28 Jan 2015 17:38:38 +0100 Subject: [PATCH] Certificate Wizard: Remove dead code, cleanup style --- src/gui/addcertificatedialog.cpp | 8 ++--- src/gui/addcertificatedialog.h | 2 +- src/gui/wizard/owncloudsetuppage.cpp | 51 ++++++++-------------------- 3 files changed, 20 insertions(+), 41 deletions(-) diff --git a/src/gui/addcertificatedialog.cpp b/src/gui/addcertificatedialog.cpp index 030658af0..6771a7f5b 100644 --- a/src/gui/addcertificatedialog.cpp +++ b/src/gui/addcertificatedialog.cpp @@ -39,11 +39,11 @@ void AddCertificateDialog::showErrorMessage(const QString message) ui->labelErrorCertif->setText(message); } -void AddCertificateDialog::Reinit() +void AddCertificateDialog::reinit() { - ui->labelErrorCertif->setText(""); - ui->lineEditCertificatePath->setText(""); - ui->lineEditPWDCertificate->setText(""); + ui->labelErrorCertif->clear(); + ui->lineEditCertificatePath->clear(); + ui->lineEditPWDCertificate->clear(); } } diff --git a/src/gui/addcertificatedialog.h b/src/gui/addcertificatedialog.h index 9bcd57a91..3ba7a651c 100644 --- a/src/gui/addcertificatedialog.h +++ b/src/gui/addcertificatedialog.h @@ -20,7 +20,7 @@ public: QString getCertificatePath(); QString getCertificatePasswd(); void showErrorMessage(const QString message); - void Reinit(); + void reinit(); private slots: void on_pushButtonBrowseCertificate_clicked(); diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp index 25571032d..63a2befba 100644 --- a/src/gui/wizard/owncloudsetuppage.cpp +++ b/src/gui/wizard/owncloudsetuppage.cpp @@ -288,6 +288,15 @@ void OwncloudSetupPage::slotAskSSLClientCertificate() connect(addCertDial, SIGNAL(accepted()),this,SLOT(slotCertificateAccepted())); } +QString subjectInfoHelper(const QSslCertificate& cert, const QByteArray &qa) +{ +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + return cert.subjectInfo(qa); +#else + return cert.subjectInfo(qa).join(QLatin1Char('/')); +#endif +} + //called during the validation of the client certificate. void OwncloudSetupPage::slotCertificateAccepted() { @@ -301,44 +310,14 @@ void OwncloudSetupPage::slotCertificateAccepted() QList sslCertificateList = QSslCertificate::fromData(ba, QSsl::Pem); sslCertificate = sslCertificateList.takeAt(0); - this->_ocWizard->ownCloudCertificate = ba; - this->_ocWizard->ownCloudPrivateKey = certif.PrivateKey.c_str(); - this->_ocWizard->ownCloudCertificatePath = addCertDial->getCertificatePath(); - this->_ocWizard->ownCloudCertificatePasswd = addCertDial->getCertificatePasswd(); + _ocWizard->ownCloudCertificate = ba; + _ocWizard->ownCloudPrivateKey = certif.PrivateKey.c_str(); + _ocWizard->ownCloudCertificatePath = addCertDial->getCertificatePath(); + _ocWizard->ownCloudCertificatePasswd = addCertDial->getCertificatePasswd(); - //FIXME qknight: hacky code ahead - AccountPtr acc = this->_ocWizard->account(); + AccountPtr acc = _ocWizard->account(); acc->setCertificate(_ocWizard->ownCloudCertificate, _ocWizard->ownCloudPrivateKey); - - QList qba = sslCertificate.subjectInfoAttributes(); - QString _DN = ""; - QString _C,_ST, _L, _O, _OU, _CN, _emailAddress; - foreach(QByteArray qa, qba) - { - if(strcmp(qa.data(),"C")==0){ - _C="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - else if(strcmp(qa.data(),"ST")==0){ - _ST="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - else if(strcmp(qa.data(),"L")==0){ - _L="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - else if(strcmp(qa.data(),"O")==0){ - _O="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - else if(strcmp(qa.data(),"OU")==0){ - _OU="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - else if(strcmp(qa.data(),"CN")==0){ - _CN="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - else if(strcmp(qa.data(),"emailAddress")==0){ - _emailAddress="/"+QString(qa)+"="+sslCertificate.subjectInfo(qa).join('/'); - } - } - _DN += _C+_ST+_L+_O+_OU+_CN+_emailAddress; - addCertDial->Reinit(); + addCertDial->reinit(); validatePage(); } else { QString message;