File indexing completed on 2024-05-26 04:37:15
0001 /* 0002 SPDX-FileCopyrightText: 2005 Georgy Yunaev <tim@krasnogorsk.ru> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef MSITS_H 0008 #define MSITS_H 0009 0010 #include <QUrl> 0011 #include <kio/slavebase.h> 0012 0013 #include <QByteArray> 0014 #include <QString> 0015 0016 #include "chm_lib.h" 0017 0018 class ProtocolMSITS : public KIO::SlaveBase 0019 { 0020 public: 0021 ProtocolMSITS(const QByteArray &, const QByteArray &); 0022 ~ProtocolMSITS() override; 0023 0024 ProtocolMSITS(const ProtocolMSITS &) = delete; 0025 ProtocolMSITS &operator=(const ProtocolMSITS &) = delete; 0026 0027 void get(const QUrl &) override; 0028 void listDir(const QUrl &url) override; 0029 void stat(const QUrl &url) override; 0030 0031 private: 0032 // This function does next thing: 0033 // - parses the URL to get a file name and URL inside the file; 0034 // - loads a new CHM file, if needed; 0035 // - returns the parsed URL inside the file; 0036 bool parseLoadAndLookup(const QUrl &, QString &abspath); 0037 0038 // Resolve an object inside a CHM file 0039 inline bool ResolveObject(const QString &fileName, chmUnitInfo *ui) 0040 { 0041 return m_chmFile != nullptr && ::chm_resolve_object(m_chmFile, fileName.toUtf8().constData(), ui) == CHM_RESOLVE_SUCCESS; 0042 } 0043 0044 // Retrieve an object from the CHM file 0045 inline size_t RetrieveObject(chmUnitInfo *ui, unsigned char *buffer, LONGUINT64 fileOffset, LONGINT64 bufferSize) 0046 { 0047 return ::chm_retrieve_object(m_chmFile, ui, buffer, fileOffset, bufferSize); 0048 } 0049 0050 // An opened file name, if presend 0051 QString m_openedFile; 0052 0053 // a CHM structure file pointer (from chmlib) 0054 chmFile *m_chmFile; 0055 }; 0056 0057 #endif /* MSITS_H */