changeset 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 92f523997086
children f22a99f7cb69
files common/listutil.h ui/certificatelist.cpp ui/certificatelist.h
diffstat 3 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 */
--- 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);
+}
--- 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

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