diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-06-17 21:15:12 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-06-17 21:15:12 +0000 |
| commit | 8df9466ada46e4b07990b9cb7e8b1cd61b96844a (patch) | |
| tree | 2cb652e5839bed672133ffa90e7ad477f55cfb6b /pica-client/dialogs/viewcertdialog.cpp | |
| download | pica-pica-8df9466ada46e4b07990b9cb7e8b1cd61b96844a.tar.gz pica-pica-8df9466ada46e4b07990b9cb7e8b1cd61b96844a.zip | |
todo list update
git-svn-id: svn://localhost/project_picapica/trunk@128 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'pica-client/dialogs/viewcertdialog.cpp')
| -rw-r--r-- | pica-client/dialogs/viewcertdialog.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/pica-client/dialogs/viewcertdialog.cpp b/pica-client/dialogs/viewcertdialog.cpp new file mode 100644 index 0000000..8b096c2 --- /dev/null +++ b/pica-client/dialogs/viewcertdialog.cpp @@ -0,0 +1,68 @@ +#include "viewcertdialog.h" +#include <QVBoxLayout> +#include <QProcess> + +#include <QMessageBox> + +#include <unistd.h> +#include <stdio.h> +#include <sys/wait.h> +#include <QFile> + +ViewCertDialog::ViewCertDialog(QWidget *parent) : + QDialog(parent) +{ + QVBoxLayout *layout; + + layout = new QVBoxLayout; + cert_text = new QTextEdit(this); + btOK = new QPushButton(tr("OK")); + btOK->setMaximumWidth(45); + this->setMinimumWidth(640); + this->setMinimumHeight(480); + + QTextCharFormat fmt; + + fmt = cert_text->currentCharFormat(); + fmt.setFontFixedPitch(true); + fmt.setFontStyleHint(QFont::Monospace); + fmt.setFontFamily("Liberation Mono"); + cert_text->setCurrentCharFormat(fmt); + + cert_text->setReadOnly(true); + + layout->addWidget(cert_text); + layout->addWidget(btOK, 0, Qt::AlignCenter); + + setLayout(layout); + + connect(btOK, SIGNAL(clicked()), this, SLOT(OK())); + +} + +void ViewCertDialog::SetCert(QString cert_pem) +{ + QProcess openssl(this); + qint64 ret; + char *data; + QByteArray ba; + + openssl.start("openssl", QStringList()<<"x509"<<"-noout"<<"-text"<<"-nameopt"<<"multiline,-esc_msb,utf8"); + + if (!openssl.waitForStarted()) + return; + + ba = cert_pem.toAscii(); + ret = openssl.write(data = (char*)ba.constData()); + openssl.closeWriteChannel(); + + if (!openssl.waitForFinished()) + return; + + cert_text->setPlainText(QString::fromUtf8(openssl.readAllStandardOutput().constData())); +} + +void ViewCertDialog::OK() +{ + done(0); +} |
