Skip to content

Commit 84931cd

Browse files
fix: ability to crosscompile using MXE
1 parent aa0cac5 commit 84931cd

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/core/Database.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <algorithm>
3838

3939
#ifdef Q_OS_WIN
40-
#include <Windows.h>
40+
#include <windows.h>
4141
#endif
4242

4343
QHash<QUuid, QPointer<Database>> Database::s_uuidMap;
@@ -338,7 +338,7 @@ bool Database::saveAs(const QString& filePath, SaveAction action, const QString&
338338

339339
#ifdef Q_OS_WIN
340340
if (isHidden) {
341-
SetFileAttributes(realFilePath.toStdString().c_str(), FILE_ATTRIBUTE_HIDDEN);
341+
SetFileAttributes(static_cast<LPCWSTR>(realFilePath.toStdString().c_str()), FILE_ATTRIBUTE_HIDDEN);
342342
}
343343
#endif
344344
m_ignoreFileChangesUntilSaved = false;

src/keys/drivers/YubiKeyInterfacePCSC.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ typedef unsigned long SCUINT;
4141
typedef long RETVAL;
4242
#endif
4343

44+
// LPWSTR is needs to be defined when compiling outside of Windows
45+
#ifndef Q_OS_WIN
46+
#define LPWSTR char *
47+
#endif
48+
4449
// This namescape contains static wrappers for the smart card API
4550
// Which enable the communication with a Yubikey via PCSC ADPUs
4651
namespace
@@ -107,7 +112,7 @@ namespace
107112
}
108113
char* mszReaders = new char[dwReaders + 2];
109114

110-
rv = SCardListReaders(context, nullptr, mszReaders, &dwReaders);
115+
rv = SCardListReaders(context, nullptr, static_cast<LPWSTR>(mszReaders), &dwReaders);
111116
if (rv == SCARD_S_SUCCESS) {
112117
char* readhead = mszReaders;
113118
// Names are separated by a null byte
@@ -143,7 +148,7 @@ namespace
143148
uint8_t pbAtr[MAX_ATR_SIZE] = {0}; // ATR record
144149
SCUINT dwAtrLen = sizeof(pbAtr); // ATR record size
145150

146-
auto rv = SCardStatus(handle, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
151+
auto rv = SCardStatus(handle, static_cast<LPWSTR>(pbReader), &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
147152
if (rv == SCARD_S_SUCCESS) {
148153
switch (dwProt) {
149154
case SCARD_PROTOCOL_T0:
@@ -431,7 +436,7 @@ namespace
431436
SCARDHANDLE hCard;
432437
SCUINT dwActiveProtocol = SCARD_PROTOCOL_UNDEFINED;
433438
rv = SCardConnect(context,
434-
reader_name.toStdString().c_str(),
439+
static_cast<LPWSTR>(reader_name.toStdString().c_str()),
435440
SCARD_SHARE_SHARED,
436441
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
437442
&hCard,
@@ -446,7 +451,7 @@ namespace
446451
uint8_t pbAtr[MAX_ATR_SIZE] = {0};
447452
SCUINT dwAtrLen = sizeof(pbAtr);
448453

449-
rv = SCardStatus(hCard, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
454+
rv = SCardStatus(hCard, static_cast<LPWSTR>(pbReader), &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
450455
if (rv == SCARD_S_SUCCESS && (dwProt == SCARD_PROTOCOL_T0 || dwProt == SCARD_PROTOCOL_T1)) {
451456
// Find which AID to use
452457
SCardAID satr;
@@ -568,7 +573,7 @@ YubiKey::KeyMap YubiKeyInterfacePCSC::findValidKeys(int& connectedKeys)
568573
SCARDHANDLE hCard;
569574
SCUINT dwActiveProtocol = SCARD_PROTOCOL_UNDEFINED;
570575
auto rv = SCardConnect(m_sc_context,
571-
reader_name.toStdString().c_str(),
576+
static_cast<LPWSTR>(reader_name.toStdString().c_str()),
572577
SCARD_SHARE_SHARED,
573578
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
574579
&hCard,
@@ -589,7 +594,7 @@ YubiKey::KeyMap YubiKeyInterfacePCSC::findValidKeys(int& connectedKeys)
589594
uint8_t pbAtr[MAX_ATR_SIZE] = {0};
590595
SCUINT dwAtrLen = sizeof(pbAtr);
591596

592-
rv = SCardStatus(hCard, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
597+
rv = SCardStatus(hCard, static_cast<LPWSTR>(pbReader), &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
593598
if (rv != SCARD_S_SUCCESS || (dwProt != SCARD_PROTOCOL_T0 && dwProt != SCARD_PROTOCOL_T1)) {
594599
// Could not read the ATR record or the protocol is not supported
595600
continue;

0 commit comments

Comments
 (0)