summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/plucker_base.cpp
Unidiff
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.cpp148
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,13 +1,15 @@
1
2
1#include "useqpe.h" 3#include "useqpe.h"
2#include <stdio.h> 4#include "plucker_base.h"
3#include <string.h> 5#include "Aportis.h"
6#include "Palm2QImage.h"
7
8/* OPIE */
9#include <opie2/odebug.h>
4#ifdef USEQPE 10#ifdef USEQPE
5#include <qpe/qcopenvelope_qws.h> 11#include <qpe/qcopenvelope_qws.h>
6#endif /* USEQPE */
7#ifdef LOCALPICTURES
8#include <qscrollview.h>
9#endif
10#ifdef USEQPE
11#include <qpe/global.h> 12#include <qpe/global.h>
12#endif /* USEQPE */ 13#endif /* USEQPE */
14
13#ifndef USEQPE 15#ifndef USEQPE
@@ -18,5 +20,11 @@
18 20
19#include "plucker_base.h" 21/* QT */
20#include "Aportis.h" 22#ifdef LOCALPICTURES
21#include "Palm2QImage.h" 23#include <qscrollview.h>
24#endif
25
26/* STD */
27#include <stdio.h>
28#include <string.h>
29
22 30
@@ -95,3 +103,3 @@ char* CPlucker_base::geturl(UInt16 tgt)
95 unsigned int nrecs = ntohs(hdr0.nRecords); 103 unsigned int nrecs = ntohs(hdr0.nRecords);
96 //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); 104 //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
97 UInt16 urlid = 0; 105 UInt16 urlid = 0;
@@ -105,3 +113,3 @@ char* CPlucker_base::geturl(UInt16 tgt)
105 fread(&id, 1, sizeof(id), fin); 113 fread(&id, 1, sizeof(id), fin);
106 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 114 //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
107 if (ntohs(name) == 2) 115 if (ntohs(name) == 2)
@@ -110,5 +118,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
110 urlid = id; 118 urlid = id;
111 //qDebug("Found url index:%d", ntohs(urlid)); 119 //odebug << "Found url index:" << ntohs(urlid) << "" << oendl;
112 } 120 }
113 ////qDebug("%x", id); 121// //odebug << "" << id << "" << oendl;
114 } 122 }
@@ -131,3 +139,3 @@ char* CPlucker_base::geturl(UInt16 tgt)
131 tctr = ntohs(tctr); 139 tctr = ntohs(tctr);
132 //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); 140 //odebug << "tgt:" << tgt << " urlctr:" << urlctr << " tctr:" << tctr << "" << oendl;
133 if (tctr >= tgt) 141 if (tctr >= tgt)
@@ -138,3 +146,3 @@ char* CPlucker_base::geturl(UInt16 tgt)
138 } 146 }
139 //qDebug("urls are in %d", ntohs(urlid)); 147 //odebug << "urls are in " << ntohs(urlid) << "" << oendl;
140 recptr = finduid(ntohs(urlid)); 148 recptr = finduid(ntohs(urlid));
@@ -145,3 +153,3 @@ char* CPlucker_base::geturl(UInt16 tgt)
145 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 153 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
146 //qDebug("Found urls:%x",thishdr_type); 154 //odebug << "Found urls:" << thishdr_type << "" << oendl;
147 urlsize = thishdr_size; 155 urlsize = thishdr_size;
@@ -155,3 +163,3 @@ char* CPlucker_base::geturl(UInt16 tgt)
155 { 163 {
156 //qDebug("URL:%s", ptr); 164 //odebug << "URL:" << ptr << "" << oendl;
157 int len = strlen(ptr)+1; 165 int len = strlen(ptr)+1;
@@ -252,3 +260,3 @@ void CPlucker_base::locate(unsigned int n)
252 gotorecordnumber(recptr); 260 gotorecordnumber(recptr);
253 //qDebug("recptr:%u", recptr); 261 //odebug << "recptr:" << recptr << "" << oendl;
254 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 262 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
@@ -277,3 +285,3 @@ void CPlucker_base::locate(unsigned int n)
277 } 285 }
278// qDebug("Time(1): %u", clock()-start); 286// odebug << "Time(1): " << clock()-start << "" << oendl;
279/* 287/*
@@ -323,6 +331,6 @@ void CPlucker_base::locate(unsigned int n)
323 331
324// qDebug("Time(2): %u", clock()-start); 332// odebug << "Time(2): " << clock()-start << "" << oendl;
325 if (recptr != thisrec) 333 if (recptr != thisrec)
326 { 334 {
327 qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); 335 odebug << "Disaster:recptr:" << recptr << " thisrec:" << thisrec << "" << oendl;
328 UInt16 thishdr_uid, thishdr_nParagraphs; 336 UInt16 thishdr_uid, thishdr_nParagraphs;
@@ -334,3 +342,3 @@ void CPlucker_base::locate(unsigned int n)
334 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 342 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
335 // 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); 343// odebug << "UID:" << thishdr_uid << " Paras:" << thishdr_nParagraphs << " Size:" << thishdr_size << " Type:" << (unsigned int)thishdr_type << " Reserved:" << (unsigned int)thishdr_reserved << "" << oendl;
336 } 344 }
@@ -373,5 +381,5 @@ bool CPlucker_base::expand(int thisrec)
373 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 381 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
374 //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); 382 //odebug << "This (" << thisrec << ") type is " << thishdr_type << ", uid is " << thishdr_uid << "" << oendl;
375 if (thishdr_type < 2) break; 383 if (thishdr_type < 2) break;
376 //qDebug("Skipping paragraph of type %d", thishdr_type); 384 //odebug << "Skipping paragraph of type " << thishdr_type << "" << oendl;
377 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; 385 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
@@ -382,3 +390,3 @@ bool CPlucker_base::expand(int thisrec)
382 m_bufferisreserved = (thishdr_reserved != 0); 390 m_bufferisreserved = (thishdr_reserved != 0);
383 //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); 391 //odebug << "It has " << thishdr_nParagraphs << " paragraphs and is " << thishdr_size << " bytes" << oendl;
384 uid = thishdr_uid; 392 uid = thishdr_uid;
@@ -393,3 +401,3 @@ bool CPlucker_base::expand(int thisrec)
393 m_ParaAttrs[i] = ntohs(attrs); 401 m_ParaAttrs[i] = ntohs(attrs);
394 ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); 402// //odebug << "Bytes " << ntohs(ubytes) << ", Attr " << ntohs(attrs) << "" << oendl;
395 } 403 }
@@ -398,3 +406,3 @@ bool CPlucker_base::expand(int thisrec)
398 m_nextPara = m_ParaOffsets[0]; 406 m_nextPara = m_ParaOffsets[0];
399 //qDebug("First offset = %u", m_nextPara); 407 //odebug << "First offset = " << m_nextPara << "" << oendl;
400 m_nextParaIndex = 0; 408 m_nextParaIndex = 0;
@@ -420,3 +428,3 @@ bool CPlucker_base::expand(int thisrec)
420 bufferrec = thisrec; 428 bufferrec = thisrec;
421 //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); 429 //odebug << "BC:" << buffercontent << ", HS:" << thishdr_size << "" << oendl;
422 return true; 430 return true;
@@ -454,3 +462,3 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
454 462
455 ////qDebug("err:%d - %u", err, zstream.avail_in); 463// //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl;
456 464
@@ -536,5 +544,5 @@ CList<Bkmk>* CPlucker_base::getbkmklist()
536 n = ntohs(n); 544 n = ntohs(n);
537 //qDebug("Found %u bookmarks", n); 545 //odebug << "Found " << n << " bookmarks" << oendl;
538 } 546 }
539 //qDebug("Found:%d, %u", i , thishdr_type); 547 //odebug << "Found:" << i << ", " << thishdr_type << "" << oendl;
540 } 548 }
@@ -594,3 +602,3 @@ void CPlucker_base::showimg(UInt16 tgt)
594{ 602{
595 //qDebug("Crassssssh!"); 603 //odebug << "Crassssssh!" << oendl;
596 QPixmap* qimage = expandimg(tgt); 604 QPixmap* qimage = expandimg(tgt);
@@ -605,3 +613,3 @@ void CPlucker_base::showimg(UInt16 tgt)
605 QPixmap* image = new QPixmap(0,0); 613 QPixmap* image = new QPixmap(0,0);
606// //qDebug("New image"); 614// //odebug << "New image" << oendl;
607 image->convertFromImage(*qimage); 615 image->convertFromImage(*qimage);
@@ -612,3 +620,3 @@ void CPlucker_base::showimg(UInt16 tgt)
612 close(f); 620 close(f);
613 //qDebug("TMPFILE:%s", tmpfile); 621 //odebug << "TMPFILE:" << tmpfile << "" << oendl;
614 if (image->save(tmpfile,"PNG")) 622 if (image->save(tmpfile,"PNG"))
@@ -629,3 +637,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
629{ 637{
630// //qDebug("Finding %u", urlid); 638// //odebug << "Finding " << urlid << "" << oendl;
631 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); 639 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
@@ -640,3 +648,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
640 unsigned short luid = thishdr_uid; 648 unsigned short luid = thishdr_uid;
641 ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); 649// //odebug << "" << jmin << " " << jmid << " " << jmax << " : " << urlid << "" << oendl;
642 if (luid == urlid) 650 if (luid == urlid)
@@ -661,3 +669,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
661 unsigned short luid = thishdr_uid; 669 unsigned short luid = thishdr_uid;
662 //qDebug("jmin at end:%u,%u", jmin, luid); 670 //odebug << "jmin at end:" << jmin << "," << luid << "" << oendl;
663 if (luid == urlid) 671 if (luid == urlid)
@@ -669,3 +677,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
669 luid = thishdr_uid; 677 luid = thishdr_uid;
670 //qDebug("jmax at end:%u,%u", jmax, luid); 678 //odebug << "jmax at end:" << jmax << "," << luid << "" << oendl;
671 if (luid == urlid) 679 if (luid == urlid)
@@ -674,3 +682,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
674 } 682 }
675 //qDebug("Couldn't find %u", urlid); 683 //odebug << "Couldn't find " << urlid << "" << oendl;
676 return 0; // Not found! 684 return 0; // Not found!
@@ -700,3 +708,3 @@ void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsig
700 unsigned long t = *it; 708 unsigned long t = *it;
701 //qDebug("[%u]", t); 709// odebug << "[" << t << "]" << oendl;
702 memcpy(newdata, &t, sizeof(t)); 710 memcpy(newdata, &t, sizeof(t));
@@ -723,3 +731,3 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
723 memcpy(&t, src, sizeof(t)); 731 memcpy(&t, src, sizeof(t));
724 // qDebug("[%u]", t); 732// odebug << "[" << t << "]" << oendl;
725 visited.push_front(t); 733 visited.push_front(t);
@@ -753,6 +761,6 @@ int CPlucker_base::OpenFile(const char *src)
753 761
754 //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); 762 //odebug << "Total number of records:" << ntohs(head.recordList.numRecords) << "" << oendl;
755 763
756 unsigned int nrecs = ntohs(hdr0.nRecords); 764 unsigned int nrecs = ntohs(hdr0.nRecords);
757 //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); 765 //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
758 UInt16 homerecid = 1; 766 UInt16 homerecid = 1;
@@ -763,3 +771,3 @@ int CPlucker_base::OpenFile(const char *src)
763 fread(&id, 1, sizeof(id), fin); 771 fread(&id, 1, sizeof(id), fin);
764 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 772 //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
765 if (ntohs(name) == 0) homerecid = ntohs(id); 773 if (ntohs(name) == 0) homerecid = ntohs(id);
@@ -821,3 +829,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
821 n &= 0xffff; 829 n &= 0xffff;
822// //qDebug("Hyper:<%u,%u>", tuid, n); 830// //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
823 UInt16 thisrec = 1; 831 UInt16 thisrec = 1;
@@ -833,3 +841,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
833 if (thishdr_type < 2) currentpos += thishdr_size; 841 if (thishdr_type < 2) currentpos += thishdr_size;
834 ////qDebug("hyper-cp:%u", currentpos); 842// //odebug << "hyper-cp:" << currentpos << "" << oendl;
835 thisrec++; 843 thisrec++;
@@ -859,3 +867,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
859#endif /* USEQPE */ 867#endif /* USEQPE */
860 //qDebug("Link:%s", (const char*)wrd); 868 //odebug << "Link:" << wrd << "" << oendl;
861 // setlink(fn, wrd); 869 // setlink(fn, wrd);
@@ -928,3 +936,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
928 } 936 }
929 //qDebug("Hyper:<%u,%u>", tuid, n); 937 //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
930 while (bufferpos < n && bufferpos < buffercontent) getch_base(true); 938 while (bufferpos < n && bufferpos < buffercontent) getch_base(true);
@@ -958,3 +966,3 @@ tchar CPlucker_base::getch_base(bool fast)
958 ch = bgetch(); 966 ch = bgetch();
959 ////qDebug("Function:%x", ch); 967// //odebug << "Function:" << ch << "" << oendl;
960 switch (ch) 968 switch (ch)
@@ -962,3 +970,3 @@ tchar CPlucker_base::getch_base(bool fast)
962 case 0x38: 970 case 0x38:
963 // //qDebug("Break:%u", locate()); 971// //odebug << "Break:" << locate() << "" << oendl;
964 if (m_lastBreak == locate()) 972 if (m_lastBreak == locate())
@@ -982,3 +990,3 @@ tchar CPlucker_base::getch_base(bool fast)
982 ln = (ln << 8) + ch; 990 ln = (ln << 8) + ch;
983 // //qDebug("ch:%d, ln:%u", ch, ln); 991// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
984 } 992 }
@@ -994,6 +1002,6 @@ tchar CPlucker_base::getch_base(bool fast)
994 ln = (ln << 8) + ch; 1002 ln = (ln << 8) + ch;
995 // //qDebug("ch:%d, ln:%u", ch, ln); 1003// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
996 } 1004 }
997 } 1005 }
998 // //qDebug("ln:%u", ln); 1006// //odebug << "ln:" << ln << "" << oendl;
999 mystyle.setLink(true); 1007 mystyle.setLink(true);
@@ -1040,3 +1048,3 @@ tchar CPlucker_base::getch_base(bool fast)
1040 ch = bgetch(); 1048 ch = bgetch();
1041 // //qDebug("Font:%d",ch); 1049// //odebug << "Font:" << ch << "" << oendl;
1042 mystyle.setVOffset(0); 1050 mystyle.setVOffset(0);
@@ -1074,3 +1082,3 @@ tchar CPlucker_base::getch_base(bool fast)
1074 case 8: // should be fixed width 1082 case 8: // should be fixed width
1075 //qDebug("Trying fixed width"); 1083 //odebug << "Trying fixed width" << oendl;
1076 mystyle.setMono(); 1084 mystyle.setMono();
@@ -1089,3 +1097,3 @@ tchar CPlucker_base::getch_base(bool fast)
1089 default: 1097 default:
1090 qDebug("Unrecognised font"); 1098 odebug << "Unrecognised font" << oendl;
1091 break; 1099 break;
@@ -1101,3 +1109,3 @@ tchar CPlucker_base::getch_base(bool fast)
1101 mystyle.setLeftJustify(); 1109 mystyle.setLeftJustify();
1102 // //qDebug("left"); 1110// //odebug << "left" << oendl;
1103 break; 1111 break;
@@ -1105,3 +1113,3 @@ tchar CPlucker_base::getch_base(bool fast)
1105 mystyle.setRightJustify(); 1113 mystyle.setRightJustify();
1106 // //qDebug("right"); 1114// //odebug << "right" << oendl;
1107 break; 1115 break;
@@ -1109,3 +1117,3 @@ tchar CPlucker_base::getch_base(bool fast)
1109 mystyle.setCentreJustify(); 1117 mystyle.setCentreJustify();
1110 // //qDebug("centre"); 1118// //odebug << "centre" << oendl;
1111 break; 1119 break;
@@ -1113,3 +1121,3 @@ tchar CPlucker_base::getch_base(bool fast)
1113 mystyle.setFullJustify(); 1121 mystyle.setFullJustify();
1114 // //qDebug("full"); 1122// //odebug << "full" << oendl;
1115 break; 1123 break;
@@ -1136,3 +1144,3 @@ tchar CPlucker_base::getch_base(bool fast)
1136 { 1144 {
1137 //qDebug("Alternate image:%x", ir); 1145 //odebug << "Alternate image:" << ir << "" << oendl;
1138 UInt16 ir2 = bgetch(); 1146 UInt16 ir2 = bgetch();
@@ -1151,3 +1159,3 @@ tchar CPlucker_base::getch_base(bool fast)
1151 } 1159 }
1152 // if (mystyle.getLink()) qDebug("Picture link!"); 1160// if (mystyle.getLink()) odebug << "Picture link!" << oendl;
1153 ch = '#'; 1161 ch = '#';
@@ -1162,3 +1170,3 @@ tchar CPlucker_base::getch_base(bool fast)
1162 UInt16 w = wc; 1170 UInt16 w = wc;
1163 // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); 1171// //odebug << "h,w,pc [" << h << ", " << w << ", " << pc << "]" << oendl;
1164 if (w == 0) 1172 if (w == 0)
@@ -1169,3 +1177,3 @@ tchar CPlucker_base::getch_base(bool fast)
1169 mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); 1177 mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue()));
1170 // if (mystyle.getLink()) //qDebug("hRule link!"); 1178// if (mystyle.getLink()) //odebug << "hRule link!" << oendl;
1171 ch = '#'; 1179 ch = '#';
@@ -1184,6 +1192,6 @@ tchar CPlucker_base::getch_base(bool fast)
1184 mystyle.setLeftMargin(ch); 1192 mystyle.setLeftMargin(ch);
1185 // //qDebug("Left margin:%d", ch); 1193// //odebug << "Left margin:" << ch << "" << oendl;
1186 ch = bgetch(); 1194 ch = bgetch();
1187 mystyle.setRightMargin(ch); 1195 mystyle.setRightMargin(ch);
1188 // //qDebug("Right margin:%d", ch); 1196// //odebug << "Right margin:" << ch << "" << oendl;
1189 ch = bgetch(); 1197 ch = bgetch();
@@ -1205,3 +1213,3 @@ tchar CPlucker_base::getch_base(bool fast)
1205 for (int i = 0; i < tlen; i++) bgetch(); 1213 for (int i = 0; i < tlen; i++) bgetch();
1206 //qDebug("Function 83"); 1214 //odebug << "Function 83" << oendl;
1207 } 1215 }
@@ -1210,3 +1218,3 @@ tchar CPlucker_base::getch_base(bool fast)
1210 default: 1218 default:
1211 qDebug("Function:%x NOT IMPLEMENTED", ch); 1219 odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl;
1212 { 1220 {
@@ -1216,3 +1224,3 @@ tchar CPlucker_base::getch_base(bool fast)
1216 ch = bgetch(); 1224 ch = bgetch();
1217 //qDebug("Arg %d, %d", i, ch); 1225 //odebug << "Arg " << i << ", " << ch << "" << oendl;
1218 } 1226 }