# HG changeset patch # User Andre Heinecke # Date 1395228668 0 # Node ID 64c8c6350e60f7dfa7e2cbe4c89ce758130f9813 # Parent 92f52399708634e55c96a092ca12748f6f8e86c6 Add default constructor to certificatelist. Remove Q_OBJECT use diff -r 92f523997086 -r 64c8c6350e60 common/listutil.h --- a/common/listutil.h Wed Mar 19 11:30:16 2014 +0000 +++ b/common/listutil.h Wed Mar 19 11:31:08 2014 +0000 @@ -23,7 +23,8 @@ InvalidSignature = 4, // Signature was invalid SeekFailed = 5, // Could not seek in the file ReadFailed = 6, // File exists but could not read the file - IncompatibleVersion = 7 // The Format Version does not match + IncompatibleVersion = 7, // The Format Version does not match + NoList = 8 // No list parsed } list_status_t; /* Definitions based on the format */ diff -r 92f523997086 -r 64c8c6350e60 ui/certificatelist.cpp --- a/ui/certificatelist.cpp Wed Mar 19 11:30:16 2014 +0000 +++ b/ui/certificatelist.cpp Wed Mar 19 11:31:08 2014 +0000 @@ -4,7 +4,11 @@ #define PARSER_VERSION "1" -CertificateList::CertificateList(const char *fileName) +CertificateList::CertificateList() : mStatus(NoList) +{ +} + +list_status_t CertificateList::readList(const char *fileName) { char *data = NULL; size_t size = 0; @@ -12,7 +16,7 @@ mStatus = read_and_verify_list(fileName, &data, &size); if (!isValid()) { - return; + return mStatus; } // Take the data into the Qt Universe where memory is plentiful @@ -27,7 +31,7 @@ if (curLine.right(1) != PARSER_VERSION) { qDebug() << "Invalid Format Version"; mStatus = IncompatibleVersion; - return; + return mStatus; } } else if (curLine.startsWith("D:")) { bool ok = false; @@ -38,7 +42,7 @@ if (!ok) { qDebug() << "Invalid Date"; mStatus = InvalidFormat; - return; + return mStatus; } mDate = QDateTime::fromMSecsSinceEpoch(timestamp * 1000); @@ -55,4 +59,10 @@ qDebug () << "Don't know how to handle: " << curLine; } } + return mStatus; } + +CertificateList::CertificateList(const char *fileName) : mStatus(NoList) +{ + readList(fileName); +} diff -r 92f523997086 -r 64c8c6350e60 ui/certificatelist.h --- a/ui/certificatelist.h Wed Mar 19 11:30:16 2014 +0000 +++ b/ui/certificatelist.h Wed Mar 19 11:31:08 2014 +0000 @@ -21,15 +21,22 @@ #include "../common/listutil.h" #include "certificate.h" -class CertificateList : public QObject +class CertificateList { - Q_OBJECT - public: + CertificateList(); CertificateList(const char *fileName); list_status_t getStatus() {return mStatus;} + /** @brief Read a list + * + * @param[in] fileName the filename of the list to read + * + * @return status of the read. Vaild on success. + */ + list_status_t readList(const char *fileName); + /** @brief Returns true if the list is Valid * * A list is valid only if the signature matched and the