Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
2d097204
Commit
2d097204
authored
Oct 29, 2021
by
Ingo Klöcker
Browse files
Use getReaders() from libkleo to get the list of smart card readers
GnuPG-bug-id: 5666
parent
9121c3fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
2d097204
...
...
@@ -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.4
4
"
)
set
(
LIBKLEO_VERSION
"5.18.4
5
"
)
set
(
QT_REQUIRED_VERSION
"5.15.2"
)
set
(
GPGME_REQUIRED_VERSION
"1.13.1"
)
set
(
BOOST_REQUIRED_VERSION
"1.58"
)
...
...
src/commands/listreaderscommand.cpp
View file @
2d097204
...
...
@@ -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
=
S
martCard
::
ReaderStatus
::
getReaders
(
err
);
const
auto
readers
=
S
CDaemon
::
getReaders
(
err
);
QString
message
;
if
(
err
)
{
message
=
i18nc
(
"@info"
,
"Reading the list of readers failed:"
)
+
QLatin1Char
{
'\n'
}
+
...
...
src/smartcard/readerstatus.cpp
View file @
2d097204
...
...
@@ -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"
src/smartcard/readerstatus.h
View file @
2d097204
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment