Minor fixes

This commit is contained in:
Christian Hohnstaedt 2020-06-15 21:53:31 +02:00
parent 17b621ccef
commit ef24c00c22
10 changed files with 18 additions and 8 deletions

View File

@ -94,6 +94,11 @@ int BioByteArray::size() const
return BIO_get_mem_data(read_write, &p);
}
QString BioByteArray::qstring() const
{
return QString::fromUtf8(byteArray().constData());
}
BioByteArray::operator BIO*()
{
return bio();

View File

@ -9,6 +9,7 @@
#define __BIOBYTEARRAY_H
#include <QByteArray>
#include <QString>
#include <openssl/bio.h>
class BioByteArray
@ -35,6 +36,7 @@ class BioByteArray
BIO *bio();
BIO *ro();
QByteArray byteArray() const;
QString qstring() const;
operator BIO*();
operator QByteArray();
BioByteArray &operator = (const BioByteArray &other);

View File

@ -38,7 +38,7 @@ const QList<arg_option> arguments::opts = {
arg_option("issuers", NULL, no_argument, true, true,
"Print all known issuer certificates that have an associated private key and the CA basic constraints set to 'true'."),
arg_option("keygen", "<type>", required_argument, true, true,
"Generate a new key and import it into the database. Use the 'name' option to set the intenral name of the new key. The <type> parameter has the format: '[RSA|DSA|EC]:[<size>|<curve>]."),
"Generate a new key and import it into the database. Use the 'name' option to set the internal name of the new key. The <type> parameter has the format: '[RSA|DSA|EC]:[<size>|<curve>]."),
arg_option("list-curves", NULL, no_argument, true, false,
"Prints all known Elliptic Curves."),
arg_option("name", "<internal name>", required_argument, false, true,

View File

@ -263,7 +263,7 @@ QString db_base::pem2QString(QModelIndexList indexes) const
pki->pem(bba, format);
openssl_error();
}
return QString::fromUtf8(bba);
return bba.qstring();
}
void db_base::pem2clipboard(QModelIndexList indexes) const

View File

@ -82,6 +82,10 @@ class db_base: public QAbstractItemModel
QModelIndex index(pki_base *pki)const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent) const;
int allItemsCount() const
{
return rootItem->childCount();
}
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,

View File

@ -273,7 +273,7 @@ void pki_base::takeChild(pki_base *pki)
QList<pki_base*> pki_base::getChildItems() const
{
#warning need to collect all children below folders (later)
//#warning need to collect all children below folders (later)
return childItems;
}

View File

@ -8,6 +8,7 @@
#ifndef __PKI_LOOKUP_H
#define __PKI_LOOKUP_H
#include <typeinfo>
#include <QString>
#include <QVariant>
#include <QHash>

View File

@ -68,7 +68,7 @@ QString x509name::oneLine(unsigned long flags) const
{
BioByteArray bba;
X509_NAME_print_ex(bba, xn, 0, flags);
return QString::fromUtf8(bba);
return bba.qstring();
}
QString x509name::getEntryByNid(int nid) const

View File

@ -150,7 +150,7 @@ QString x509v3ext::getValue() const
ret = ASN1_STRING_print(bba, (ASN1_STRING *)getData());
if (ign_openssl_error() || !ret)
return QString();
return QString::fromLocal8Bit(bba).trimmed();
return bba.qstring().trimmed();
}
QString x509v3ext::getHtmlValue() const

View File

@ -325,10 +325,8 @@ ImportMulti::~ImportMulti()
int ImportMulti::entries()
{
return mcont->rowCount(QModelIndex());
return mcont->allItemsCount();
}
#warning better mcont->rootItems().count() via accessor. rowCount()
#warning is only toplevel
void ImportMulti::importError(QStringList failed)
{