Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
libkleo
Commits
97eb1dc3
Commit
97eb1dc3
authored
Oct 14, 2021
by
Ingo Klöcker
Browse files
Add helper for retrieving used versions of GnuPG and libgcrypt
GnuPG-bug-id: 5652
parent
d6fbbb96
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/utils/gnupg.cpp
View file @
97eb1dc3
...
...
@@ -497,3 +497,32 @@ QString Kleo::stringFromGpgOutput(const QByteArray &ba)
return
QString
::
fromLocal8Bit
(
ba
);
#endif
}
QStringList
Kleo
::
backendVersionInfo
()
{
QStringList
versions
;
if
(
Kleo
::
engineIsVersion
(
2
,
2
,
24
,
GpgME
::
GpgConfEngine
))
{
QProcess
p
;
qCDebug
(
LIBKLEO_LOG
)
<<
"Running gpgconf --show-versions ..."
;
p
.
start
(
Kleo
::
gpgConfPath
(),
{
QStringLiteral
(
"--show-versions"
)});
// wait at most 1 second
if
(
!
p
.
waitForFinished
(
1000
))
{
qCDebug
(
LIBKLEO_LOG
)
<<
"Running gpgconf --show-versions timed out after 1 second."
;
}
else
if
(
p
.
exitStatus
()
!=
QProcess
::
NormalExit
||
p
.
exitCode
()
!=
0
)
{
qCDebug
(
LIBKLEO_LOG
)
<<
"Running gpgconf --show-versions failed:"
<<
p
.
errorString
();
qCDebug
(
LIBKLEO_LOG
)
<<
"gpgconf stderr:"
<<
p
.
readAllStandardError
();
qCDebug
(
LIBKLEO_LOG
)
<<
"gpgconf stdout:"
<<
p
.
readAllStandardOutput
();
}
else
{
const
QByteArray
output
=
p
.
readAllStandardOutput
().
replace
(
"
\r\n
"
,
"
\n
"
);
qCDebug
(
LIBKLEO_LOG
)
<<
"gpgconf stdout:"
<<
p
.
readAllStandardOutput
();
const
auto
lines
=
output
.
split
(
'\n'
);
for
(
const
auto
&
line
:
lines
)
{
if
(
line
.
startsWith
(
"* GnuPG"
)
||
line
.
startsWith
(
"* Libgcrypt"
))
{
const
auto
components
=
line
.
split
(
' '
);
versions
.
push_back
(
QString
::
fromLatin1
(
components
.
at
(
1
)
+
' '
+
components
.
value
(
2
)));
}
}
}
}
return
versions
;
}
src/utils/gnupg.h
View file @
97eb1dc3
...
...
@@ -58,5 +58,10 @@ KLEO_EXPORT QString stringFromGpgOutput(const QByteArray &ba);
/* Check if a minimum version is there. Strings should be in the format:
* 1.2.3 */
KLEO_EXPORT
bool
versionIsAtLeast
(
const
char
*
minimum
,
const
char
*
actual
);
}
/** Returns a list of component names (e.g. GnuPG, libgcrypt) followed by
* version numbers. This is meant for displaying in the About dialog.
*/
KLEO_EXPORT
QStringList
backendVersionInfo
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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