changeset 85:e52df5870c4f

Add basic interaction with another process
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 20 Mar 2014 16:22:16 +0000
parents 00a93409e93e
children 6f1a73575c99
files ui/listupdatedialog.cpp
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ui/listupdatedialog.cpp	Thu Mar 20 16:21:27 2014 +0000
+++ b/ui/listupdatedialog.cpp	Thu Mar 20 16:22:16 2014 +0000
@@ -1,5 +1,6 @@
 #include "listupdatedialog.h"
 #include <QDebug>
+#include <QProcess>
 #include <QPushButton>
 #include <QGroupBox>
 #include <QHBoxLayout>
@@ -22,6 +23,8 @@
     QVBoxLayout *topLayout = new QVBoxLayout;
     QHBoxLayout *listLayout = new QHBoxLayout;
     QPushButton *executeUpdate = new QPushButton(tr("Update Stores"));
+    connect(executeUpdate, &QPushButton::clicked,
+            this, &ListUpdateDialog::executeUpdate);
 
     /* The remove groups */
     QVBoxLayout *removeGroupLayout = new QVBoxLayout;
@@ -55,6 +58,8 @@
         }
         QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
         item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
+        item->setData(Qt::ToolTipRole, cert.details());
+        item->setData(Qt::UserRole, cert.base64Line());
         item->setCheckState(Qt::Checked);
         mInstallListWidget->addItem(item);
     }
@@ -73,5 +78,27 @@
 }
 
 void ListUpdateDialog::executeUpdate() {
+    /* TODO move this in another dialog and call it async*/
+    QProcess installerProcess;
 
+    installerProcess.setProgram("cinst");
+    installerProcess.start();
+    installerProcess.waitForStarted();
+    installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n");
+    installerProcess.write(mCertificateList.rawData().toLatin1());
+    installerProcess.write("-----END CERTIFICATE LIST-----\r\n");
+
+    QList<QListWidgetItem *> selectedItems = mInstallListWidget->selectedItems();
+    selectedItems << mRemoveListWidget->selectedItems();
+
+    foreach (const QListWidgetItem * item, selectedItems) {
+        installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
+        installerProcess.write("\r\n");
+    }
+
+    installerProcess.closeWriteChannel();
+    installerProcess.waitForFinished();
+    qDebug() << "cinst output: " << installerProcess.readAllStandardOutput();
+    qDebug() << " Done " << " exitCode: " << installerProcess.exitCode();
+    qDebug() << " Done " << " exitStatus: " << installerProcess.exitStatus();
 }

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