1/***************************************************************************
2 * Copyright (C) 2008 by Jakub Stachowski <qbast@go2.pl> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
9
10#ifndef MOBIPOCKET_H
11#define MOBIPOCKET_H
12
13#include <QString>
14#include <QByteArray>
15#include <QMap>
16#include <QImage>
17
18#include "qmobipocket_export.h"
19
20class QIODevice;
21
22namespace Mobipocket {
23
24/**
25Minimalistic stream abstraction. It is supposed to allow mobipocket document classes to be
26used with QIODevice (for Okular generator), and previously also with InputStream for Strigi
27analyzer.
28*/
29class QMOBIPOCKET_EXPORT Stream {
30public:
31 virtual int read(char* buf, int size)=0;
32 virtual bool seek(int pos)=0;
33
34 QByteArray readAll();
35 QByteArray read(int len);
36 virtual ~Stream() {}
37};
38
39struct PDBPrivate;
40class PDB {
41public:
42 PDB(Stream* s);
43 ~PDB();
44 QString fileType() const;
45 int recordCount() const;
46 QByteArray getRecord(int i) const;
47 bool isValid() const;
48private:
49 PDBPrivate* const d;
50};
51
52struct DocumentPrivate;
53class QMOBIPOCKET_EXPORT Document {
54public:
55 enum MetaKey { Title, Author, Copyright, Description, Subject };
56 ~Document();
57 Document(Stream* s);
58 QMap<MetaKey,QString> metadata() const;
59 QString text(int size=-1) const;
60 int imageCount() const;
61 QImage getImage(int i) const;
62 QImage thumbnail() const;
63 bool isValid() const;
64
65 // if true then it is impossible to get text of book. Images should still be readable
66 bool hasDRM() const;
67private:
68 DocumentPrivate* const d;
69};
70}
71#endif
72

source code of kdegraphics-mobipocket/lib/mobipocket.h