summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CExpander.h
authorpohly <pohly>2004-08-24 20:52:45 (UTC)
committer pohly <pohly>2004-08-24 20:52:45 (UTC)
commit73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (side-by-side diff)
tree1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/CExpander.h
parente90847c784c48bd21bf8768cb38edb853b832697 (diff)
downloadopie-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) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CExpander.h197
1 files changed, 94 insertions, 103 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
@@ -1,6 +1,13 @@
#ifndef __CExpander_h
#define __CExpander_h
+#ifndef _WINDOWS
+#include <unistd.h>
+#endif
+#include <stdio.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <qmessagebox.h>
#include "useqpe.h"
#include "config.h"
#include "StyleConsts.h"
@@ -8,21 +15,9 @@
#include "names.h"
#include "linktype.h"
-/* 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;
template<class T>
class CList;
@@ -30,11 +25,69 @@ class CList;
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_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
+class CExpander : public CExpander_Interface
{
protected:
size_t m_homepos;
@@ -47,112 +100,50 @@ class CExpander
unsigned long m_currentstart, m_currentend;
public:
#ifdef USEQPE
- virtual void suspend() = 0;
+ virtual void suspend() = 0;
virtual void unsuspend() = 0;
#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;
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)
- {
- 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;
virtual void saveposn(size_t posn) {}
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; }
void setContinuous(bool _b) { m_continuous = _b; }
#ifdef USEQPE
- virtual void suspend(FILE*& fin)
+ 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 putSaveData(unsigned char*& src, unsigned short& srclen);
+ void setwidth(int w)
{
- bSuspended = true;
- suspos = ftell(fin);
- fclose(fin);
- fin = NULL;
- sustime = time(NULL);
+ m_scrWidth = w;
}
- virtual void unsuspend(FILE*& fin)
- {
- if (bSuspended)
+ int getwidth()
{
- 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);
+ return m_scrWidth;
}
- }
-#endif
- virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
- {
- len = srclen;
- data = new unsigned char[len];
- memcpy(data, src, len);
- }
- virtual void putSaveData(unsigned char*& src, unsigned short& srclen)
- {
- if (srclen != 0)
- {
- odebug << "Don't know what to do with non-zero save data" << oendl;
- }
- }
- 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; }
};
#endif