comparison ui/certificatelist.cpp @ 70:64c8c6350e60

Add default constructor to certificatelist. Remove Q_OBJECT use
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 19 Mar 2014 11:31:08 +0000
parents 37fc66967517
children 1dd8e91972a8
comparison
equal deleted inserted replaced
69:92f523997086 70:64c8c6350e60
2 2
3 #include <QDebug> 3 #include <QDebug>
4 4
5 #define PARSER_VERSION "1" 5 #define PARSER_VERSION "1"
6 6
7 CertificateList::CertificateList(const char *fileName) 7 CertificateList::CertificateList() : mStatus(NoList)
8 {
9 }
10
11 list_status_t CertificateList::readList(const char *fileName)
8 { 12 {
9 char *data = NULL; 13 char *data = NULL;
10 size_t size = 0; 14 size_t size = 0;
11 15
12 mStatus = read_and_verify_list(fileName, &data, &size); 16 mStatus = read_and_verify_list(fileName, &data, &size);
13 17
14 if (!isValid()) { 18 if (!isValid()) {
15 return; 19 return mStatus;
16 } 20 }
17 21
18 // Take the data into the Qt Universe where memory is plentiful 22 // Take the data into the Qt Universe where memory is plentiful
19 // and CPU's are fast :) 23 // and CPU's are fast :)
20 QStringList lines = QString::fromLatin1(data, size).split("\n"); 24 QStringList lines = QString::fromLatin1(data, size).split("\n");
25 QString curLine = lines[i].trimmed(); 29 QString curLine = lines[i].trimmed();
26 if (curLine.startsWith("F:")) { 30 if (curLine.startsWith("F:")) {
27 if (curLine.right(1) != PARSER_VERSION) { 31 if (curLine.right(1) != PARSER_VERSION) {
28 qDebug() << "Invalid Format Version"; 32 qDebug() << "Invalid Format Version";
29 mStatus = IncompatibleVersion; 33 mStatus = IncompatibleVersion;
30 return; 34 return mStatus;
31 } 35 }
32 } else if (curLine.startsWith("D:")) { 36 } else if (curLine.startsWith("D:")) {
33 bool ok = false; 37 bool ok = false;
34 qlonglong timestamp = 0; 38 qlonglong timestamp = 0;
35 39
36 curLine.remove(0, 2); 40 curLine.remove(0, 2);
37 timestamp = curLine.toLongLong(&ok); 41 timestamp = curLine.toLongLong(&ok);
38 if (!ok) { 42 if (!ok) {
39 qDebug() << "Invalid Date"; 43 qDebug() << "Invalid Date";
40 mStatus = InvalidFormat; 44 mStatus = InvalidFormat;
41 return; 45 return mStatus;
42 } 46 }
43 47
44 mDate = QDateTime::fromMSecsSinceEpoch(timestamp * 1000); 48 mDate = QDateTime::fromMSecsSinceEpoch(timestamp * 1000);
45 } else if (curLine.startsWith("I:")) { 49 } else if (curLine.startsWith("I:")) {
46 mCertificatesInstall << Certificate( 50 mCertificatesInstall << Certificate(
53 continue; 57 continue;
54 } else if (!curLine.isEmpty()){ 58 } else if (!curLine.isEmpty()){
55 qDebug () << "Don't know how to handle: " << curLine; 59 qDebug () << "Don't know how to handle: " << curLine;
56 } 60 }
57 } 61 }
62 return mStatus;
58 } 63 }
64
65 CertificateList::CertificateList(const char *fileName) : mStatus(NoList)
66 {
67 readList(fileName);
68 }

http://wald.intevation.org/projects/trustbridge/