# HG changeset patch # User Andre Heinecke # Date 1395332536 0 # Node ID e52df5870c4f657da400d9e359fd5117d29a4902 # Parent 00a93409e93e139838e08ecf4a7f2cbc725f8086 Add basic interaction with another process diff -r 00a93409e93e -r e52df5870c4f ui/listupdatedialog.cpp --- 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 +#include #include #include #include @@ -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 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(); }