Mercurial > trustbridge
view ui/certificatelist.cpp @ 754:27043d74dc90
(Issue25) Align header contents in their own column.
We now also stretch column 3 so that the contents are aligned
with the descriptive labels without a space in between.
Sadly this causes the quit button to be resized to it's minimum
instead of sharing the space with the installation button as the
installation button is so large that it squeezes the push button.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 07 Jul 2014 12:38:33 +0200 |
parents | cf25bb040186 |
children |
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=2) * and comes with ABSOLUTELY NO WARRANTY! * See LICENSE.txt for details. */ #include "certificatelist.h" #include <QDebug> #define PARSER_VERSION "1" CertificateList::CertificateList() : mStatus(NoList) { } list_status_t CertificateList::readList(const char *fileName) { char *data = NULL; size_t size = 0; mCertificates.clear(); mDate = QDateTime(); mData = QString(); mFileName = QString::fromUtf8(fileName); mStatus = read_and_verify_list(fileName, &data, &size); if (!isValid()) { return mStatus; } // Take the data into the Qt Universe where memory is plentiful // and CPU's are fast :) mData = QString::fromLatin1(data, size); free(data); data = NULL; QStringList lines = mData.split("\n"); for (int i = 0; i < lines.size(); ++i) { QString curLine = lines[i].trimmed(); if (curLine.startsWith("F:")) { if (curLine.right(1) != PARSER_VERSION) { qDebug() << "Invalid Format Version"; mStatus = IncompatibleVersion; return mStatus; } } else if (curLine.startsWith("D:")) { curLine.remove(0, 2); mDate = QDateTime::fromString(curLine, Qt::ISODate); if (!mDate.isValid()) { qDebug() << "Invalid Date: " << curLine; mStatus = InvalidFormat; return mStatus; } } else if (curLine.startsWith("I:")) { mCertificates << Certificate(curLine); } else if (curLine.startsWith("R:")) { mCertificates << Certificate(curLine); } else if (curLine.startsWith("S:")) { // Signature is verified in read_and_verify_list continue; } else if (!curLine.isEmpty()){ qDebug () << "Don't know how to handle: " << curLine; } } return mStatus; } CertificateList::CertificateList(const char *fileName) : mStatus(NoList) { readList(fileName); } const QList<Certificate>& CertificateList::getCertificates() const { return mCertificates; }