git: 7314f3d14ab7 - main - graphics/digikam: make compatible with exiv2 0.28

From: Matthias Andree <mandree_at_FreeBSD.org>
Date: Sun, 09 Jul 2023 22:09:58 UTC
The branch main has been updated by mandree:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7314f3d14ab7912d70800cae62bf5ffc778376f3

commit 7314f3d14ab7912d70800cae62bf5ffc778376f3
Author:     Matthias Andree <mandree@FreeBSD.org>
AuthorDate: 2023-07-03 00:04:45 +0000
Commit:     Matthias Andree <mandree@FreeBSD.org>
CommitDate: 2023-07-09 22:09:12 +0000

    graphics/digikam: make compatible with exiv2 0.28
    
    NOTE: Upstream has just tagged digikam 8.1.0 which
    should also work with exiv2 0.28, see here:
    https://invent.kde.org/graphics/digikam/-/blob/v8.1.0/NEWS
    
    But the web site does not yet mention 8.1.0 and the release
    tarball is not available, so upgrading might be premature.
    
    PR:             272311
---
 graphics/digikam/Makefile                          |  2 +-
 ..._metadataengine_engine_metaengine__comments.cpp | 11 +++
 ...s_metadataengine_engine_metaengine__data__p.cpp | 11 +++
 ...libs_metadataengine_engine_metaengine__exif.cpp | 98 ++++++++++++++++++++++
 ...libs_metadataengine_engine_metaengine__iptc.cpp | 29 +++++++
 ...libs_metadataengine_engine_metaengine__item.cpp | 65 ++++++++++++++
 ...re_libs_metadataengine_engine_metaengine__p.cpp | 11 +++
 ...core_libs_metadataengine_engine_metaengine__p.h | 22 +++++
 ..._libs_metadataengine_engine_metaengine__xmp.cpp | 20 +++++
 9 files changed, 268 insertions(+), 1 deletion(-)

diff --git a/graphics/digikam/Makefile b/graphics/digikam/Makefile
index 7a7e1e3a9e10..6309bb4fce25 100644
--- a/graphics/digikam/Makefile
+++ b/graphics/digikam/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	digikam
 DISTVERSION=	7.10.0
-PORTREVISION=	6
+PORTREVISION=	7
 CATEGORIES=	graphics kde
 MASTER_SITES=	KDE/stable/${PORTNAME}/${PORTVERSION}
 DIST_SUBDIR=	KDE/${PORTNAME}/${PORTVERSION}
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__comments.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__comments.cpp
new file mode 100644
index 000000000000..ea033e9b1ef8
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__comments.cpp
@@ -0,0 +1,11 @@
+--- core/libs/metadataengine/engine/metaengine_comments.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_comments.cpp
+@@ -64,7 +64,7 @@ bool MetaEngine::canWriteComment(const QString& filePa
+     catch (Exiv2::AnyError& e)
+     {
+         qCCritical(DIGIKAM_METAENGINE_LOG) << "Cannot check Comment access mode with Exiv2 (Error #"
+-                                           << e.code() << ": " << QString::fromStdString(e.what()) << ")";
++                                           << static_cast<int>(e.code()) << ": " << QString::fromStdString(e.what()) << ")";
+     }
+     catch (...)
+     {
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__data__p.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__data__p.cpp
new file mode 100644
index 000000000000..0131c92db68c
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__data__p.cpp
@@ -0,0 +1,11 @@
+--- core/libs/metadataengine/engine/metaengine_data_p.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_data_p.cpp
+@@ -52,7 +52,7 @@ void MetaEngineData::Private::clear()
+     catch (Exiv2::AnyError& e)
+     {
+         qCCritical(DIGIKAM_METAENGINE_LOG) << "Cannot clear data container with Exiv2 "
+-                                           << "(Error #" << e.code() << ": "
++                                           << "(Error #" << static_cast<int>(e.code()) << ": "
+                                            << QString::fromStdString(e.what())
+                                            << ")";
+     }
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__exif.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__exif.cpp
new file mode 100644
index 000000000000..4bf3eb5d4c7f
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__exif.cpp
@@ -0,0 +1,98 @@
+--- core/libs/metadataengine/engine/metaengine_exif.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_exif.cpp
+@@ -80,7 +80,7 @@ bool MetaEngine::canWriteExif(const QString& filePath)
+     catch (Exiv2::AnyError& e)
+     {
+         qCCritical(DIGIKAM_METAENGINE_LOG) << "Cannot check Exif access mode with Exiv2:(Error #"
+-                                           << e.code() << ": " << QString::fromStdString(e.what()) << ")";
++                                           << static_cast<int>(e.code()) << ": " << QString::fromStdString(e.what()) << ")";
+     }
+     catch (...)
+     {
+@@ -739,7 +739,7 @@ bool MetaEngine::getExifTagLong(const char* exifTagNam
+ 
+         if ((it != exifData.end()) && (it->count() > 0))
+         {
+-            val = it->toLong(component);
++            val = it->toInt64(component);
+ 
+             return true;
+         }
+@@ -812,7 +812,7 @@ QVariant MetaEngine::getExifTagVariant(const char* exi
+                 {
+                     if ((int)it->count() > component)
+                     {
+-                        return QVariant((int)it->toLong(component));
++                        return QVariant((int)it->toInt64(component));
+                     }
+                     else
+                     {
+@@ -915,7 +915,7 @@ QString MetaEngine::getExifTagString(const char* exifT
+             QString tagValue;
+             QString key = QLatin1String(it->key().c_str());
+ 
+-            if ((key == QLatin1String("Exif.CanonCs.LensType")) && (it->toLong() == 65535))
++            if ((key == QLatin1String("Exif.CanonCs.LensType")) && (it->toInt64() == 65535))
+             {
+                 // FIXME: workaround for a possible crash in Exiv2 pretty-print function for the Exif.CanonCs.LensType.
+ 
+@@ -987,12 +987,12 @@ QImage MetaEngine::getExifThumbnail(bool fixOrientatio
+         Exiv2::ExifThumbC thumb(d->exifMetadata());
+         Exiv2::DataBuf const c1 = thumb.copy();
+ 
+-        if (c1.size_ == 0)
++        if (c1.size() == 0)
+         {
+             return thumbnail;
+         }
+ 
+-        thumbnail.loadFromData(c1.pData_, c1.size_);
++        thumbnail.loadFromData(c1.c_data(), c1.size());
+ 
+         if (!thumbnail.isNull())
+         {
+@@ -1010,7 +1010,7 @@ QImage MetaEngine::getExifThumbnail(bool fixOrientatio
+ 
+                 if (it != exifData.end() && it->count())
+                 {
+-                    long orientation = it->toLong();
++                    long orientation = it->toInt64();
+ 
+                     //qCDebug(DIGIKAM_METAENGINE_LOG) << "Exif Thumbnail Orientation: " << (int)orientation;
+ 
+@@ -1092,12 +1092,12 @@ bool MetaEngine::setTiffThumbnail(const QImage& thumbI
+ 
+         Exiv2::ExifData::const_iterator pos = d->exifMetadata().findKey(Exiv2::ExifKey("Exif.Image.NewSubfileType"));
+ 
+-        if ((pos == d->exifMetadata().end()) || (pos->count() != 1) || (pos->toLong() != 0))
++        if ((pos == d->exifMetadata().end()) || (pos->count() != 1) || (pos->toInt64() != 0))
+         {
+ 
+ #if EXIV2_TEST_VERSION(0,27,0)
+ 
+-            throw Exiv2::Error(Exiv2::kerErrorMessage, "Exif.Image.NewSubfileType missing or not set as main image");
++            throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.NewSubfileType missing or not set as main image");
+ 
+ #else
+ 
+@@ -1136,9 +1136,9 @@ bool MetaEngine::setTiffThumbnail(const QImage& thumbI
+             Exiv2::DataBuf buf((Exiv2::byte*)data.data(), data.size());
+             Exiv2::ULongValue val;
+             val.read("0");
+-            val.setDataArea(buf.pData_, buf.size_);
++            val.setDataArea(buf.c_data(), buf.size());
+             d->exifMetadata()["Exif.SubImage1.JPEGInterchangeFormat"]       = val;
+-            d->exifMetadata()["Exif.SubImage1.JPEGInterchangeFormatLength"] = uint32_t(buf.size_);
++            d->exifMetadata()["Exif.SubImage1.JPEGInterchangeFormatLength"] = uint32_t(buf.size());
+             d->exifMetadata()["Exif.SubImage1.Compression"]                 = uint16_t(6);          // JPEG (old-style)
+             d->exifMetadata()["Exif.SubImage1.NewSubfileType"]              = uint32_t(1);          // Thumbnail image
+ 
+@@ -1261,7 +1261,7 @@ MetaEngine::MetaDataMap MetaEngine::getExifTagsDataLis
+             {
+                 tagValue = QString::number(md->value().size());
+             }
+-            else if (key == QLatin1String("Exif.CanonCs.LensType") && md->toLong() == 65535)
++            else if (key == QLatin1String("Exif.CanonCs.LensType") && md->toInt64() == 65535)
+             {
+                 // FIXME: workaround for a possible crash in Exiv2 pretty-print function for the Exif.CanonCs.LensType.
+ 
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__iptc.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__iptc.cpp
new file mode 100644
index 000000000000..2d3ccae32866
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__iptc.cpp
@@ -0,0 +1,29 @@
+--- core/libs/metadataengine/engine/metaengine_iptc.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_iptc.cpp
+@@ -29,6 +29,8 @@
+ #include "digikam_debug.h"
+ #include "digikam_config.h"
+ 
++#include <exiv2/photoshop.hpp>
++
+ #if defined(Q_CC_CLANG)
+ #   pragma clang diagnostic push
+ #   pragma clang diagnostic ignored "-Wdeprecated-declarations"
+@@ -65,7 +67,7 @@ bool MetaEngine::canWriteIptc(const QString& filePath)
+     catch (Exiv2::AnyError& e)
+     {
+         qCCritical(DIGIKAM_METAENGINE_LOG) << "Cannot check Iptc access mode with Exiv2:(Error #"
+-                                           << e.code() << ": " << QString::fromStdString(e.what()) << ")";
++                                           << static_cast<int>(e.code()) << ": " << QString::fromStdString(e.what()) << ")";
+     }
+     catch (...)
+     {
+@@ -121,7 +123,7 @@ QByteArray MetaEngine::getIptc(bool addIrbHeader) cons
+                 c2 = Exiv2::IptcParser::encode(d->iptcMetadata());
+             }
+ 
+-            QByteArray data((const char*)c2.pData_, c2.size_);
++            QByteArray data(reinterpret_cast<const char *>(c2.c_data()), c2.size());
+ 
+             return data;
+         }
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__item.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__item.cpp
new file mode 100644
index 000000000000..b28099023389
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__item.cpp
@@ -0,0 +1,65 @@
+--- core/libs/metadataengine/engine/metaengine_item.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_item.cpp
+@@ -127,7 +127,7 @@ QSize MetaEngine::getItemDimensions() const
+ 
+         if ((it != exifData.end()) && it->count())
+         {
+-            width = it->toLong();
++            width = it->toInt64();
+         }
+ 
+         Exiv2::ExifKey key2("Exif.Photo.PixelYDimension");
+@@ -135,7 +135,7 @@ QSize MetaEngine::getItemDimensions() const
+ 
+         if ((it2 != exifData.end()) && it2->count())
+         {
+-            height = it2->toLong();
++            height = it2->toInt64();
+         }
+ 
+         if ((width != -1) && (height != -1))
+@@ -153,7 +153,7 @@ QSize MetaEngine::getItemDimensions() const
+ 
+         if ((it3 != exifData.end()) && it3->count())
+         {
+-            width = it3->toLong();
++            width = it3->toInt64();
+         }
+ 
+         Exiv2::ExifKey key4("Exif.Image.ImageLength");
+@@ -161,7 +161,7 @@ QSize MetaEngine::getItemDimensions() const
+ 
+         if ((it4 != exifData.end()) && it4->count())
+         {
+-            height = it4->toLong();
++            height = it4->toInt64();
+         }
+ 
+         if ((width != -1) && (height != -1))
+@@ -320,7 +320,7 @@ MetaEngine::ImageOrientation MetaEngine::getItemOrient
+ 
+         if ((it != exifData.end()) && it->count())
+         {
+-            orientation = it->toLong();
++            orientation = it->toInt64();
+ 
+             //qCDebug(DIGIKAM_METAENGINE_LOG) << "Orientation => Exif.MinoltaCs7D.Rotation =>" << (int)orientation;
+ 
+@@ -347,7 +347,7 @@ MetaEngine::ImageOrientation MetaEngine::getItemOrient
+ 
+         if ((it != exifData.end()) && it->count())
+         {
+-            orientation = it->toLong();
++            orientation = it->toInt64();
+ 
+             //qCDebug(DIGIKAM_METAENGINE_LOG) << "Orientation => Exif.MinoltaCs5D.Rotation =>" << (int)orientation;
+ 
+@@ -376,7 +376,7 @@ MetaEngine::ImageOrientation MetaEngine::getItemOrient
+ 
+         if ((it != exifData.end()) && it->count())
+         {
+-            orientation = it->toLong();
++            orientation = it->toInt64();
+ 
+             //qCDebug(DIGIKAM_METAENGINE_LOG) << "Orientation => Exif.Image.Orientation =>" << (int)orientation;
+ 
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__p.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__p.cpp
new file mode 100644
index 000000000000..722990b80fc4
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__p.cpp
@@ -0,0 +1,11 @@
+--- core/libs/metadataengine/engine/metaengine_p.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_p.cpp
+@@ -542,7 +542,7 @@ bool MetaEngine::Private::saveOperations(const QFileIn
+ void MetaEngine::Private::printExiv2ExceptionError(const QString& msg, Exiv2::AnyError& e)
+ {
+     qCCritical(DIGIKAM_METAENGINE_LOG) << msg.toLatin1().constData()
+-                                       << " (Error #" << e.code() << ": " << QString::fromStdString(e.what());
++                                       << " (Error #" << static_cast<int>(e.code()) << ": " << QString::fromStdString(e.what());
+ }
+ 
+ void MetaEngine::Private::printExiv2MessageHandler(int lvl, const char* msg)
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__p.h b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__p.h
new file mode 100644
index 000000000000..a32ff29c2b30
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__p.h
@@ -0,0 +1,22 @@
+--- core/libs/metadataengine/engine/metaengine_p.h.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_p.h
+@@ -90,6 +90,10 @@
+          ( EXIV2_VERSION >= EXIV2_MAKE_VERSION(major,minor,patch) )
+ #endif
+ 
++#if EXIV2_TEST_VERSION(0,28,0)
++#   define AnyError Error
++#endif
++
+ #if EXIV2_TEST_VERSION(0,27,99)
+ #   define AutoPtr UniquePtr
+ #endif
+@@ -182,7 +186,7 @@ class Q_DECL_HIDDEN MetaEngine::Private (public)
+      * Generic method to print the Exiv2 C++ Exception error message from 'e'.
+      * 'msg' string is printed using qDebug rules.
+      */
+-    static void printExiv2ExceptionError(const QString& msg, Exiv2::AnyError& e);
++    static void printExiv2ExceptionError(const QString& msg, Exiv2::Error& e);
+ 
+     /**
+      * Generic method to print debug message from Exiv2.
diff --git a/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__xmp.cpp b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__xmp.cpp
new file mode 100644
index 000000000000..285ef0ed2e5a
--- /dev/null
+++ b/graphics/digikam/files/patch-core_libs_metadataengine_engine_metaengine__xmp.cpp
@@ -0,0 +1,20 @@
+--- core/libs/metadataengine/engine/metaengine_xmp.cpp.orig	2023-03-12 13:19:02 UTC
++++ core/libs/metadataengine/engine/metaengine_xmp.cpp
+@@ -67,7 +67,7 @@ bool MetaEngine::canWriteXmp(const QString& filePath)
+     catch (Exiv2::AnyError& e)
+     {
+         qCCritical(DIGIKAM_METAENGINE_LOG) << "Cannot check Xmp access mode with Exiv2:(Error #"
+-                                           << e.code() << ": " << QString::fromStdString(e.what()) << ")";
++                                           << static_cast<int>(e.code()) << ": " << QString::fromStdString(e.what()) << ")";
+     }
+     catch (...)
+     {
+@@ -1014,7 +1014,7 @@ QVariant MetaEngine::getXmpTagVariant(const char* xmpT
+                 case Exiv2::signedShort:
+                 case Exiv2::signedLong:
+                 {
+-                    return QVariant((int)it->toLong());
++                    return QVariant((int)it->toInt64());
+                 }
+ 
+                 case Exiv2::unsignedRational: