File indexing completed on 2024-05-12 15:59:59

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2004 Nicolas GOUTTE <goutte@kde.org>
0003    
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef __koStore_p_h_
0008 #define __koStore_p_h_
0009 
0010 
0011 #include "KoStore.h"
0012 
0013 #include <QStringList>
0014 #include <QStack>
0015 
0016 #include <QUrl>
0017 
0018 class QWidget;
0019 
0020 class KoStorePrivate
0021 {
0022 public:
0023     explicit KoStorePrivate(KoStore *qq, KoStore::Mode _mode, bool _writeMimetype)
0024         : q(qq),
0025         window(0),
0026         mode(_mode),
0027         size(0),
0028         stream(0),
0029         isOpen(false),
0030         good(false),
0031         finalized(false),
0032         writeMimetype(_writeMimetype)
0033     {
0034     }
0035 
0036     /**
0037      * Conversion routine
0038      * @param internalNaming name used internally : "root", "tar:/0", ...
0039      * @return the name used in the file, more user-friendly ("maindoc.xml",
0040      *         "part0/maindoc.xml", ...)
0041      * Examples:
0042      *
0043      * tar:/0 is saved as part0/maindoc.xml
0044      * tar:/0/1 is saved as part0/part1/maindoc.xml
0045      * tar:/0/1/pictures/picture0.png is saved as part0/part1/pictures/picture0.png
0046      *
0047      * see specification (calligra/lib/store/SPEC) for details.
0048      */
0049     QString toExternalNaming(const QString &internalNaming) const;
0050 
0051     /**
0052      * Enter *one* single directory. Nothing like foo/bar/bleh allowed.
0053      * Performs some checking when in Read mode
0054      */
0055     bool enterDirectoryInternal(const QString &directory);
0056 
0057     bool extractFile(const QString &sourceName, QIODevice &buffer);
0058 
0059     KoStore *q;
0060 
0061     QString localFileName;
0062     QWidget *window;
0063 
0064     KoStore::Mode mode;
0065 
0066     /// Store the filenames (with full path inside the archive) when writing, to avoid duplicates
0067     QStringList filesList;
0068 
0069     /// The "current directory" (path)
0070     QStringList currentPath;
0071 
0072     /// Current filename (between an open() and a close())
0073     QString fileName;
0074     /// Current size of the file named m_sName
0075     qint64 size;
0076 
0077     /// The stream for the current read or write operation
0078     QIODevice *stream;
0079 
0080     bool isOpen;
0081     /// Must be set by the constructor.
0082     bool good;
0083     bool finalized;
0084 
0085     QStack<QString> directoryStack;
0086 
0087     bool writeMimetype; ///< true if the backend is allowed to create "mimetype" automatically.
0088 
0089     QString substituteThis;
0090     QString substituteWith;
0091 
0092     QUrl url;
0093 };
0094 
0095 #endif