MCPcopy Create free account
hub / github.com/IJHack/QtPass / resolveGpgconfCommand

Method resolveGpgconfCommand

src/pass.cpp:367–409  ·  view source on GitHub ↗

* @brief Resolves the appropriate gpgconf command from a given GPG executable * path or command string. * @example * ResolvedGpgconfCommand result = Pass::resolveGpgconfCommand("wsl.exe * /usr/bin/gpg"); std::cout << result.first.toStdString() << std::endl; // * Expected output sample * * @param const QString &gpgPath - Path or command string pointing to the GPG * executable. * @return Re

Source from the content-addressed store, hash-verified

365 * command and its arguments.
366 */
367auto Pass::resolveGpgconfCommand(const QString &gpgPath)
368 -> ResolvedGpgconfCommand {
369 if (gpgPath.trimmed().isEmpty()) {
370 return {"gpgconf", {}};
371 }
372
373#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
374 QStringList parts = QProcess::splitCommand(gpgPath);
375#else
376 QStringList parts = splitCommandCompat(gpgPath);
377#endif
378
379 if (parts.isEmpty()) {
380 return {"gpgconf", {}};
381 }
382
383 const QString first = parts.first();
384 if (first.compare("wsl", Qt::CaseInsensitive) == 0 ||
385 first.compare("wsl.exe", Qt::CaseInsensitive) == 0) {
386 if (parts.size() >= 2 && parts.at(1).startsWith("sh")) {
387 return {"gpgconf", {}};
388 }
389 if (parts.size() >= 2 &&
390 QFileInfo(parts.last()).fileName().startsWith("gpg")) {
391 QString wslGpgconf = resolveWslGpgconfPath(parts.last());
392 parts.removeLast();
393 parts.append(wslGpgconf);
394 return {parts.first(), parts.mid(1)};
395 }
396 return {"gpgconf", {}};
397 }
398
399 if (!first.contains('/') && !first.contains('\\')) {
400 return {"gpgconf", {}};
401 }
402
403 QString gpgconfPath = findGpgconfInGpgDir(first);
404 if (!gpgconfPath.isEmpty()) {
405 return {gpgconfPath, {}};
406 }
407
408 return {"gpgconf", {}};
409}
410
411/**
412 * @brief Pass::GenerateGPGKeys internal gpg keypair generator . .

Callers

nothing calls this directly

Calls 3

splitCommandCompatFunction · 0.85
resolveWslGpgconfPathFunction · 0.85
findGpgconfInGpgDirFunction · 0.85

Tested by

no test coverage detected