File indexing completed on 2024-04-28 04:58:02

0001 /**
0002  * This file is part of the KDE libraries
0003  *
0004  * Comic Book Thumbnailer for KDE 4 v0.1
0005  * Creates cover page previews for comic-book files (.cbr/z/t).
0006  * SPDX-FileCopyrightText: 2009 Harsh J <harsh@harshj.com>
0007  *
0008  * Some code borrowed from Okular's comicbook generators,
0009  * by Tobias Koenig <tokoe@kde.org>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0012  */
0013 
0014 // comiccreator.h
0015 
0016 #ifndef COMIC_CREATOR_H
0017 #define COMIC_CREATOR_H
0018 
0019 #include <KIO/ThumbnailCreator>
0020 
0021 #include <QByteArray>
0022 #include <QImage>
0023 #include <QObject>
0024 #include <QStringList>
0025 
0026 class KArchiveDirectory;
0027 class QEventLoop;
0028 
0029 class ComicCreator : public KIO::ThumbnailCreator
0030 {
0031     Q_OBJECT
0032 public:
0033     ComicCreator(QObject *parent, const QVariantList &args);
0034     KIO::ThumbnailResult create(const KIO::ThumbnailRequest &request) override;
0035 
0036 private:
0037     enum Type { ZIP, TAR, RAR, SEVENZIP };
0038     void filterImages(QStringList &entries);
0039     int runProcess(const QString &processPath, const QStringList &args);
0040 
0041     // For "zip" and "tar" type files.
0042     // Uses KDE's internal archive classes.
0043     QImage extractArchiveImage(const QString &path, const ComicCreator::Type);
0044     void getArchiveFileList(QStringList &entries, const QString &prefix, const KArchiveDirectory *dir);
0045 
0046     // For "rar" type files.
0047     // Uses the non-free 'unrar' executable, if available.
0048     QImage extractRARImage(const QString &path);
0049     QString unrarPath() const;
0050     QStringList getRARFileList(const QString &path, const QString &unrarPath);
0051 
0052 private:
0053     QByteArray m_stdOut;
0054 };
0055 
0056 #endif