Diffstat (limited to 'noncore/apps/opie-reader/plucker_base.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/plucker_base.cpp | 148 |
1 files changed, 78 insertions, 70 deletions
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index caa945d..b523a54 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp @@ -1,14 +1,16 @@ + + #include "useqpe.h" -#include <stdio.h> -#include <string.h> +#include "plucker_base.h" +#include "Aportis.h" +#include "Palm2QImage.h" + +/* OPIE */ +#include <opie2/odebug.h> #ifdef USEQPE #include <qpe/qcopenvelope_qws.h> -#endif /* USEQPE */ -#ifdef LOCALPICTURES -#include <qscrollview.h> -#endif -#ifdef USEQPE #include <qpe/global.h> #endif /* USEQPE */ + #ifndef USEQPE #include <qapplication.h> @@ -17,7 +19,13 @@ #endif /* USEQPE */ -#include "plucker_base.h" -#include "Aportis.h" -#include "Palm2QImage.h" +/* QT */ +#ifdef LOCALPICTURES +#include <qscrollview.h> +#endif + +/* STD */ +#include <stdio.h> +#include <string.h> + CPlucker_base::CPlucker_base() : @@ -94,5 +102,5 @@ char* CPlucker_base::geturl(UInt16 tgt) fread(&hdr0, 1, 6, fin); unsigned int nrecs = ntohs(hdr0.nRecords); - //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); + //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl; UInt16 urlid = 0; bool urlsfound = false; @@ -104,12 +112,12 @@ char* CPlucker_base::geturl(UInt16 tgt) fread(&name, 1, sizeof(name), fin); fread(&id, 1, sizeof(id), fin); - //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); + //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl; if (ntohs(name) == 2) { urlsfound = true; urlid = id; - //qDebug("Found url index:%d", ntohs(urlid)); + //odebug << "Found url index:" << ntohs(urlid) << "" << oendl; } -// //qDebug("%x", id); +// //odebug << "" << id << "" << oendl; } if (urlsfound) @@ -130,5 +138,5 @@ char* CPlucker_base::geturl(UInt16 tgt) fread(&urlid, 1, sizeof(urlid), fin); tctr = ntohs(tctr); - //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); + //odebug << "tgt:" << tgt << " urlctr:" << urlctr << " tctr:" << tctr << "" << oendl; if (tctr >= tgt) { @@ -137,5 +145,5 @@ char* CPlucker_base::geturl(UInt16 tgt) urlctr = tctr; } - //qDebug("urls are in %d", ntohs(urlid)); + //odebug << "urls are in " << ntohs(urlid) << "" << oendl; recptr = finduid(ntohs(urlid)); if (recptr != 0) @@ -144,5 +152,5 @@ char* CPlucker_base::geturl(UInt16 tgt) gotorecordnumber(recptr); GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); - //qDebug("Found urls:%x",thishdr_type); + //odebug << "Found urls:" << thishdr_type << "" << oendl; urlsize = thishdr_size; urls = new char[urlsize]; @@ -154,5 +162,5 @@ char* CPlucker_base::geturl(UInt16 tgt) if (rn == tgt) { - //qDebug("URL:%s", ptr); + //odebug << "URL:" << ptr << "" << oendl; int len = strlen(ptr)+1; pRet = new char[len]; @@ -251,5 +259,5 @@ void CPlucker_base::locate(unsigned int n) recptr--; gotorecordnumber(recptr); - //qDebug("recptr:%u", recptr); + //odebug << "recptr:" << recptr << "" << oendl; GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); if (thishdr_type < 2) @@ -276,5 +284,5 @@ void CPlucker_base::locate(unsigned int n) } } -// qDebug("Time(1): %u", clock()-start); +// odebug << "Time(1): " << clock()-start << "" << oendl; /* expand(recptr); @@ -322,8 +330,8 @@ void CPlucker_base::locate(unsigned int n) } while (locpos + bs <= n); -// qDebug("Time(2): %u", clock()-start); +// odebug << "Time(2): " << clock()-start << "" << oendl; if (recptr != thisrec) { - qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); + odebug << "Disaster:recptr:" << recptr << " thisrec:" << thisrec << "" << oendl; UInt16 thishdr_uid, thishdr_nParagraphs; UInt32 thishdr_size = buffercontent; @@ -333,5 +341,5 @@ void CPlucker_base::locate(unsigned int n) gotorecordnumber(recptr); GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); -// qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved); +// odebug << "UID:" << thishdr_uid << " Paras:" << thishdr_nParagraphs << " Size:" << thishdr_size << " Type:" << (unsigned int)thishdr_type << " Reserved:" << (unsigned int)thishdr_reserved << "" << oendl; } // QApplication::exit ( 100 ); @@ -372,7 +380,7 @@ bool CPlucker_base::expand(int thisrec) { GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); - //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); + //odebug << "This (" << thisrec << ") type is " << thishdr_type << ", uid is " << thishdr_uid << "" << oendl; if (thishdr_type < 2) break; - //qDebug("Skipping paragraph of type %d", thishdr_type); + //odebug << "Skipping paragraph of type " << thishdr_type << "" << oendl; if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; reclen = recordlength(thisrec); @@ -381,5 +389,5 @@ bool CPlucker_base::expand(int thisrec) m_nParas = thishdr_nParagraphs; m_bufferisreserved = (thishdr_reserved != 0); - //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); + //odebug << "It has " << thishdr_nParagraphs << " paragraphs and is " << thishdr_size << " bytes" << oendl; uid = thishdr_uid; // gotorecordnumber(thisrec); @@ -392,10 +400,10 @@ bool CPlucker_base::expand(int thisrec) m_ParaOffsets[i] = ntohs(ubytes); m_ParaAttrs[i] = ntohs(attrs); -// //qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); +// //odebug << "Bytes " << ntohs(ubytes) << ", Attr " << ntohs(attrs) << "" << oendl; } if (m_nParas > 0) { m_nextPara = m_ParaOffsets[0]; - //qDebug("First offset = %u", m_nextPara); + //odebug << "First offset = " << m_nextPara << "" << oendl; m_nextParaIndex = 0; } @@ -419,5 +427,5 @@ bool CPlucker_base::expand(int thisrec) bufferpos = 0; bufferrec = thisrec; - //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); + //odebug << "BC:" << buffercontent << ", HS:" << thishdr_size << "" << oendl; return true; } @@ -453,5 +461,5 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff err = inflate( &zstream, Z_SYNC_FLUSH ); -// //qDebug("err:%d - %u", err, zstream.avail_in); +// //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl; } while ( err == Z_OK ); @@ -535,7 +543,7 @@ CList<Bkmk>* CPlucker_base::getbkmklist() fread(&n, 1, sizeof(n), fin); n = ntohs(n); - //qDebug("Found %u bookmarks", n); + //odebug << "Found " << n << " bookmarks" << oendl; } - //qDebug("Found:%d, %u", i , thishdr_type); + //odebug << "Found:" << i << ", " << thishdr_type << "" << oendl; } */ @@ -593,5 +601,5 @@ QImage* CPlucker_base::getPicture(unsigned long tgt) void CPlucker_base::showimg(UInt16 tgt) { - //qDebug("Crassssssh!"); + //odebug << "Crassssssh!" << oendl; QPixmap* qimage = expandimg(tgt); m_picture->setFixedSize(qimage->size()); @@ -604,5 +612,5 @@ void CPlucker_base::showimg(UInt16 tgt) QImage* qimage = getimg(tgt); QPixmap* image = new QPixmap(0,0); -// //qDebug("New image"); +// //odebug << "New image" << oendl; image->convertFromImage(*qimage); delete qimage; @@ -611,5 +619,5 @@ void CPlucker_base::showimg(UInt16 tgt) int f = mkstemp(tmpfile); close(f); - //qDebug("TMPFILE:%s", tmpfile); + //odebug << "TMPFILE:" << tmpfile << "" << oendl; if (image->save(tmpfile,"PNG")) { @@ -628,5 +636,5 @@ void CPlucker_base::showimg(UInt16 tgt) unsigned short CPlucker_base::finduid(unsigned short urlid) { -// //qDebug("Finding %u", urlid); +// //odebug << "Finding " << urlid << "" << oendl; unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); unsigned short jmid = (jmin+jmax) >> 1; @@ -639,5 +647,5 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); unsigned short luid = thishdr_uid; -// //qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); +// //odebug << "" << jmin << " " << jmid << " " << jmax << " : " << urlid << "" << oendl; if (luid == urlid) { @@ -660,5 +668,5 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); unsigned short luid = thishdr_uid; - //qDebug("jmin at end:%u,%u", jmin, luid); + //odebug << "jmin at end:" << jmin << "," << luid << "" << oendl; if (luid == urlid) { @@ -668,10 +676,10 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); luid = thishdr_uid; - //qDebug("jmax at end:%u,%u", jmax, luid); + //odebug << "jmax at end:" << jmax << "," << luid << "" << oendl; if (luid == urlid) { return jmax; } - //qDebug("Couldn't find %u", urlid); + //odebug << "Couldn't find " << urlid << "" << oendl; return 0; // Not found! } @@ -699,5 +707,5 @@ void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsig { unsigned long t = *it; -// qDebug("[%u]", t); +// odebug << "[" << t << "]" << oendl; memcpy(newdata, &t, sizeof(t)); newdata += sizeof(t); @@ -722,5 +730,5 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) { memcpy(&t, src, sizeof(t)); -// qDebug("[%u]", t); +// odebug << "[" << t << "]" << oendl; visited.push_front(t); src += sizeof(t); @@ -752,8 +760,8 @@ int CPlucker_base::OpenFile(const char *src) expandedtextbuffer = new UInt8[buffersize]; - //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); + //odebug << "Total number of records:" << ntohs(head.recordList.numRecords) << "" << oendl; unsigned int nrecs = ntohs(hdr0.nRecords); - //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); + //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl; UInt16 homerecid = 1; for (unsigned int i = 0; i < nrecs; i++) @@ -762,5 +770,5 @@ int CPlucker_base::OpenFile(const char *src) fread(&name, 1, sizeof(name), fin); fread(&id, 1, sizeof(id), fin); - //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); + //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl; if (ntohs(name) == 0) homerecid = ntohs(id); } @@ -820,5 +828,5 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) UInt16 tuid = (n >> 16); n &= 0xffff; -// //qDebug("Hyper:<%u,%u>", tuid, n); +// //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl; UInt16 thisrec = 1; currentpos = 0; @@ -832,5 +840,5 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) if (tuid == thishdr_uid) break; if (thishdr_type < 2) currentpos += thishdr_size; -// //qDebug("hyper-cp:%u", currentpos); +// //odebug << "hyper-cp:" << currentpos << "" << oendl; thisrec++; if (thisrec >= ntohs(head.recordList.numRecords)) @@ -858,5 +866,5 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) #else #endif /* USEQPE */ - //qDebug("Link:%s", (const char*)wrd); + //odebug << "Link:" << wrd << "" << oendl; // setlink(fn, wrd); delete [] turl; @@ -927,5 +935,5 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) return eNone; } - //qDebug("Hyper:<%u,%u>", tuid, n); + //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl; while (bufferpos < n && bufferpos < buffercontent) getch_base(true); /* // This is faster but the alignment doesn't get set @@ -957,9 +965,9 @@ tchar CPlucker_base::getch_base(bool fast) { ch = bgetch(); -// //qDebug("Function:%x", ch); +// //odebug << "Function:" << ch << "" << oendl; switch (ch) { case 0x38: -// //qDebug("Break:%u", locate()); +// //odebug << "Break:" << locate() << "" << oendl; if (m_lastBreak == locate()) { @@ -981,5 +989,5 @@ tchar CPlucker_base::getch_base(bool fast) int ch = bgetch(); ln = (ln << 8) + ch; -// //qDebug("ch:%d, ln:%u", ch, ln); +// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl; } if (skip == 2) @@ -993,8 +1001,8 @@ tchar CPlucker_base::getch_base(bool fast) int ch = bgetch(); ln = (ln << 8) + ch; -// //qDebug("ch:%d, ln:%u", ch, ln); +// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl; } } -// //qDebug("ln:%u", ln); +// //odebug << "ln:" << ln << "" << oendl; mystyle.setLink(true); mystyle.setData(ln); @@ -1039,5 +1047,5 @@ tchar CPlucker_base::getch_base(bool fast) { ch = bgetch(); -// //qDebug("Font:%d",ch); +// //odebug << "Font:" << ch << "" << oendl; mystyle.setVOffset(0); mystyle.unsetMono(); @@ -1073,5 +1081,5 @@ tchar CPlucker_base::getch_base(bool fast) break; case 8: // should be fixed width - //qDebug("Trying fixed width"); + //odebug << "Trying fixed width" << oendl; mystyle.setMono(); break; @@ -1088,5 +1096,5 @@ tchar CPlucker_base::getch_base(bool fast) break; default: - qDebug("Unrecognised font"); + odebug << "Unrecognised font" << oendl; break; } @@ -1100,17 +1108,17 @@ tchar CPlucker_base::getch_base(bool fast) case 0: mystyle.setLeftJustify(); -// //qDebug("left"); +// //odebug << "left" << oendl; break; case 1: mystyle.setRightJustify(); -// //qDebug("right"); +// //odebug << "right" << oendl; break; case 2: mystyle.setCentreJustify(); -// //qDebug("centre"); +// //odebug << "centre" << oendl; break; case 3: mystyle.setFullJustify(); -// //qDebug("full"); +// //odebug << "full" << oendl; break; @@ -1135,5 +1143,5 @@ tchar CPlucker_base::getch_base(bool fast) if (hasalternate) { - //qDebug("Alternate image:%x", ir); + //odebug << "Alternate image:" << ir << "" << oendl; UInt16 ir2 = bgetch(); ir2 = (ir2 << 8) + bgetch(); @@ -1150,5 +1158,5 @@ tchar CPlucker_base::getch_base(bool fast) if (!fast) mystyle.setPicture(true, expandimg(ir)); } -// if (mystyle.getLink()) qDebug("Picture link!"); +// if (mystyle.getLink()) odebug << "Picture link!" << oendl; ch = '#'; } @@ -1161,5 +1169,5 @@ tchar CPlucker_base::getch_base(bool fast) UInt8 pc = bgetch(); UInt16 w = wc; -// //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); +// //odebug << "h,w,pc [" << h << ", " << w << ", " << pc << "]" << oendl; if (w == 0) { @@ -1168,5 +1176,5 @@ tchar CPlucker_base::getch_base(bool fast) if (w == 0) w = m_scrWidth; mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); -// if (mystyle.getLink()) //qDebug("hRule link!"); +// if (mystyle.getLink()) //odebug << "hRule link!" << oendl; ch = '#'; } @@ -1183,8 +1191,8 @@ tchar CPlucker_base::getch_base(bool fast) ch = bgetch(); mystyle.setLeftMargin(ch); -// //qDebug("Left margin:%d", ch); +// //odebug << "Left margin:" << ch << "" << oendl; ch = bgetch(); mystyle.setRightMargin(ch); -// //qDebug("Right margin:%d", ch); +// //odebug << "Right margin:" << ch << "" << oendl; ch = bgetch(); break; @@ -1204,10 +1212,10 @@ tchar CPlucker_base::getch_base(bool fast) ch |= (tchar)bgetch(); for (int i = 0; i < tlen; i++) bgetch(); - //qDebug("Function 83"); + //odebug << "Function 83" << oendl; } break; case 0x85: default: - qDebug("Function:%x NOT IMPLEMENTED", ch); + odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl; { int skip = ch & 7; @@ -1215,5 +1223,5 @@ tchar CPlucker_base::getch_base(bool fast) { ch = bgetch(); - //qDebug("Arg %d, %d", i, ch); + //odebug << "Arg " << i << ", " << ch << "" << oendl; } ch = bgetch(); |