Skip to content

Commit

Permalink
Simplify APDU SW usage
Browse files Browse the repository at this point in the history
IB-8231

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Oct 30, 2024
1 parent cd8d216 commit b9c31c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions client/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#include <QtCore/QTextStream>
#include <QtNetwork/QSslCertificate>

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
namespace Qt {
using ::hex;
}
#endif

void Diagnostics::generalInfo(QTextStream &s)
{
s << "<b>" << tr("Arguments:") << "</b> " << Application::arguments().join(' ') << "<br />"
Expand Down Expand Up @@ -122,10 +128,10 @@ void Diagnostics::generalInfo(QTextStream &s)
{
constexpr auto APDU = &QByteArray::fromHex;
QPCSCReader::Result r = reader.transfer(apdu);
s << label << ": " << r.SW.toHex();
if (r.SW == APDU("9000")) s << " (OK)";
if (r.SW == APDU("6A81")) s << " (Locked)";
if (r.SW == APDU("6A82")) s << " (Not found)";
s << label << ": " << Qt::hex << r.SW;
if (r.SW == 0x9000) s << " (OK)";
if (r.SW == 0x6A81) s << " (Locked)";
if (r.SW == 0x6A82) s << " (Not found)";
s << "<br />";
return r;
};
Expand Down
2 changes: 1 addition & 1 deletion client/QSmartCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ QSmartCard::ErrorType QSmartCard::Private::handlePinResult(QPCSCReader *reader,
{
if(!response || forceUpdate)
card->updateCounters(reader, t.d);
switch((quint8(response.SW[0]) << 8) + quint8(response.SW[1]))
switch(response.SW)
{
case 0x9000: return QSmartCard::NoError;
case 0x63C0: return QSmartCard::BlockedError;//pin retry count 0
Expand Down
2 changes: 1 addition & 1 deletion common
Submodule common updated 3 files
+22 −17 QPCSC.cpp
+2 −7 QPCSC.h
+8 −14 QPCSC_p.h

0 comments on commit b9c31c3

Please sign in to comment.