summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CHM.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/CHM.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CHM.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/noncore/apps/opie-reader/CHM.cpp b/noncore/apps/opie-reader/CHM.cpp
index 88d53bf..ace5abc 100644
--- a/noncore/apps/opie-reader/CHM.cpp
+++ b/noncore/apps/opie-reader/CHM.cpp
@@ -6,4 +6,7 @@
6#include <qimage.h> 6#include <qimage.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#ifdef USEQPE
9#include <qpe/global.h>
10#endif
8 11
9#ifndef __STATIC 12#ifndef __STATIC
@@ -50,5 +53,5 @@ CHM::~CHM() {
50} 53}
51 54
52void CHM::suspend() { 55void CHM::suspend() {
53#ifdef USEQPE 56#ifdef USEQPE
54 bSuspended = true; 57 bSuspended = true;
@@ -56,9 +59,9 @@ void CHM::suspend() {
56 chm_close(chmFile); 59 chm_close(chmFile);
57 chmFile = NULL; 60 chmFile = NULL;
58 sustime = time(NULL); 61 sustime = time(NULL);
59#endif 62#endif
60} 63}
61 64
62void CHM::unsuspend() { 65void CHM::unsuspend() {
63#ifdef USEQPE 66#ifdef USEQPE
64 if (bSuspended) 67 if (bSuspended)
@@ -66,8 +69,12 @@ void CHM::unsuspend() {
66 bSuspended = false; 69 bSuspended = false;
67 int delay = time(NULL) - sustime; 70 int delay = time(NULL) - sustime;
68 if (delay < 10) 71 if (delay < 10)
69 sleep(10-delay); 72 {
73 Global::statusMessage("Stalling");
74 sleep(10-delay);
75 }
70 chmFile = chm_open(fname); 76 chmFile = chm_open(fname);
71 for (int i = 0; chmFile == NULL && i < 5; i++) { 77 for (int i = 0; chmFile == NULL && i < 5; i++) {
78 Global::statusMessage("Stalling");
72 sleep(5); 79 sleep(5);
73 chmFile = chm_open(fname); 80 chmFile = chm_open(fname);
@@ -78,5 +85,5 @@ void CHM::unsuspend() {
78 } 85 }
79 //suspos = gzseek(file, suspos, SEEK_SET); 86 //suspos = gzseek(file, suspos, SEEK_SET);
80 } 87 }
81#endif 88#endif
82} 89}
@@ -87,4 +94,5 @@ void CHM::addContent(QString content) {
87 94
88void CHM::FillHomeContent() { 95void CHM::FillHomeContent() {
96unsuspend();
89 if (chmHHCPath != "") { 97 if (chmHHCPath != "") {
90 const char *ext; 98 const char *ext;
@@ -163,4 +171,5 @@ void CHM::FillHomeContent() {
163bool CHM::FillBuffer() 171bool CHM::FillBuffer()
164{ 172{
173unsuspend();
165 bool bRetVal = false; 174 bool bRetVal = false;
166 char buffer[65536]; 175 char buffer[65536];
@@ -197,4 +206,5 @@ bool CHM::FillBuffer()
197 206
198bool CHM::FillContent() { 207bool CHM::FillContent() {
208unsuspend();
199 bool bRetVal = false; 209 bool bRetVal = false;
200 if (chmPath != "") { 210 if (chmPath != "") {
@@ -240,5 +250,6 @@ bool CHM::FillContent() {
240} 250}
241 251
242bool CHM::getFile(const QString& href) { 252bool CHM::getFile(const QString& _href, const QString& ) {
253 QString href = "/" + _href;
243 qDebug("Got:%s", (const char*)href); 254 qDebug("Got:%s", (const char*)href);
244 bool bRetVal = false; 255 bool bRetVal = false;
@@ -320,9 +331,9 @@ int CHM::getch() {
320 if ( (bufpos+1) >= chmBuffer.length() ) 331 if ( (bufpos+1) >= chmBuffer.length() )
321 return EOF; 332 return EOF;
322#ifdef _WINDOWS 333#ifdef _WINDOWS
323 QChar letter = chmBuffer.at(bufpos++); 334 QChar letter = chmBuffer.at(bufpos++);
324#else 335#else
325 QChar letter = chmBuffer[bufpos++]; 336 QChar letter = chmBuffer[bufpos++];
326#endif 337#endif
327 return (int)(char)letter; 338 return (int)(char)letter;
328} 339}