Commit 2d097204 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Use getReaders() from libkleo to get the list of smart card readers

GnuPG-bug-id: 5666
parent 9121c3fd
......@@ -30,7 +30,7 @@ option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
set(KF5_MIN_VERSION "5.87.0")
set(KMIME_VERSION "5.18.40")
set(LIBKLEO_VERSION "5.18.44")
set(LIBKLEO_VERSION "5.18.45")
set(QT_REQUIRED_VERSION "5.15.2")
set(GPGME_REQUIRED_VERSION "1.13.1")
set(BOOST_REQUIRED_VERSION "1.58")
......
......@@ -11,7 +11,7 @@
#include "command_p.h"
#include "smartcard/readerstatus.h"
#include <Libkleo/SCDaemon>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -56,7 +56,7 @@ ListReadersCommand::Private::~Private() = default;
void ListReadersCommand::Private::start()
{
GpgME::Error err;
const auto readers = SmartCard::ReaderStatus::getReaders(err);
const auto readers = SCDaemon::getReaders(err);
QString message;
if (err) {
message = i18nc("@info", "Reading the list of readers failed:") + QLatin1Char{'\n'} +
......
......@@ -24,8 +24,6 @@
#endif
#include "keypairinfo.h"
#include "utils/hex.h"
#include <Libkleo/GnuPG>
#include <Libkleo/FileSystemWatcher>
......@@ -1137,47 +1135,4 @@ Error ReaderStatus::switchCardAndApp(const std::string &serialNumber, const std:
return err;
}
namespace
{
static auto split(const std::string &s, char c)
{
std::vector<std::string> result;
auto start = 0;
auto end = s.find(c, start);
while (end != s.npos) {
result.push_back(s.substr(start, end - start));
start = end + 1;
end = s.find(c, start);
}
result.push_back(s.substr(start));
return result;
}
}
// static
std::vector<std::string> ReaderStatus::getReaders(Error &err)
{
std::vector<std::string> result;
auto c = Context::createForEngine(AssuanEngine, &err);
if (err) {
qCDebug(KLEOPATRA_LOG) << "Creating context for Assuan engine failed:" << err;
return result;
}
auto assuanContext = std::shared_ptr<Context>(c.release());
const std::string command = "SCD GETINFO reader_list";
const auto readersData = gpgagent_data(assuanContext, command.c_str(), err);
if (err) {
return result;
}
const auto readers = hexdecode(readersData);
result = split(readers, '\n');
return result;
}
#include "readerstatus.moc"
......@@ -62,10 +62,6 @@ public:
const std::string &appName, GpgME::Error &err);
static GpgME::Error switchCardAndApp(const std::string &serialNumber, const std::string &appName);
// Returns a list of reader IDs of the form "%04X:%04X:%s:0"
// with USB device vendor ID & 0xffff, USB device product ID & 0xffff, USB device serial number or "X"
static std::vector<std::string> getReaders(GpgME::Error &err);
public Q_SLOTS:
void updateStatus();
void startMonitoring();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment