Diffstat (limited to 'noncore/apps/opie-reader/ZText.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ZText.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h index 199c7da..40b0f0a 100644 --- a/noncore/apps/opie-reader/ZText.h +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -1,65 +1,74 @@ | |||
1 | #ifndef __Text_h | 1 | #ifndef __Text_h |
2 | #define __Text_h | 2 | #define __Text_h |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <zlib.h> | 4 | #include <zlib.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | |||
6 | #include "CExpander.h" | 10 | #include "CExpander.h" |
7 | 11 | ||
8 | class Text: public CExpander { | 12 | class Text: public CExpander { |
9 | gzFile file; | 13 | gzFile file; |
10 | unsigned long fsize; | 14 | unsigned long fsize; |
11 | public: | 15 | public: |
12 | void suspend() | 16 | void suspend() |
13 | { | 17 | { |
14 | #ifdef USEQPE | 18 | #ifdef USEQPE |
15 | if (!bSuspended) | 19 | if (!bSuspended) |
16 | { | 20 | { |
17 | bSuspended = true; | 21 | bSuspended = true; |
18 | suspos = gztell(file); | 22 | suspos = gztell(file); |
19 | gzclose(file); | 23 | gzclose(file); |
20 | file = NULL; | 24 | file = NULL; |
21 | sustime = time(NULL); | 25 | sustime = time(NULL); |
22 | } | 26 | } |
23 | #endif | 27 | #endif |
24 | } | 28 | } |
25 | void unsuspend() | 29 | void unsuspend() |
26 | { | 30 | { |
27 | #ifdef USEQPE | 31 | #ifdef USEQPE |
28 | if (bSuspended) | 32 | if (bSuspended) |
29 | { | 33 | { |
30 | bSuspended = false; | 34 | bSuspended = false; |
31 | if (sustime != ((time_t)-1)) | 35 | if (sustime != ((time_t)-1)) |
32 | { | 36 | { |
33 | int delay = time(NULL) - sustime; | 37 | int delay = time(NULL) - sustime; |
34 | if (delay < 10) sleep(10-delay); | 38 | if (delay < 10) |
39 | { | ||
40 | Global::statusMessage("Stalling"); | ||
41 | sleep(10-delay); | ||
42 | } | ||
35 | } | 43 | } |
36 | file = gzopen(fname, "rb"); | 44 | file = gzopen(fname, "rb"); |
37 | for (int i = 0; file == NULL && i < 5; i++) | 45 | for (int i = 0; file == NULL && i < 5; i++) |
38 | { | 46 | { |
47 | Global::statusMessage("Stalling"); | ||
39 | sleep(5); | 48 | sleep(5); |
40 | file = gzopen(fname, "rb"); | 49 | file = gzopen(fname, "rb"); |
41 | } | 50 | } |
42 | if (file == NULL) | 51 | if (file == NULL) |
43 | { | 52 | { |
44 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 53 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
45 | exit(0); | 54 | exit(0); |
46 | } | 55 | } |
47 | suspos = gzseek(file, suspos, SEEK_SET); | 56 | suspos = gzseek(file, suspos, SEEK_SET); |
48 | } | 57 | } |
49 | #endif | 58 | #endif |
50 | } | 59 | } |
51 | Text() : file(NULL) {}; | 60 | Text() : file(NULL) {}; |
52 | virtual ~Text() | 61 | virtual ~Text() |
53 | { | 62 | { |
54 | if (file != NULL) | 63 | if (file != NULL) |
55 | { | 64 | { |
56 | #ifdef USEQPE | 65 | #ifdef USEQPE |
57 | unsuspend(); | 66 | unsuspend(); |
58 | #endif | 67 | #endif |
59 | gzclose(file); | 68 | gzclose(file); |
60 | } | 69 | } |
61 | } | 70 | } |
62 | int OpenFile(const char *src) | 71 | int OpenFile(const char *src) |
63 | { | 72 | { |
64 | if (file != NULL) gzclose(file); | 73 | if (file != NULL) gzclose(file); |
65 | struct stat _stat; | 74 | struct stat _stat; |