summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Bkmks.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/Bkmks.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp107
1 files changed, 93 insertions, 14 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 480c240..440d8be 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -4,2 +4,4 @@
+#include "StyleConsts.h"
+#include "Markups.h"
#include "my_list.h"
@@ -10,3 +12,3 @@ const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned lo
-Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p)
+Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p)
{
@@ -22,3 +24,15 @@ Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_
{
+ if (_anno == NULL)
+ {
+ tchar t = 0;
+ init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
+ }
+ else
+ {
+ init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
+ }
+}
+Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p)
+{
if (_anno == NULL)
@@ -32,2 +46,4 @@ Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_
}
+ m_position2 = _p2;
+ m_red = m_green = m_blue = 127;
}
@@ -58,2 +74,5 @@ void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsig
m_position = _p;
+ m_position2 = _p;
+ m_red = m_green = m_blue = 255;
+ m_level = 0;
}
@@ -97,2 +116,7 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs)
m_position = rhs.m_position;
+ m_position2 = rhs.m_position2;
+ m_red = rhs.m_red;
+ m_green = rhs.m_green;
+ m_blue = rhs.m_blue;
+ m_level = rhs.m_level;
return *this;
@@ -102,3 +126,3 @@ bool Bkmk::operator==(const Bkmk& rhs)
{
- return (m_position == rhs.m_position && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0);
+ return ((m_position == rhs.m_position) && (m_position2 == rhs.m_position2) && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0);
}
@@ -148,5 +172,5 @@ void Bkmk::setAnno(tchar* t)
-BkmkFile::BkmkFile(const char *fnm, bool w)
- :
- wt(w), isUpgraded(false)
+BkmkFile::BkmkFile(const char *fnm, bool w, bool _x)
+ :
+ wt(w), isUpgraded(false), m_extras(_x)
{
@@ -176,2 +200,10 @@ void BkmkFile::write(const Bkmk& b)
fwrite(&b.m_position,sizeof(b.m_position),1,f);
+ if (m_extras)
+ {
+ fwrite(&b.m_position2,sizeof(b.m_position2),1,f);
+ fwrite(&b.m_red,sizeof(b.m_red),1,f);
+ fwrite(&b.m_green,sizeof(b.m_green),1,f);
+ fwrite(&b.m_blue,sizeof(b.m_blue),1,f);
+ fwrite(&b.m_level,sizeof(b.m_level),1,f);
+ }
}
@@ -216,6 +248,11 @@ CList<Bkmk>* BkmkFile::readall()
{
- case 6:
+ case 7:
isUpgraded = false;
+ bl = readall00(read07);
+// qDebug("Correct version!");
+ break;
+ case 6:
+ isUpgraded = true;
bl = readall00(read06);
-// odebug << "Correct version!" << oendl;
+// qDebug("Correct version!");
break;
@@ -224,6 +261,6 @@ CList<Bkmk>* BkmkFile::readall()
bl = readall00(read05);
-// odebug << "Known version!" << oendl;
+// qDebug("Known version!");
break;
default:
-// odebug << "Unknown version!" << oendl;
+// qDebug("Unknown version!");
isUpgraded = true;
@@ -236,3 +273,3 @@ CList<Bkmk>* BkmkFile::readall()
-CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*))
+CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(BkmkFile*, FILE*))
{
@@ -241,3 +278,3 @@ CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*))
{
- Bkmk* b = (*readfn)(f);
+ Bkmk* b = (*readfn)(this, f);
if (b == NULL) break;
@@ -249,3 +286,3 @@ CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*))
-Bkmk* BkmkFile::read03(FILE* f)
+Bkmk* BkmkFile::read03(BkmkFile* /*_this*/, FILE* f)
{
@@ -273,3 +310,3 @@ Bkmk* BkmkFile::read03(FILE* f)
-Bkmk* BkmkFile::read05(FILE* f)
+Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f)
{
@@ -296,3 +333,3 @@ Bkmk* BkmkFile::read05(FILE* f)
-Bkmk* BkmkFile::read06(FILE* f)
+Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f)
{
@@ -316,2 +353,5 @@ Bkmk* BkmkFile::read06(FILE* f)
fread(&(b->m_position),sizeof(b->m_position),1,f);
+ b->m_position2 = b->m_position+b->m_namelen-1;
+ b->m_red = b->m_green = b->m_blue = 127;
+ b->m_level = 0;
}
@@ -320 +360,40 @@ Bkmk* BkmkFile::read06(FILE* f)
}
+
+Bkmk* BkmkFile::read07(BkmkFile* _this, FILE* f)
+{
+ Bkmk* b = NULL;
+ if (f != NULL)
+ {
+ unsigned short ln;
+ if (fread(&ln,sizeof(ln),1,f) == 1)
+ {
+ b = new Bkmk;
+ b->m_namelen = ln;
+ b->m_name = new unsigned char[b->m_namelen];
+ fread(b->m_name,1,b->m_namelen,f);
+
+ fread(&(b->m_annolen),sizeof(b->m_annolen),1,f);
+ if (b->m_annolen > 0)
+ {
+ b->m_anno = new unsigned char[b->m_annolen];
+ fread(b->m_anno,1,b->m_annolen,f);
+ }
+ fread(&(b->m_position),sizeof(b->m_position),1,f);
+ if (_this->m_extras)
+ {
+ fread(&(b->m_position2),sizeof(b->m_position2),1,f);
+ fread(&(b->m_red),sizeof(b->m_red),1,f);
+ fread(&(b->m_green),sizeof(b->m_green),1,f);
+ fread(&(b->m_blue),sizeof(b->m_blue),1,f);
+ fread(&(b->m_level),sizeof(b->m_level),1,f);
+ }
+ else
+ {
+ b->m_position2 = b->m_position;
+ b->m_red = b->m_green = b->m_blue = 255;
+ b->m_level = 0;
+ }
+ }
+ }
+ return b;
+}