File indexing completed on 2025-03-09 03:50:50

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-12-23
0007  * Description : Autodetect enfuse binary program and version
0008  *
0009  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2012-2015 by Benjamin Girault <benjamin dot girault at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "enfusebinary.h"
0017 
0018 // Local includes
0019 
0020 #include "digikam_debug.h"
0021 
0022 namespace DigikamGenericExpoBlendingPlugin
0023 {
0024 
0025 double EnfuseBinary::getVersion() const
0026 {
0027     return versionDouble;
0028 }
0029 
0030 bool EnfuseBinary::parseHeader(const QString& output)
0031 {
0032     // Work around Enfuse <= 3.2
0033     // The output look like this : ==== enfuse, version 3.2 ====
0034     QString headerStartsOld = QLatin1String("==== enfuse, version ");
0035     QString firstLine = output.section(QLatin1Char('\n'), m_headerLine, m_headerLine);
0036 
0037     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << path() << " help header line: \n" << firstLine;
0038 
0039     if (firstLine.startsWith(m_headerStarts))
0040     {
0041         setVersion(firstLine.remove(0, m_headerStarts.length()));
0042         QStringList versionList = version().split(QLatin1Char('.'));
0043         versionList.removeLast();
0044         versionDouble = versionList.join(QLatin1Char('.')).toDouble();
0045         Q_EMIT signalEnfuseVersion(versionDouble);
0046         qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Found " << path() << " version: " << version();
0047         return true;
0048     }
0049     else if (firstLine.startsWith(headerStartsOld))
0050     {
0051         setVersion(firstLine.remove(0, headerStartsOld.length()));
0052         QStringList versionList = version().split(QLatin1Char('.'));
0053         versionList.removeLast();
0054         versionDouble = versionList.join(QLatin1Char('.')).toDouble();
0055         Q_EMIT signalEnfuseVersion(versionDouble);
0056         qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Found " << path() << " version: " << version();
0057         return true;
0058     }
0059 
0060     return false;
0061 }
0062 
0063 } // namespace DigikamGenericExpoBlendingPlugin
0064 
0065 #include "moc_enfusebinary.cpp"