author | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
---|---|---|
committer | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
commit | 73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (side-by-side diff) | |
tree | 1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/CExpander.h | |
parent | e90847c784c48bd21bf8768cb38edb853b832697 (diff) | |
download | opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2 |
updated source to opie-reader 0.7g
Diffstat (limited to 'noncore/apps/opie-reader/CExpander.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CExpander.h | 193 |
1 files changed, 92 insertions, 101 deletions
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index 553069c..e9aaf79 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h @@ -3,2 +3,9 @@ +#ifndef _WINDOWS +#include <unistd.h> +#endif +#include <stdio.h> +#include <time.h> +#include <sys/stat.h> +#include <qmessagebox.h> #include "useqpe.h" @@ -10,17 +17,5 @@ -/* OPIE */ -#include <opie2/odebug.h> - -/* QT */ -#include <qmessagebox.h> - -/* STD */ -#ifndef _WINDOWS -#include <unistd.h> -#endif -#include <stdio.h> -#include <time.h> - class QImage; class Bkmk; +class QString; @@ -32,7 +27,65 @@ class CCharacterSource public: - virtual void getch(tchar&, CStyle&) = 0; - virtual linkType hyperlink(unsigned int n, QString&) = 0; + virtual void getch(tchar&, CStyle&, unsigned long&) = 0; + virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; + virtual void locate(unsigned int n) = 0; + virtual bool findanchor(const QString& nm) = 0; + virtual void saveposn(const QString& f, size_t posn) = 0; + virtual void writeposn(const QString& f, size_t posn) = 0; + virtual linkType forward(QString& f, size_t& loc) = 0; + virtual linkType back(QString& f, size_t& loc) = 0; + virtual bool hasnavigation() = 0; + virtual int getwidth() = 0; + virtual QImage* getPicture(unsigned long) = 0; + virtual QImage* getPicture(const QString& href) = 0; + virtual bool getFile(const QString& href) = 0; + virtual QString about() = 0; }; -class CExpander +class CExpander_Interface +{ + public: +#ifdef USEQPE + virtual void suspend() = 0; + virtual void unsuspend() = 0; +#endif + virtual QString about() = 0; + virtual size_t getHome() = 0; + //CExpander_Interface(); + //virtual ~CExpander_Interface(); + virtual int openfile(const char *src) = 0; + //virtual int OpenFile(const char *src) = 0; + virtual unsigned int locate() = 0; + virtual void locate(unsigned int n) = 0; + virtual bool hasrandomaccess() = 0; + virtual void sizes(unsigned long& file, unsigned long& text) = 0; + virtual CList<Bkmk>* getbkmklist() { return NULL; } + virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; + virtual int getch() = 0; + virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; + virtual MarkupType PreferredMarkup() = 0; + virtual void saveposn(size_t posn) {} + virtual void writeposn(size_t posn) {} + virtual linkType forward(size_t& loc) { return eNone; } + virtual linkType back(size_t& loc) { return eNone; } + virtual bool hasnavigation() { return false; } + virtual unsigned long startSection() = 0; + virtual unsigned long endSection() = 0; + virtual void start2endSection() = 0; + virtual QImage* getPicture(unsigned long tgt) { return NULL; } + virtual void setContinuous(bool _b) = 0; +#ifdef USEQPE + virtual void suspend(FILE*& fin) = 0; + virtual void unsuspend(FILE*& fin) = 0; +#endif + virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; + virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; + virtual void setwidth(int w) = 0; + // bool findstring(const QString& info); + // int getpara(CBuffer& buff); + virtual int getwidth() = 0; + virtual QImage* getPicture(const QString& href) = 0; + virtual bool getFile(const QString& href) = 0; +}; + +class CExpander : public CExpander_Interface { @@ -52,11 +105,6 @@ class CExpander #endif - size_t getHome() { return m_homepos; } - CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; - virtual ~CExpander() { if (fname != NULL) delete [] fname; }; - int openfile(const char *src) - { - bSuspended = false; - fname = strdup(src); - return OpenFile(src); - } + size_t getHome(); + CExpander(); + virtual ~CExpander(); + int openfile(const char *src); virtual int OpenFile(const char *src) = 0; @@ -67,14 +115,5 @@ class CExpander virtual CList<Bkmk>* getbkmklist() { return NULL; } - virtual void getch(tchar& ch, CStyle& sty) - { - int ich = getch(); - ch = (ich == EOF) ? UEOF : ich; - sty.unset(); - } + virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); virtual int getch() = 0; - virtual linkType hyperlink(unsigned int n, QString& wrd) - { - locate(n); - return eLink; - } + virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); virtual MarkupType PreferredMarkup() = 0; @@ -82,29 +121,8 @@ class CExpander virtual void writeposn(size_t posn) {} - virtual bool forward(size_t& loc) { return false; } - virtual bool back(size_t& loc) { return false; } + virtual linkType forward(size_t& loc) { return eNone; } + virtual linkType back(size_t& loc) { return eNone; } virtual bool hasnavigation() { return false; } - unsigned long startSection() - { - unsigned long current = locate(); - if (m_currentstart > current || current > m_currentend) - { - start2endSection(); - } - return m_currentstart; - } - unsigned long endSection() - { - unsigned long current = locate(); - if (m_currentstart > current || current > m_currentend) - { - start2endSection(); - } - return m_currentend; - } - virtual void start2endSection() - { - m_currentstart = 0; - unsigned long file; - sizes(file, m_currentend); - } + unsigned long startSection(); + unsigned long endSection(); + virtual void start2endSection(); virtual QImage* getPicture(unsigned long tgt) { return NULL; } @@ -112,46 +130,19 @@ class CExpander #ifdef USEQPE - virtual void suspend(FILE*& fin) - { - bSuspended = true; - suspos = ftell(fin); - fclose(fin); - fin = NULL; - sustime = time(NULL); - } - virtual void unsuspend(FILE*& fin) - { - if (bSuspended) - { - bSuspended = false; - int delay = time(NULL) - sustime; - if (delay < 10) sleep(10-delay); - fin = fopen(fname, "rb"); - for (int i = 0; fin == NULL && i < 5; i++) - { - sleep(5); - fin = fopen(fname, "rb"); - } - if (fin == NULL) - { - QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); - exit(0); - } - suspos = fseek(fin, suspos, SEEK_SET); - } - } + virtual void suspend(FILE*& fin); + virtual void unsuspend(FILE*& fin); #endif - virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) + virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); + virtual void putSaveData(unsigned char*& src, unsigned short& srclen); + void setwidth(int w) { - len = srclen; - data = new unsigned char[len]; - memcpy(data, src, len); + m_scrWidth = w; } - virtual void putSaveData(unsigned char*& src, unsigned short& srclen) + int getwidth() { - if (srclen != 0) - { - odebug << "Don't know what to do with non-zero save data" << oendl; - } + return m_scrWidth; } - void setwidth(int w) { m_scrWidth = w; } + // bool findstring(const QString& info); + // int getpara(CBuffer& buff); + virtual QImage* getPicture(const QString& href) { return NULL; } + virtual bool getFile(const QString& href) { return false; } }; |