diff ui/certificate.cpp @ 1297:c2fd36cd4093

(issue123) Use gcr-viewer to view certificate details on Linux
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 16:24:05 +0200
parents 265583011f24
children 60e481aa75ca
line wrap: on
line diff
--- a/ui/certificate.cpp	Mon Sep 29 16:12:47 2014 +0200
+++ b/ui/certificate.cpp	Mon Sep 29 16:24:05 2014 +0200
@@ -10,6 +10,8 @@
 #include <QFile>
 #include <QStringList>
 #include <QObject>
+#include <QProcess>
+#include <QTemporaryFile>
 
 #include <polarssl/sha1.h>
 
@@ -257,7 +259,21 @@
 #else
 bool Certificate::showNativeUI(void *parent)
 {
-    qDebug() << "Not implemented.";
-    return false;
+    QTemporaryFile *tmpCert = new QTemporaryFile;
+    tmpCert->open();
+    tmpCert->write("-----BEGIN CERTIFICATE-----\n");
+    tmpCert->write(mBaseLine.right(mBaseLine.size() - 2).toLatin1());
+    tmpCert->write("-----END CERTIFICATE-----\n");
+    tmpCert->close();
+    QStringList args;
+    args << tmpCert->fileName();
+    QProcess *viewer = new QProcess();
+    viewer->setProgram("gcr-viewer");
+    viewer->setArguments(args);
+
+    QObject::connect (viewer, SIGNAL(finished(int, QProcess::ExitStatus)), tmpCert, SLOT(deleteLater()));
+    QObject::connect (viewer, SIGNAL(finished(int, QProcess::ExitStatus)), viewer, SLOT(deleteLater()));
+    viewer->start();
+    return !(!viewer->waitForStarted() || viewer->state() == QProcess::NotRunning);
 }
 #endif

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