Diffstat (limited to 'noncore/apps/opie-reader/ebookcodec.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ebookcodec.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/noncore/apps/opie-reader/ebookcodec.h b/noncore/apps/opie-reader/ebookcodec.h index f6e2daf..4229fb9 100644 --- a/noncore/apps/opie-reader/ebookcodec.h +++ b/noncore/apps/opie-reader/ebookcodec.h | |||
@@ -1,118 +1,131 @@ | |||
1 | #include "CExpander.h" | 1 | #include "CExpander.h" |
2 | 2 | ||
3 | #include <qfileinfo.h> | 3 | #include <qfileinfo.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | 5 | ||
6 | #ifdef USEQPE | 6 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | #include "util.h" | ||
11 | |||
12 | #ifndef __STATIC | 10 | #ifndef __STATIC |
13 | #include <dlfcn.h> | 11 | #include <dlfcn.h> |
14 | class ebookcodec : public CExpander_Interface | 12 | class ebookcodec : public CExpander_Interface |
15 | { | 13 | { |
16 | CExpander *codec; | 14 | CExpander *codec; |
17 | void *handle; | 15 | void *handle; |
18 | int status; | 16 | int status; |
19 | public: | 17 | public: |
18 | QString getTableAsHtml(unsigned long loc) { return codec->getTableAsHtml(loc); } | ||
20 | QString about() | 19 | QString about() |
21 | { | 20 | { |
22 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); | 21 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); |
23 | } | 22 | } |
24 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) | 23 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) |
25 | { | 24 | { |
26 | QString codecpath(QTReaderUtil::getPluginPath()); | 25 | #ifdef USEQPE |
26 | #ifdef OPIE | ||
27 | QString codecpath(getenv("OPIEDIR")); | ||
28 | #else | ||
29 | QString codecpath(getenv("QTDIR")); | ||
30 | #endif | ||
31 | codecpath += "/plugins/reader/codecs/"; | ||
32 | #else | ||
33 | QString codecpath(getenv("READERDIR")); | ||
34 | codecpath += "/codecs/"; | ||
35 | #endif | ||
27 | codecpath += _s; | 36 | codecpath += _s; |
28 | if (QFile::exists(codecpath)) | 37 | if (QFile::exists(codecpath)) |
29 | { | 38 | { |
30 | qDebug("Codec:%s", (const char*)codecpath); | 39 | qDebug("Codec:%s", (const char*)codecpath); |
31 | handle = dlopen(codecpath, RTLD_LAZY); | 40 | handle = dlopen(codecpath, RTLD_LAZY); |
32 | if (handle == 0) | 41 | if (handle == 0) |
33 | { | 42 | { |
34 | /* | 43 | /* |
35 | QString wrn(dlerror()); | 44 | QString wrn(dlerror()); |
36 | QString fmt; | 45 | QString fmt; |
37 | while (wrn.length() > 10) | 46 | while (wrn.length() > 10) |
38 | { | 47 | { |
39 | fmt += wrn.left(10); | 48 | fmt += wrn.left(10); |
40 | fmt += '\n'; | 49 | fmt += '\n'; |
41 | wrn = wrn.right(wrn.length()-10); | 50 | wrn = wrn.right(wrn.length()-10); |
42 | } | 51 | } |
43 | fmt += wrn; | 52 | fmt += wrn; |
44 | QMessageBox::warning(NULL, PROGNAME, fmt); | 53 | QMessageBox::warning(NULL, PROGNAME, fmt); |
45 | */ | 54 | */ |
46 | qDebug("Can't find codec:%s", dlerror()); | 55 | qDebug("Can't find codec:%s", dlerror()); |
47 | status = -10; | 56 | status = -10; |
48 | return; | 57 | return; |
49 | } | 58 | } |
50 | CExpander* (*newcodec)(); | 59 | CExpander* (*newcodec)(); |
51 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); | 60 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); |
52 | if (newcodec == NULL) | 61 | if (newcodec == NULL) |
53 | { | 62 | { |
54 | qDebug("Can't find newcodec"); | 63 | qDebug("Can't find newcodec"); |
55 | status = -20; | 64 | status = -20; |
56 | return; | 65 | return; |
57 | } | 66 | } |
58 | codec = (*newcodec)(); | 67 | codec = (*newcodec)(); |
59 | } | 68 | } |
60 | else | 69 | else |
61 | { | 70 | { |
62 | qDebug("Can't find codec"); | 71 | qDebug("Can't find codec"); |
63 | } | 72 | } |
64 | if (codec == NULL) | 73 | if (codec == NULL) |
65 | { | 74 | { |
66 | qDebug("Can't do newcodec"); | 75 | qDebug("Can't do newcodec"); |
67 | status = -30; | 76 | status = -30; |
68 | return; | 77 | return; |
69 | } | 78 | } |
70 | } | 79 | } |
71 | virtual ~ebookcodec() | 80 | virtual ~ebookcodec() |
72 | { | 81 | { |
73 | if (codec != NULL) delete codec; | 82 | if (codec != NULL) delete codec; |
74 | if (handle != NULL) dlclose(handle); | 83 | if (handle != NULL) dlclose(handle); |
75 | } | 84 | } |
76 | size_t getHome() { return codec->getHome(); } | 85 | size_t getHome() { return codec->getHome(); } |
77 | #ifdef USEQPE | 86 | #ifdef USEQPE |
78 | void suspend() { codec->suspend(); } | 87 | void suspend() { codec->suspend(); } |
79 | void unsuspend() { codec->unsuspend(); } | 88 | void unsuspend() { codec->unsuspend(); } |
80 | void suspend(FILE*& fin) { codec->suspend(fin); } | 89 | void suspend(FILE*& fin) { codec->suspend(fin); } |
81 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } | 90 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } |
82 | #endif | 91 | #endif |
83 | unsigned int locate() { return codec->locate(); } | 92 | unsigned int locate() { return codec->locate(); } |
84 | void locate(unsigned int n) { codec->locate(n); } | 93 | void locate(unsigned int n) { codec->locate(n); } |
85 | bool hasrandomaccess() { return codec->hasrandomaccess(); } | 94 | bool hasrandomaccess() { return codec->hasrandomaccess(); } |
86 | void sizes(unsigned long& file, unsigned long& text) | 95 | void sizes(unsigned long& file, unsigned long& text) |
87 | { | 96 | { |
88 | codec->sizes(file, text); | 97 | codec->sizes(file, text); |
89 | //qDebug("Codec sizes:(%u, %u)", file, text); | 98 | //qDebug("Codec sizes:(%u, %u)", file, text); |
90 | } | 99 | } |
91 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } | 100 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } |
92 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } | 101 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } |
93 | int getch() { return codec->getch(); } | 102 | int getch() { return codec->getch(); } |
94 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } | 103 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } |
95 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } | 104 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } |
96 | void saveposn(size_t posn) { codec->saveposn(posn); } | 105 | void saveposn(size_t posn) { codec->saveposn(posn); } |
97 | void writeposn(size_t posn) { codec->writeposn(posn); } | 106 | void writeposn(size_t posn) { codec->writeposn(posn); } |
98 | linkType forward(size_t& loc) { return codec->forward(loc); } | 107 | linkType forward(size_t& loc) { return codec->forward(loc); } |
99 | linkType back(size_t& loc) { return codec->back(loc); } | 108 | linkType back(size_t& loc) { return codec->back(loc); } |
100 | bool hasnavigation() { return codec->hasnavigation(); } | 109 | bool hasnavigation() { return codec->hasnavigation(); } |
101 | void start2endSection() { codec->start2endSection(); } | 110 | void start2endSection() { codec->start2endSection(); } |
102 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } | 111 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } |
103 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } | 112 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } |
104 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } | 113 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } |
105 | void setContinuous(bool _b) { codec->setContinuous(_b); } | 114 | void setContinuous(bool _b) { codec->setContinuous(_b); } |
106 | void setwidth(int w) { codec->setwidth(w); } | 115 | void setwidth(int w) { codec->setwidth(w); } |
107 | unsigned long startSection() { return codec->startSection(); } | 116 | unsigned long startSection() { return codec->startSection(); } |
108 | unsigned long endSection() { return codec->endSection(); } | 117 | unsigned long endSection() { return codec->endSection(); } |
109 | int openfile(const char *src) | 118 | int openfile(const char *src) |
110 | { | 119 | { |
111 | //qDebug("ebook openfile:%s", src); | 120 | //qDebug("ebook openfile:%s", src); |
112 | return (status != 0) ? status : codec->openfile(src); | 121 | return (status != 0) ? status : codec->openfile(src); |
113 | } | 122 | } |
114 | int getwidth() { return codec->getwidth(); } | 123 | int getwidth() { return codec->getwidth(); } |
115 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } | 124 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } |
116 | bool getFile(const QString& href) { return codec->getFile(href); } | 125 | bool getFile(const QString& href, const QString& nm) { return codec->getFile(href, nm); } |
126 | bool findanchor(const QString& nm) | ||
127 | { | ||
128 | return codec->findanchor(nm); | ||
129 | } | ||
117 | }; | 130 | }; |
118 | #endif | 131 | #endif |