superpacko
5th September 2011, 14:59
Hey there, im having a few issues trying to use QProcess to create a sub-process that runs GPG on the background.
I had previously implemented the functionality with windows specific methods, but since we are porting everything to Linux and Mac i thought it would be nice to let QProcess handle everything.
The problem is that the arguments that QProcess is building are not compatible with the type or argument GPG expects (GPG is pretty sensitive).
My code look like this:
QList<GPGKey> GPGKeyManagement::getKeys(GPGParameter *param)
{
QList<GPGKey> list;
QStringList args;
args << "--homedir . --list-keys";
//args << "--homedir . ";
//args << " --list-keys ";
if (param)
{
// add the information specified in param to the args
}
QProcess gpg;
gpg.setProcessChannelMode(QProcess::MergedChannels );
gpg.start("gpg.exe", args);
if (!gpg.waitForFinished())
qDebug() << "Error: " << gpg.errorString();
else
{
QString response(gpg.readAll());
qDebug() << response;
list = parseKeysFromOutput(response);
}
return list;
}
i also tried this, with no luck:
gpg.start("gpg.exe --homedir . --list-keys", args); //args empty
or
args << "gpg.exe --homedir . --list-keys";
gpg.start("", args);
When Qt builds the command line it does 'gpg "--homedir . --list-keys" ' and so GPG complains about the double quotes added.
Was anyone able to call gpg from a QProcess in Windows?
I had previously implemented the functionality with windows specific methods, but since we are porting everything to Linux and Mac i thought it would be nice to let QProcess handle everything.
The problem is that the arguments that QProcess is building are not compatible with the type or argument GPG expects (GPG is pretty sensitive).
My code look like this:
QList<GPGKey> GPGKeyManagement::getKeys(GPGParameter *param)
{
QList<GPGKey> list;
QStringList args;
args << "--homedir . --list-keys";
//args << "--homedir . ";
//args << " --list-keys ";
if (param)
{
// add the information specified in param to the args
}
QProcess gpg;
gpg.setProcessChannelMode(QProcess::MergedChannels );
gpg.start("gpg.exe", args);
if (!gpg.waitForFinished())
qDebug() << "Error: " << gpg.errorString();
else
{
QString response(gpg.readAll());
qDebug() << response;
list = parseKeysFromOutput(response);
}
return list;
}
i also tried this, with no luck:
gpg.start("gpg.exe --homedir . --list-keys", args); //args empty
or
args << "gpg.exe --homedir . --list-keys";
gpg.start("", args);
When Qt builds the command line it does 'gpg "--homedir . --list-keys" ' and so GPG complains about the double quotes added.
Was anyone able to call gpg from a QProcess in Windows?