[neon/forks/kaidan/Neon/release] debian/patches: simplify patch for qr code

Jonathan Esk-Riddell null at kde.org
Wed Feb 22 12:40:05 GMT 2023


Git commit a77c8889924205498c36d7c5be1b3c7a4de66a11 by Jonathan Esk-Riddell.
Committed on 22/02/2023 at 12:40.
Pushed by jriddell into branch 'Neon/release'.

simplify patch for qr code

M  +41   -117  debian/patches/qrcode.diff

https://invent.kde.org/neon/forks/kaidan/commit/a77c8889924205498c36d7c5be1b3c7a4de66a11

diff --git a/debian/patches/qrcode.diff b/debian/patches/qrcode.diff
index f56590a..51d0aac 100644
--- a/debian/patches/qrcode.diff
+++ b/debian/patches/qrcode.diff
@@ -1,62 +1,47 @@
---- kaiden/src/QrCodeDecoder.cpp	2021-05-28 22:55:43.000000000 +0100
-+++ kaidan/src/QrCodeDecoder.cpp	2023-02-15 13:16:35.918315698 +0000
-@@ -1,7 +1,7 @@
- /*
-  *  Kaidan - A user-friendly XMPP client for every device!
-  *
-- *  Copyright (C) 2016-2021 Kaidan developers and contributors
-+ *  Copyright (C) 2016-2022 Kaidan developers and contributors
-  *  (see the LICENSE file for a full list of copyright authors)
-  *
-  *  Kaidan is free software: you can redistribute it and/or modify
-@@ -60,7 +60,11 @@
- {
- 	// Advise the decoder to check for QR codes and to try decoding rotated versions of the image.
- #if ZXING_VERSION >= QT_VERSION_CHECK(1, 1, 0)
-+# if ZXING_VERSION >= QT_VERSION_CHECK(1, 1, 1)
-+	const auto decodeHints = DecodeHints().setFormats(BarcodeFormat::QRCode);
-+# else
- 	const auto decodeHints = DecodeHints().setFormats(BarcodeFormat::QR_CODE);
-+# endif
- 	const auto result = ReadBarcode({image.bits(), image.width(), image.height(), ZXing::ImageFormat::Lum, image.bytesPerLine()}, decodeHints);
- #else
- 	const auto decodeHints =
-@@ -74,10 +78,23 @@
- 	const auto result = MultiFormatReader(decodeHints).read(binImage);
- #endif
+commit dc41a3f3850308d5204134ae08e66f20a58195f9
+Author: Melvin Keskin <melvo at olomono.de>
+Date:   Sun Mar 13 13:03:16 2022 +0100
+
+    QrCodeGenerator: Replace deprecated 'BarcodeFormat::QR_CODE' with 'BarcodeFormat::QRCode'
+
+diff --git a/src/QrCodeGenerator.cpp b/src/QrCodeGenerator.cpp
+index b9c8743..1338308 100644
+--- a/src/QrCodeGenerator.cpp
++++ b/src/QrCodeGenerator.cpp
+@@ -33,6 +33,10 @@
+ #include <QImage>
+ #include <QRgb>
  
-+	// FIXME: `this` is not supposed to become nullptr in well-defined C++ code,
-+	//        so if we are unlucky, the compiler may optimize the entire check away.
-+	//        Additionally, this could be racy if the object is deleted on the other thread
-+	//        in between this check and the emit.
-+	const auto *self = this;
-+	if (!self) {
-+		return;
-+	}
++#include <ZXing/ZXVersion.h>
++#define ZXING_VERSION \
++	QT_VERSION_CHECK(ZXING_VERSION_MAJOR, ZXING_VERSION_MINOR, ZXING_VERSION_PATCH)
 +
- 	// If a QR code could be found and decoded, emit a signal with the decoded string.
- 	// Otherwise, emit a signal for failed decoding.
- 	if (result.isValid())
-+#if ZXING_VERSION < QT_VERSION_CHECK(2, 0, 0)
- 		emit decodingSucceeded(QString::fromStdString(TextUtfEncoding::ToUtf8(result.text())));
+ #include <ZXing/BarcodeFormat.h>
+ #include <ZXing/MultiFormatWriter.h>
+ 
+@@ -74,7 +78,11 @@ QImage QrCodeGenerator::generateBareJidQrCode(int edgePixelCount, const QString
+ QImage QrCodeGenerator::generateQrCode(int edgePixelCount, const QString &text)
+ {
+ 	try {
++#if ZXING_VERSION >= QT_VERSION_CHECK(1, 1, 1)
++		ZXing::MultiFormatWriter writer(ZXing::BarcodeFormat::QRCode);
 +#else
-+		emit decodingSucceeded(QString::fromStdString(result.text()));
+ 		ZXing::MultiFormatWriter writer(ZXing::BarcodeFormat::QR_CODE);
 +#endif
- 	else
- 		emit decodingFailed();
- }
---- kaidan/src/QrCodeGenerator.cpp	2021-05-28 22:55:43.000000000 +0100
-+++ kaidan/src/QrCodeGenerator.cpp	2022-10-14 15:30:40.902041831 +0100
-@@ -1,7 +1,7 @@
- /*
-  *  Kaidan - A user-friendly XMPP client for every device!
-  *
-- *  Copyright (C) 2016-2021 Kaidan developers and contributors
-+ *  Copyright (C) 2016-2022 Kaidan developers and contributors
-  *  (see the LICENSE file for a full list of copyright authors)
-  *
-  *  Kaidan is free software: you can redistribute it and/or modify
-@@ -33,11 +33,17 @@
+ 		const ZXing::BitMatrix &bitMatrix = writer.encode(text.toStdWString(), edgePixelCount, edgePixelCount);
+ 		return toImage(bitMatrix);
+ 	} catch (const std::invalid_argument &e) {
+commit dc41a3f3850308d5204134ae08e66f20a58195f9
+Author: Melvin Keskin <melvo at olomono.de>
+Date:   Sun Mar 13 13:03:16 2022 +0100
+
+    QrCodeGenerator: Replace deprecated 'BarcodeFormat::QR_CODE' with 'BarcodeFormat::QRCode'
+
+diff --git a/src/QrCodeGenerator.cpp b/src/QrCodeGenerator.cpp
+index b9c8743..1338308 100644
+--- a/src/QrCodeGenerator.cpp
++++ b/src/QrCodeGenerator.cpp
+@@ -33,6 +33,10 @@
  #include <QImage>
  #include <QRgb>
  
@@ -67,68 +52,7 @@
  #include <ZXing/BarcodeFormat.h>
  #include <ZXing/MultiFormatWriter.h>
  
- #include "AccountManager.h"
-+#include "MessageModel.h"
- #include "Kaidan.h"
-+#include "Settings.h"
- #include "qxmpp-exts/QXmppUri.h"
- 
- #include <stdexcept>
-@@ -57,16 +63,50 @@
- 	uri.setJid(AccountManager::instance()->jid());
- 	uri.setAction(QXmppUri::Login);
- 
--	if (Kaidan::instance()->passwordVisibility() != Kaidan::PasswordInvisible)
-+	if (Kaidan::instance()->settings()->authPasswordVisibility() != Kaidan::PasswordInvisible)
- 		uri.setPassword(AccountManager::instance()->password());
- 
- 	return generateQrCode(edgePixelCount, uri.toString());
- }
- 
--QImage QrCodeGenerator::generateBareJidQrCode(int edgePixelCount, const QString &bareJid)
-+QImage QrCodeGenerator::generateOwnTrustMessageQrCode(int edgePixelCount)
- {
-+	return generateTrustMessageQrCode(edgePixelCount, AccountManager::instance()->jid());
-+}
-+
-+QImage QrCodeGenerator::generateContactTrustMessageQrCode(int edgePixelCount, const QString &contactJid)
-+{
-+	return generateTrustMessageQrCode(edgePixelCount, contactJid);
-+}
-+
-+QImage QrCodeGenerator::generateTrustMessageQrCode(int edgePixelCount, const QString &jid)
-+{
-+	const auto keys = MessageModel::instance()->keys().value(jid);
-+	QList<QString> authenticatedKeys;
-+	QList<QString> distrustedKeys;
-+
-+	for (auto itr = keys.constBegin(); itr != keys.constEnd(); ++itr) {
-+		const auto key = itr.key().toHex();
-+		const auto trustLevel = itr.value();
-+
-+		if (trustLevel == QXmpp::TrustLevel::Authenticated) {
-+			authenticatedKeys.append(key);
-+		} else if (trustLevel == QXmpp::TrustLevel::ManuallyDistrusted) {
-+			distrustedKeys.append(key);
-+		}
-+	}
-+
- 	QXmppUri uri;
--	uri.setJid(bareJid);
-+	uri.setJid(jid);
-+
-+	// Create a Trust Message URI only if there are keys for it.
-+	if (!authenticatedKeys.isEmpty() || !distrustedKeys.isEmpty()) {
-+		uri.setAction(QXmppUri::TrustMessage);
-+		// TODO: Find solution to pass enum to "uri.setEncryption()" instead of string (see QXmppGlobal::encryptionToString())
-+		uri.setEncryption(QStringLiteral("urn:xmpp:omemo:2"));
-+		uri.setTrustedKeysIds(authenticatedKeys);
-+		uri.setDistrustedKeysIds(distrustedKeys);
-+	}
- 
- 	return generateQrCode(edgePixelCount, uri.toString());
- }
-@@ -74,7 +114,11 @@
+@@ -74,7 +78,11 @@ QImage QrCodeGenerator::generateBareJidQrCode(int edgePixelCount, const QString
  QImage QrCodeGenerator::generateQrCode(int edgePixelCount, const QString &text)
  {
  	try {


More information about the Neon-commits mailing list