-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43f80ce
commit a636daa
Showing
16 changed files
with
134 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -14,27 +14,22 @@ | |
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/* | ||
#include <QTextCodec> | ||
#include "MacPasteboard.h" | ||
|
||
QString MacPasteboard::convertorName() | ||
{ | ||
return QLatin1String("MacPasteboard"); | ||
} | ||
#include "MacPasteboard.h" | ||
#include <QStringConverter> | ||
|
||
QString MacPasteboard::flavorFor(const QString& mimetype) | ||
QString MacPasteboard::utiForMime(const QString& mime) const | ||
{ | ||
if (mimetype == QLatin1String("text/plain")) { | ||
if (mime == QLatin1String("text/plain")) { | ||
return QLatin1String("public.utf8-plain-text"); | ||
} else if (mimetype == QLatin1String("application/x-nspasteboard-concealed-type")) { | ||
} else if (mime == QLatin1String("application/x-nspasteboard-concealed-type")) { | ||
return QLatin1String("org.nspasteboard.ConcealedType"); | ||
} | ||
|
||
int i = mimetype.indexOf(QLatin1String("charset=")); | ||
int i = mime.indexOf(QLatin1String("charset=")); | ||
|
||
if (i >= 0) { | ||
QString cs(mimetype.mid(i + 8).toLower()); | ||
QString cs(mime.mid(i + 8).toLower()); | ||
i = cs.indexOf(QLatin1Char(';')); | ||
|
||
if (i >= 0) { | ||
|
@@ -47,55 +42,61 @@ QString MacPasteboard::flavorFor(const QString& mimetype) | |
return QLatin1String("public.utf16-plain-text"); | ||
} | ||
} | ||
return QString(); | ||
return {}; | ||
} | ||
|
||
QString MacPasteboard::mimeFor(QString flavor) | ||
QString MacPasteboard::mimeForUti(const QString& uti) const | ||
{ | ||
if (flavor == QLatin1String("public.utf8-plain-text")) | ||
if (uti == QLatin1String("public.utf8-plain-text")) | ||
return QLatin1String("text/plain"); | ||
if (flavor == QLatin1String("org.nspasteboard.ConcealedType")) | ||
if (uti == QLatin1String("org.nspasteboard.ConcealedType")) | ||
return QLatin1String("application/x-nspasteboard-concealed-type"); | ||
if (flavor == QLatin1String("public.utf16-plain-text")) | ||
if (uti == QLatin1String("public.utf16-plain-text")) | ||
return QLatin1String("text/plain;charset=utf16"); | ||
return QString(); | ||
return {}; | ||
} | ||
|
||
bool MacPasteboard::canConvert(const QString& mimetype, QString flavor) | ||
bool MacPasteboard::canConvert(const QString& mime, const QString& uti) const | ||
{ | ||
Q_UNUSED(mimetype); | ||
Q_UNUSED(flavor); | ||
Q_UNUSED(mime); | ||
Q_UNUSED(uti); | ||
return true; | ||
} | ||
|
||
QVariant MacPasteboard::convertToMime(const QString& mimetype, QList<QByteArray> data, QString flavor) | ||
QVariant MacPasteboard::convertToMime(const QString& mime, const QList<QByteArray>& data, const QString& uti) const | ||
{ | ||
if (data.count() > 1) | ||
qWarning("QMime::convertToMime: Cannot handle multiple member data"); | ||
const QByteArray& firstData = data.first(); | ||
QVariant ret; | ||
if (flavor == QLatin1String("public.utf8-plain-text")) { | ||
if (uti == QLatin1String("public.utf8-plain-text")) { | ||
ret = QString::fromUtf8(firstData); | ||
} else if (flavor == QLatin1String("org.nspasteboard.ConcealedType")) { | ||
} else if (uti == QLatin1String("org.nspasteboard.ConcealedType")) { | ||
ret = QString::fromUtf8(firstData); | ||
} else if (flavor == QLatin1String("public.utf16-plain-text")) { | ||
ret = QTextCodec::codecForName("UTF-16")->toUnicode(firstData); | ||
} else if (uti == QLatin1String("public.utf16-plain-text")) { | ||
auto toUtf16 = QStringDecoder(QStringDecoder::Utf16); | ||
QVariant var{toUtf16(firstData)}; | ||
return var; | ||
} else { | ||
qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype)); | ||
qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mime)); | ||
} | ||
return ret; | ||
} | ||
|
||
QList<QByteArray> MacPasteboard::convertFromMime(const QString&, QVariant data, QString flavor) | ||
QList<QByteArray> MacPasteboard::convertFromMime(const QString& mime, const QVariant& data, const QString& uti) const | ||
{ | ||
Q_UNUSED(mime); | ||
|
||
QList<QByteArray> ret; | ||
QString string = data.toString(); | ||
if (flavor == QLatin1String("public.utf8-plain-text")) | ||
ret.append(string.toUtf8()); | ||
else if (flavor == QLatin1String("org.nspasteboard.ConcealedType")) | ||
ret.append(string.toUtf8()); | ||
else if (flavor == QLatin1String("public.utf16-plain-text")) | ||
ret.append(QTextCodec::codecForName("UTF-16")->fromUnicode(string)); | ||
QString dataString = data.toString(); | ||
if (uti == QLatin1String("public.utf8-plain-text")) { | ||
ret.append(dataString.toUtf8()); | ||
} else if (uti == QLatin1String("org.nspasteboard.ConcealedType")) { | ||
ret.append(dataString.toUtf8()); | ||
} else if (uti == QLatin1String("public.utf16-plain-text")) { | ||
auto toUtf16 = QStringEncoder(QStringDecoder::Utf16); | ||
QByteArray baUtf16 = toUtf16(dataString); | ||
ret.append(baUtf16); | ||
} | ||
return ret; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -14,27 +14,28 @@ | |
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/* | ||
|
||
#ifndef KEEPASSXC_MACPASTEBOARD_H | ||
#define KEEPASSXC_MACPASTEBOARD_H | ||
|
||
#include <QObject> | ||
//#include <QTextCodec> | ||
#include <QStringConverter> | ||
#include <QUtiMimeConverter> | ||
#include <QVariant> | ||
|
||
class MacPasteboard : public QObject, public QUtiMimeConverter | ||
{ | ||
public: | ||
explicit MacPasteboard() : QUtiMimeConverter() | ||
explicit MacPasteboard() | ||
: QUtiMimeConverter() | ||
{ | ||
} | ||
|
||
//QString convertorName() override; | ||
virtual bool canConvert(const QString &mime, const QString &uti) override; | ||
QString mimeForUti(const QString &uti) override; | ||
QString utiForMime(const QString &mime) override; | ||
QVariant convertToMime(const QString &mime, const QList<QByteArray> &data, const QString &uti) override; | ||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &uti) override; | ||
bool canConvert(const QString& mime, const QString& uti) const; | ||
QString mimeForUti(const QString& uti) const override; | ||
QString utiForMime(const QString& mime) const override; | ||
QVariant convertToMime(const QString& mime, const QList<QByteArray>& data, const QString& uti) const override; | ||
QList<QByteArray> convertFromMime(const QString& mime, const QVariant& data, const QString& uti) const override; | ||
}; | ||
|
||
#endif // KEEPASSXC_MACPASTEBOARD_H*/ | ||
#endif // KEEPASSXC_MACPASTEBOARD_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
/* | ||
* Copyright (C) 2016 Enrico Mariotti <[email protected]> | ||
* Copyright (C) 2017 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -39,7 +39,7 @@ namespace | |
return group; | ||
} | ||
|
||
auto nameList = groupPath.split("/", QString::SkipEmptyParts); | ||
auto nameList = groupPath.split("/", Qt::SkipEmptyParts); | ||
// Skip over first group name if root | ||
if (nameList.first().compare("root", Qt::CaseInsensitive)) { | ||
nameList.removeFirst(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2014 Kyle Manna <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -24,8 +24,6 @@ | |
#include <QSet> | ||
#include <QtConcurrent> | ||
|
||
QMutex YubiKey::s_interfaceMutex(QMutex::Recursive); | ||
|
||
YubiKey::YubiKey() | ||
{ | ||
int num_interfaces = 0; | ||
|
@@ -73,7 +71,7 @@ bool YubiKey::isInitialized() | |
|
||
bool YubiKey::findValidKeys() | ||
{ | ||
QMutexLocker lock(&s_interfaceMutex); | ||
QMutexLocker lock(&m_interfaces_detect_mutex); | ||
|
||
m_usbKeys = YubiKeyInterfaceUSB::instance()->findValidKeys(); | ||
m_pcscKeys = YubiKeyInterfacePCSC::instance()->findValidKeys(); | ||
|
@@ -88,7 +86,7 @@ void YubiKey::findValidKeysAsync() | |
|
||
YubiKey::KeyMap YubiKey::foundKeys() | ||
{ | ||
QMutexLocker lock(&s_interfaceMutex); | ||
QMutexLocker lock(&m_interfaces_detect_mutex); | ||
KeyMap foundKeys; | ||
|
||
for (auto i = m_usbKeys.cbegin(); i != m_usbKeys.cend(); ++i) { | ||
|
@@ -104,7 +102,7 @@ YubiKey::KeyMap YubiKey::foundKeys() | |
|
||
QString YubiKey::errorMessage() | ||
{ | ||
QMutexLocker lock(&s_interfaceMutex); | ||
QMutexLocker lock(&m_interfaces_detect_mutex); | ||
|
||
QString error; | ||
error.clear(); | ||
|
@@ -141,7 +139,7 @@ QString YubiKey::errorMessage() | |
*/ | ||
bool YubiKey::testChallenge(YubiKeySlot slot, bool* wouldBlock) | ||
{ | ||
QMutexLocker lock(&s_interfaceMutex); | ||
QMutexLocker lock(&m_interfaces_detect_mutex); | ||
|
||
if (m_usbKeys.contains(slot)) { | ||
return YubiKeyInterfaceUSB::instance()->testChallenge(slot, wouldBlock); | ||
|
@@ -166,7 +164,7 @@ bool YubiKey::testChallenge(YubiKeySlot slot, bool* wouldBlock) | |
YubiKey::ChallengeResult | ||
YubiKey::challenge(YubiKeySlot slot, const QByteArray& challenge, Botan::secure_vector<char>& response) | ||
{ | ||
QMutexLocker lock(&s_interfaceMutex); | ||
QMutexLocker lock(&m_interfaces_detect_mutex); | ||
|
||
m_error.clear(); | ||
|
||
|
Oops, something went wrong.