Mercurial > trustbridge
comparison ui/certificatelist.cpp @ 249:6a7eb102716d
Remove code duplication by unifying the certificatelist.
You should now check for isInstallCert to determine wether this
certificate should be installed or removed.
Leaving the getInstallCertificates and getRemoveCertificates
in place for compatibilty would have been easier to keep the
tests stable.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 31 Mar 2014 08:06:17 +0000 |
parents | 60c5df8e7980 |
children | 17e1c8f37d72 |
comparison
equal
deleted
inserted
replaced
248:9f0865dc8b14 | 249:6a7eb102716d |
---|---|
11 list_status_t CertificateList::readList(const char *fileName) | 11 list_status_t CertificateList::readList(const char *fileName) |
12 { | 12 { |
13 char *data = NULL; | 13 char *data = NULL; |
14 size_t size = 0; | 14 size_t size = 0; |
15 | 15 |
16 mCertificatesRemove.clear(); | 16 mCertificates.clear(); |
17 mCertificatesInstall.clear(); | |
18 mDate = QDateTime(); | 17 mDate = QDateTime(); |
19 mData = QString(); | 18 mData = QString(); |
19 mFileName = QString::fromUtf8(fileName); | |
20 | 20 |
21 mStatus = read_and_verify_list(fileName, &data, &size); | 21 mStatus = read_and_verify_list(fileName, &data, &size); |
22 | 22 |
23 if (!isValid()) { | 23 if (!isValid()) { |
24 return mStatus; | 24 return mStatus; |
51 return mStatus; | 51 return mStatus; |
52 } | 52 } |
53 | 53 |
54 mDate = QDateTime::fromMSecsSinceEpoch(timestamp * 1000); | 54 mDate = QDateTime::fromMSecsSinceEpoch(timestamp * 1000); |
55 } else if (curLine.startsWith("I:")) { | 55 } else if (curLine.startsWith("I:")) { |
56 mCertificatesInstall << Certificate(curLine); | 56 mCertificates << Certificate(curLine); |
57 } else if (curLine.startsWith("R:")) { | 57 } else if (curLine.startsWith("R:")) { |
58 mCertificatesRemove << Certificate(curLine); | 58 mCertificates << Certificate(curLine); |
59 } else if (curLine.startsWith("S:")) { | 59 } else if (curLine.startsWith("S:")) { |
60 // Signature is verified in read_and_verify_list | 60 // Signature is verified in read_and_verify_list |
61 continue; | 61 continue; |
62 } else if (!curLine.isEmpty()){ | 62 } else if (!curLine.isEmpty()){ |
63 qDebug () << "Don't know how to handle: " << curLine; | 63 qDebug () << "Don't know how to handle: " << curLine; |
69 CertificateList::CertificateList(const char *fileName) : mStatus(NoList) | 69 CertificateList::CertificateList(const char *fileName) : mStatus(NoList) |
70 { | 70 { |
71 readList(fileName); | 71 readList(fileName); |
72 } | 72 } |
73 | 73 |
74 const QList<Certificate>& CertificateList::getInstallCertificates() const { | 74 const QList<Certificate>& CertificateList::getCertificates() const |
75 return mCertificatesInstall; | 75 { |
76 return mCertificates; | |
76 } | 77 } |
77 | |
78 const QList<Certificate>& CertificateList::getRemoveCertificates() const { | |
79 return mCertificatesRemove; | |
80 } |