summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CExpander.h
authorllornkcor <llornkcor>2002-12-20 01:35:01 (UTC)
committer llornkcor <llornkcor>2002-12-20 01:35:01 (UTC)
commit876e1a4724a7bd75dc642e295de354241096e028 (patch) (side-by-side diff)
treea37c5dcc9d78e04bb6b859ab89d8cf81e6745087 /noncore/apps/opie-reader/CExpander.h
parent5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff)
downloadopie-876e1a4724a7bd75dc642e295de354241096e028.zip
opie-876e1a4724a7bd75dc642e295de354241096e028.tar.gz
opie-876e1a4724a7bd75dc642e295de354241096e028.tar.bz2
update - sorry it took so long. hope this works correctly
Diffstat (limited to 'noncore/apps/opie-reader/CExpander.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CExpander.h87
1 files changed, 84 insertions, 3 deletions
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h
index b1147a6..c281398 100644
--- a/noncore/apps/opie-reader/CExpander.h
+++ b/noncore/apps/opie-reader/CExpander.h
@@ -1,10 +1,16 @@
#ifndef __CExpander_h
#define __CExpander_h
+#include <unistd.h>
+#include <stdio.h>
+#include <time.h>
+#include <qmessagebox.h>
#include "config.h"
#include "StyleConsts.h"
#include "Markups.h"
+#include "name.h"
+class QPixmap;
class Bkmk;
template<class T>
@@ -18,10 +24,26 @@ class CCharacterSource
class CExpander
{
+ protected:
+ size_t m_homepos;
+ bool m_continuous;
+ char* fname;
+ bool bSuspended;
+ size_t suspos;
+ time_t sustime;
public:
- CExpander() {};
- virtual ~CExpander() {};
- virtual int openfile(const char *src) = 0;
+ virtual void suspend() = 0;
+ virtual void unsuspend() = 0;
+ size_t getHome() { return m_homepos; }
+ CExpander() : m_homepos(0), fname(NULL) {};
+ virtual ~CExpander() { if (fname != NULL) delete [] fname; };
+ int openfile(const char *src)
+ {
+ bSuspended = false;
+ fname = strdup(src);
+ return OpenFile(src);
+ }
+ virtual int OpenFile(const char *src) = 0;
virtual unsigned int locate() = 0;
virtual void locate(unsigned int n) = 0;
virtual bool hasrandomaccess() = 0;
@@ -39,5 +61,64 @@ class CExpander
return true;
}
virtual MarkupType PreferredMarkup() = 0;
+ virtual void saveposn(size_t posn) {}
+ virtual bool forward(size_t& loc) {}
+ virtual bool back(size_t& loc) {}
+ virtual bool hasnavigation() { return false; }
+ virtual unsigned long startSection()
+ {
+ return 0;
+ }
+ virtual unsigned long endSection()
+ {
+ unsigned long file, text;
+ sizes(file, text);
+ return text;
+ }
+ virtual QPixmap* getPicture(unsigned long tgt) { return NULL; }
+ void setContinuous(bool _b) { m_continuous = _b; }
+
+ 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 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)
+ {
+ qDebug("Don't know what to do with non-zero save data");
+ }
+ }
};
#endif