Mercurial > trustbridge
changeset 1101:2b3526ef2d69
(issue111) Keep manually changed certificates in the manually changed list.
This invents the new property "active certificate"
an inactive certificate is a certificate that is displayed but
has no impact on the store.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 15 Sep 2014 13:55:47 +0200 (2014-09-15) |
parents | 77afafd23a1b |
children | 3d03aaeca6d4 |
files | ui/certificate.cpp ui/certificate.h ui/certificateitemwidget.cpp ui/certificateitemwidget.h ui/certificatelistwidget.cpp ui/certificatelistwidget.h |
diffstat | 6 files changed, 64 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/certificate.cpp Mon Sep 15 12:50:26 2014 +0200 +++ b/ui/certificate.cpp Mon Sep 15 13:55:47 2014 +0200 @@ -88,7 +88,8 @@ Certificate::Certificate(const QByteArray& derData) : mValid(false), - mEditable(false) + mEditable(false), + mActive(true) { if (derData.isEmpty()) { return;
--- a/ui/certificate.h Mon Sep 15 12:50:26 2014 +0200 +++ b/ui/certificate.h Mon Sep 15 13:55:47 2014 +0200 @@ -136,6 +136,21 @@ friend inline bool operator==(const Certificate& lhs, const Certificate& rhs) { return lhs.base64Line() == rhs.base64Line(); } + + /** @brief Wether or not the certificate is Active. + * + * This property is mainly for the manually changed certificate list. + * A certificate is active if it should be counted as change in a list + * and if it should be written to a certificate store. + * + * An inctive certificate will only be shown in the manual changes list + * but not counted as a changed or changed in the certificate list. */ + bool isActive() const { return mActive; } + + /** @brief set the active state of a certificate. + * + * See isActive() for details. */ + void setActive(bool active) { mActive = active; } private: /** @brief Helper function to parse the details of a certificate **/ void parseDetails(const QByteArray& cert); @@ -143,6 +158,7 @@ bool mValid; /* bool mInstCert; */ bool mEditable; + bool mActive; QString mSubjectOU, mSubjectCN,
--- a/ui/certificateitemwidget.cpp Mon Sep 15 12:50:26 2014 +0200 +++ b/ui/certificateitemwidget.cpp Mon Sep 15 13:55:47 2014 +0200 @@ -139,9 +139,9 @@ this, SLOT(currentStateChanged(int))); } -Certificate CertificateItemWidget::certificate() +Certificate* CertificateItemWidget::certificate() { - return mCertificate; + return &mCertificate; } void CertificateItemWidget::currentStateChanged(int)
--- a/ui/certificateitemwidget.h Mon Sep 15 12:50:26 2014 +0200 +++ b/ui/certificateitemwidget.h Mon Sep 15 13:55:47 2014 +0200 @@ -43,7 +43,7 @@ bool state(); void setState(bool state); - Certificate certificate(); + Certificate *certificate(); private: void setupGUI();
--- a/ui/certificatelistwidget.cpp Mon Sep 15 12:50:26 2014 +0200 +++ b/ui/certificatelistwidget.cpp Mon Sep 15 13:55:47 2014 +0200 @@ -40,10 +40,43 @@ emit certListChanged(-1); } +int CertificateListWidget::activeCertificates() +{ + int ret = 0; + for (int i = 0; i < mCertificateWidgets.size(); i++) { + if (mCertificateWidgets[i]->certificate()->isActive()) { + ret++; + } + } + return ret; +} + +void CertificateListWidget::activateCertificate(const Certificate &cert) +{ + for (int i = 0; i < mCertificateWidgets.size(); i++) { + if (*(mCertificateWidgets[i]->certificate()) == cert) { + mCertificateWidgets[i]->certificate()->setActive(true); + break; + } + } + emit certListChanged(-1); +} + +void CertificateListWidget::deactivateCertificate(const Certificate &cert) +{ + for (int i = 0; i < mCertificateWidgets.size(); i++) { + if (*(mCertificateWidgets[i]->certificate()) == cert) { + mCertificateWidgets[i]->certificate()->setActive(false); + break; + } + } + emit certListChanged(-1); +} + void CertificateListWidget::removeCertificate(const Certificate &cert) { for (int i = 0; i < mCertificateWidgets.size(); i++) { - if (mCertificateWidgets[i]->certificate() == cert) { + if (*(mCertificateWidgets[i]->certificate()) == cert) { mLayout.removeWidget(mCertificateWidgets[i]); mCertificateWidgets[i]->deleteLater(); mCertificateWidgets.removeAt(i); @@ -66,7 +99,7 @@ { QStringList list; foreach (CertificateItemWidget * item, mCertificateWidgets) { - list << item->certificate().base64Line(); + list << item->certificate()->base64Line(); } return list; } @@ -75,7 +108,7 @@ QStringList list; foreach (CertificateItemWidget * item, mCertificateWidgets) { if (item->state()) { - list << item->certificate().base64Line(); + list << item->certificate()->base64Line(); } } return list; @@ -85,7 +118,7 @@ QStringList list; foreach (CertificateItemWidget * item, mCertificateWidgets) { if (!item->state()) { - list << item->certificate().base64Line(); + list << item->certificate()->base64Line(); } } return list; @@ -95,7 +128,7 @@ { QList<Certificate> list; foreach (CertificateItemWidget * item, mCertificateWidgets) { - list << item->certificate(); + list << *(item->certificate()); } return list; } @@ -103,7 +136,7 @@ void CertificateListWidget::setCertState(bool state, const Certificate &cert) { foreach (CertificateItemWidget * item, mCertificateWidgets) { - if (item->certificate() == cert && + if (*(item->certificate()) == cert && item->state() != state) { item->setState(state); } @@ -131,7 +164,7 @@ bool CertificateListWidget::contains(const Certificate &cert) { foreach (CertificateItemWidget * item, mCertificateWidgets) { - if (item->certificate() == cert) { + if (*(item->certificate()) == cert) { return true; } }
--- a/ui/certificatelistwidget.h Mon Sep 15 12:50:26 2014 +0200 +++ b/ui/certificatelistwidget.h Mon Sep 15 13:55:47 2014 +0200 @@ -35,6 +35,8 @@ const QString& installLabel = QString(), const QString& removeLabel = QString()); void removeCertificate(const Certificate &cert); + void activateCertificate(const Certificate &cert); + void deactivateCertificate(const Certificate &cert); void setCertState(bool state, const Certificate &cert); void clear(); QStringList certificates(); @@ -42,6 +44,7 @@ QStringList unselectedCertificates(); QList<Certificate> certificateList(); int selectedCertCount(); + int activeCertificates(); bool contains(const Certificate &cert); private: