File indexing completed on 2024-05-12 12:18:47
0001 /*************************************************************************** 0002 * Copyright (C) 2008 by Jakub Stachowski <qbast@go2.pl> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 ***************************************************************************/ 0009 0010 #ifndef MOBIPOCKET_H 0011 #define MOBIPOCKET_H 0012 0013 #include <QString> 0014 #include <QByteArray> 0015 #include <QMap> 0016 #include <QImage> 0017 0018 #include "qmobipocket_export.h" 0019 0020 class QIODevice; 0021 0022 namespace Mobipocket { 0023 0024 /** 0025 Minimalistic stream abstraction. It is supposed to allow mobipocket document classes to be 0026 used with QIODevice (for Okular generator), and previously also with InputStream for Strigi 0027 analyzer. 0028 */ 0029 class QMOBIPOCKET_EXPORT Stream { 0030 public: 0031 virtual int read(char* buf, int size)=0; 0032 virtual bool seek(int pos)=0; 0033 0034 QByteArray readAll(); 0035 QByteArray read(int len); 0036 virtual ~Stream() {} 0037 }; 0038 0039 struct PDBPrivate; 0040 class PDB { 0041 public: 0042 PDB(Stream* s); 0043 ~PDB(); 0044 QString fileType() const; 0045 int recordCount() const; 0046 QByteArray getRecord(int i) const; 0047 bool isValid() const; 0048 private: 0049 PDBPrivate* const d; 0050 }; 0051 0052 struct DocumentPrivate; 0053 class QMOBIPOCKET_EXPORT Document { 0054 public: 0055 enum MetaKey { Title, Author, Copyright, Description, Subject }; 0056 ~Document(); 0057 Document(Stream* s); 0058 QMap<MetaKey,QString> metadata() const; 0059 QString text(int size=-1) const; 0060 int imageCount() const; 0061 QImage getImage(int i) const; 0062 QImage thumbnail() const; 0063 bool isValid() const; 0064 0065 // if true then it is impossible to get text of book. Images should still be readable 0066 bool hasDRM() const; 0067 private: 0068 DocumentPrivate* const d; 0069 }; 0070 } 0071 #endif