Commit 47b69ef8 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

use libkexiv2 debug space

parent 6bcc7cb1
......@@ -31,6 +31,7 @@
// Local includes
#include "libkexiv2_version.h"
#include "libkexiv2_debug.h"
namespace KExiv2Iface
{
......@@ -159,10 +160,12 @@ QString KExiv2::version()
QString KExiv2::sidecarFilePathForFile(const QString& path)
{
QString ret;
if (!path.isEmpty())
{
ret = path + QString(".xmp");
}
return ret;
}
......@@ -257,7 +260,7 @@ bool KExiv2::loadFromData(const QByteArray& imgData) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -313,7 +316,7 @@ bool KExiv2::load(const QString& filePath) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
#ifdef _XMP_SUPPORT_
......@@ -344,7 +347,7 @@ bool KExiv2::load(const QString& filePath) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
#endif // _XMP_SUPPORT_
......@@ -373,7 +376,7 @@ bool KExiv2::save(const QString& imageFilePath) const
if (givenFileInfo.isSymLink())
{
qDebug() << "filePath" << imageFilePath << "is a symlink."
qCDebug(LIBKEXIV2_LOG) << "filePath" << imageFilePath << "is a symlink."
<< "Using target" << givenFileInfo.canonicalPath();
regularFilePath = givenFileInfo.canonicalPath();// Walk all the symlinks
......@@ -385,7 +388,7 @@ bool KExiv2::save(const QString& imageFilePath) const
if (!dinfo.isWritable())
{
qDebug() << "Dir '" << dinfo.filePath() << "' is read-only. Metadata not saved.";
qCDebug(LIBKEXIV2_LOG) << "Dir '" << dinfo.filePath() << "' is read-only. Metadata not saved.";
return false;
}
......@@ -395,7 +398,7 @@ bool KExiv2::save(const QString& imageFilePath) const
bool writtenToFile = false;
bool writtenToSidecar = false;
qDebug() << "KExiv2::metadataWritingMode" << d->metadataWritingMode;
qCDebug(LIBKEXIV2_LOG) << "KExiv2::metadataWritingMode" << d->metadataWritingMode;
switch(d->metadataWritingMode)
{
......@@ -417,23 +420,23 @@ bool KExiv2::save(const QString& imageFilePath) const
if (writeToFile)
{
qDebug() << "Will write Metadata to file" << finfo.fileName();
qCDebug(LIBKEXIV2_LOG) << "Will write Metadata to file" << finfo.fileName();
writtenToFile = d->saveToFile(finfo);
if (writeToFile)
{
qDebug() << "Metadata for file" << finfo.fileName() << "written to file.";
qCDebug(LIBKEXIV2_LOG) << "Metadata for file" << finfo.fileName() << "written to file.";
}
}
if (writeToSidecar || (writeToSidecarIfFileNotPossible && !writtenToFile))
{
qDebug() << "Will write XMP sidecar for file" << givenFileInfo.fileName();
qCDebug(LIBKEXIV2_LOG) << "Will write XMP sidecar for file" << givenFileInfo.fileName();
writtenToSidecar = d->saveToXMPSidecar(imageFilePath);
if (writtenToSidecar)
{
qDebug() << "Metadata for file '" << givenFileInfo.fileName() << "' written to XMP sidecar.";
qCDebug(LIBKEXIV2_LOG) << "Metadata for file '" << givenFileInfo.fileName() << "' written to XMP sidecar.";
}
}
......@@ -444,7 +447,7 @@ bool KExiv2::applyChanges() const
{
if (d->filePath.isEmpty())
{
qDebug() << "Failed to apply changes: file path is empty!";
qCDebug(LIBKEXIV2_LOG) << "Failed to apply changes: file path is empty!";
return false;
}
......
......@@ -39,6 +39,10 @@ extern "C"
#include <QTextCodec>
// Local includes
#include "libkexiv2_debug.h"
namespace KExiv2Iface
{
......@@ -89,7 +93,7 @@ bool KExiv2::Private::saveToXMPSidecar(const QFileInfo& finfo) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
return false;
}
}
......@@ -98,7 +102,7 @@ bool KExiv2::Private::saveToFile(const QFileInfo& finfo) const
{
if (!finfo.isWritable())
{
qDebug() << "File '" << finfo.fileName().toLatin1().constData() << "' is read only. Metadata not written.";
qCDebug(LIBKEXIV2_LOG) << "File '" << finfo.fileName().toLatin1().constData() << "' is read only. Metadata not written.";
return false;
}
......@@ -126,28 +130,28 @@ bool KExiv2::Private::saveToFile(const QFileInfo& finfo) const
if (!writeRawFiles && (rawTiffBasedSupported.contains(ext) || rawTiffBasedNotSupported.contains(ext)) )
{
qDebug() << finfo.fileName()
<< "is a TIFF based RAW file, writing to such a file is disabled by current settings.";
qCDebug(LIBKEXIV2_LOG) << finfo.fileName()
<< "is a TIFF based RAW file, writing to such a file is disabled by current settings.";
return false;
}
/*
if (rawTiffBasedNotSupported.contains(ext))
{
qDebug() << finfo.fileName()
<< "is TIFF based RAW file not yet supported. Metadata not saved.";
qCDebug(LIBKEXIV2_LOG) << finfo.fileName()
<< "is TIFF based RAW file not yet supported. Metadata not saved.";
return false;
}
if (rawTiffBasedSupported.contains(ext) && !writeRawFiles)
{
qDebug() << finfo.fileName()
<< "is TIFF based RAW file supported but writing mode is disabled. "
<< "Metadata not saved.";
qCDebug(LIBKEXIV2_LOG) << finfo.fileName()
<< "is TIFF based RAW file supported but writing mode is disabled. "
<< "Metadata not saved.";
return false;
}
qDebug() << "File Extension: " << ext << " is supported for writing mode";
qCDebug(LIBKEXIV2_LOG) << "File Extension: " << ext << " is supported for writing mode";
bool ret = false;
*/
......@@ -165,7 +169,7 @@ bool KExiv2::Private::saveToFile(const QFileInfo& finfo) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
return false;
}
}
......@@ -176,7 +180,7 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
{
Exiv2::AccessMode mode;
bool wroteComment = false, wroteEXIF = false, wroteIPTC = false, wroteXMP = false;
// We need to load target file metadata to merge with new one. It's mandatory with TIFF format:
// like all tiff file structure is based on Exif.
image->readMetadata();
......@@ -191,7 +195,7 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
wroteComment = true;
}
qDebug() << "wroteComment: " << wroteComment;
qCDebug(LIBKEXIV2_LOG) << "wroteComment: " << wroteComment;
// Exif metadata ----------------------------------
......@@ -251,7 +255,7 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
wroteEXIF = true;
}
qDebug() << "wroteEXIF: " << wroteEXIF;
qCDebug(LIBKEXIV2_LOG) << "wroteEXIF: " << wroteEXIF;
// Iptc metadata ----------------------------------
......@@ -263,7 +267,7 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
wroteIPTC = true;
}
qDebug() << "wroteIPTC: " << wroteIPTC;
qCDebug(LIBKEXIV2_LOG) << "wroteIPTC: " << wroteIPTC;
// Xmp metadata -----------------------------------
......@@ -277,16 +281,16 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
#endif
}
qDebug() << "wroteXMP: " << wroteXMP;
qCDebug(LIBKEXIV2_LOG) << "wroteXMP: " << wroteXMP;
if (!wroteComment && !wroteEXIF && !wroteIPTC && !wroteXMP)
{
qDebug() << "Writing metadata is not supported for file" << finfo.fileName();
qCDebug(LIBKEXIV2_LOG) << "Writing metadata is not supported for file" << finfo.fileName();
return false;
}
else if (!wroteEXIF || !wroteIPTC || !wroteXMP)
{
qDebug() << "Support for writing metadata is limited for file" << finfo.fileName();
qCDebug(LIBKEXIV2_LOG) << "Support for writing metadata is limited for file" << finfo.fileName();
}
if (!updateFileTimeStamp)
......@@ -308,8 +312,8 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
{
::utime(QFile::encodeName(filePath).constData(), &ut);
}
qDebug() << "File time stamp restored";
qCDebug(LIBKEXIV2_LOG) << "File time stamp restored";
}
else
{
......@@ -324,7 +328,7 @@ bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoP
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -343,13 +347,13 @@ void KExiv2Data::Private::clear()
void KExiv2::Private::printExiv2ExceptionError(const QString& msg, Exiv2::Error& e)
{
std::string s(e.what());
qCritical() << msg.toLatin1().constData() << " (Error #"
qCCritical(LIBKEXIV2_LOG) << msg.toLatin1().constData() << " (Error #"
<< e.code() << ": " << s.c_str();
}
void KExiv2::Private::printExiv2MessageHandler(int lvl, const char* msg)
{
qDebug() << "Exiv2 (" << lvl << ") : " << msg;
qCDebug(LIBKEXIV2_LOG) << "Exiv2 (" << lvl << ") : " << msg;
}
QString KExiv2::Private::convertCommentValue(const Exiv2::Exifdatum& exifDatum) const
......@@ -383,7 +387,7 @@ QString KExiv2::Private::convertCommentValue(const Exiv2::Exifdatum& exifDatum)
}
else if (charset == "\"Jis\"")
{
QTextCodec* codec = QTextCodec::codecForName("JIS7");
QTextCodec* const codec = QTextCodec::codecForName("JIS7");
return codec->toUnicode(comment.c_str());
}
else if (charset == "\"Ascii\"")
......@@ -401,7 +405,7 @@ QString KExiv2::Private::convertCommentValue(const Exiv2::Exifdatum& exifDatum)
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QString();
......
......@@ -48,7 +48,6 @@
#include <QLatin1String>
#include <QFileInfo>
#include <QSharedData>
#include <QDebug>
// KDE includes
......
......@@ -29,6 +29,7 @@
#include "kexiv2_p.h"
#include "kexiv2.h"
#include "libkexiv2_debug.h"
namespace KExiv2Iface
{
......@@ -46,12 +47,12 @@ bool KExiv2::canWriteComment(const QString& filePath)
catch( Exiv2::Error& e )
{
std::string s(e.what());
qCritical() << "Cannot check Comment access mode using Exiv2 (Error #"
<< e.code() << ": " << s.c_str() << ")";
qCCritical(LIBKEXIV2_LOG) << "Cannot check Comment access mode using Exiv2 (Error #"
<< e.code() << ": " << s.c_str() << ")";
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -90,6 +91,7 @@ QString KExiv2::detectLanguageAlt(const QString& value, QString& lang)
if (value.size() > 6 && value.startsWith(QString("lang=\"")))
{
int pos = value.indexOf(QString("\""), 6);
if (pos != -1)
{
lang = value.mid(6, pos-6);
......
......@@ -28,7 +28,7 @@
#ifndef KEXIV2DATA_H
#define KEXIV2DATA_H
// QT includes
// Qt includes
#include <QSharedDataPointer>
......
......@@ -27,7 +27,6 @@
#include "kexiv2.h"
#include "kexiv2_p.h"
#include "rotationmatrix.h"
// C++ includes
......@@ -40,7 +39,12 @@
// KDE includes
#include <KLocalizedString>
#include <klocalizedstring.h>
// Local includes
#include "rotationmatrix.h"
#include "libkexiv2_debug.h"
namespace KExiv2Iface
{
......@@ -59,12 +63,12 @@ bool KExiv2::canWriteExif(const QString& filePath)
catch( Exiv2::Error& e )
{
std::string s(e.what());
qCritical() << "Cannot check Exif access mode using Exiv2 (Error #"
qCCritical(LIBKEXIV2_LOG) << "Cannot check Exif access mode using Exiv2 (Error #"
<< e.code() << ": " << s.c_str() << ")";
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -88,7 +92,7 @@ bool KExiv2::clearExif() const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -123,13 +127,13 @@ QByteArray KExiv2::getExifEncoded(bool addExifHeader) const
catch( Exiv2::Error& e )
{
if (!d->filePath.isEmpty())
qDebug() << "From file " << d->filePath.toLatin1().constData();
qCDebug(LIBKEXIV2_LOG) << "From file " << d->filePath.toLatin1().constData();
d->printExiv2ExceptionError("Cannot get Exif data using Exiv2 ", e);
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QByteArray();
......@@ -148,13 +152,13 @@ bool KExiv2::setExif(const QByteArray& data) const
catch( Exiv2::Error& e )
{
if (!d->filePath.isEmpty())
qCritical() << "From file " << d->filePath.toLatin1().constData();
qCCritical(LIBKEXIV2_LOG) << "From file " << d->filePath.toLatin1().constData();
d->printExiv2ExceptionError("Cannot set Exif data using Exiv2 ", e);
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -228,7 +232,7 @@ KExiv2::MetaDataMap KExiv2::getExifTagsDataList(const QStringList& exifKeysFilte
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return MetaDataMap();
......@@ -280,7 +284,7 @@ QString KExiv2::getExifComment() const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QString();
......@@ -344,7 +348,7 @@ bool KExiv2::setExifComment(const QString& comment, bool setProgramName) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -365,7 +369,7 @@ QString KExiv2::getExifTagTitle(const char* exifTagName)
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QString();
......@@ -386,7 +390,7 @@ QString KExiv2::getExifTagDescription(const char* exifTagName)
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QString();
......@@ -414,7 +418,7 @@ bool KExiv2::removeExifTag(const char* exifTagName, bool setProgramName) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -443,7 +447,7 @@ bool KExiv2::getExifTagRational(const char* exifTagName, long int& num, long int
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -465,7 +469,7 @@ bool KExiv2::setExifTagLong(const char* exifTagName, long val, bool setProgramNa
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -487,7 +491,7 @@ bool KExiv2::setExifTagRational(const char* exifTagName, long int num, long int
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -513,7 +517,7 @@ bool KExiv2::setExifTagData(const char* exifTagName, const QByteArray& data, boo
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -578,7 +582,7 @@ bool KExiv2::setExifTagVariant(const char* exifTagName, const QVariant& val,
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -675,7 +679,7 @@ QString KExiv2::createExifUserStringFromValue(const char* exifTagName, const QVa
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QString();
......@@ -707,7 +711,7 @@ bool KExiv2::getExifTagLong(const char* exifTagName, long& val, int component) c
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -738,7 +742,7 @@ QByteArray KExiv2::getExifTagData(const char* exifTagName) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QByteArray();
......@@ -824,7 +828,7 @@ QVariant KExiv2::getExifTagVariant(const char* exifTagName, bool rationalAsListO
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QVariant();
......@@ -857,7 +861,7 @@ QString KExiv2::getExifTagString(const char* exifTagName, bool escapeCR) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return QString();
......@@ -879,7 +883,7 @@ bool KExiv2::setExifTagString(const char* exifTagName, const QString& value, boo
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -913,7 +917,7 @@ QImage KExiv2::getExifThumbnail(bool fixOrientation) const
if (it != exifData.end() && it->count())
{
long orientation = it->toLong();
qDebug() << "Exif Thumbnail Orientation: " << (int)orientation;
qCDebug(LIBKEXIV2_LOG) << "Exif Thumbnail Orientation: " << (int)orientation;
rotateExifQImage(thumbnail, (ImageOrientation)orientation);
}
......@@ -927,7 +931,7 @@ QImage KExiv2::getExifThumbnail(bool fixOrientation) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return thumbnail;
......@@ -972,7 +976,7 @@ bool KExiv2::setExifThumbnail(const QImage& thumbImage, bool setProgramName) con
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -1031,7 +1035,7 @@ bool KExiv2::setTiffThumbnail(const QImage& thumbImage, bool setProgramName) con
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -1052,7 +1056,7 @@ bool KExiv2::removeExifThumbnail() const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -1104,7 +1108,7 @@ KExiv2::TagsMap KExiv2::getStdExifTagsList() const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return TagsMap();
......@@ -1157,7 +1161,7 @@ KExiv2::TagsMap KExiv2::getMakernoteTagsList() const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return TagsMap();
......
......@@ -39,6 +39,10 @@
#include <climits>
#include <cmath>
// Local includes
#include "libkexiv2_debug.h"
namespace KExiv2Iface
{
......@@ -134,7 +138,7 @@ bool KExiv2::getGPSLatitudeNumber(double* const latitude) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -230,7 +234,7 @@ bool KExiv2::getGPSLongitudeNumber(double* const longitude) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
......@@ -304,7 +308,7 @@ bool KExiv2::getGPSAltitude(double* const altitude) const
}
catch(...)
{
qCritical() << "Default exception from Exiv2";