[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/graphics/okular/mobipocket
From: Jakub Stachowski <qbast () go2 ! pl>
Date: 2008-11-10 20:59:56
Message-ID: 1226350796.621676.27498.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 882506 by qbast:
Detect DRMed files and show error instead of mangled content
M +3 -2 converter.cpp
M +0 -5 mobidocument.cpp
M +0 -1 mobidocument.h
M +10 -3 mobipocket.cpp
M +3 -0 mobipocket.h
--- trunk/playground/graphics/okular/mobipocket/converter.cpp #882505:882506
@@ -49,8 +49,9 @@
QTextDocument* Converter::convert( const QString &fileName )
{
MobiDocument* newDocument=new MobiDocument(fileName);
- if (!newDocument->isValid()) {
- emit error(i18n("Error while opening the Mobipocket document."), -1);
+ if (!newDocument->mobi()->isValid()) {
+ if (newDocument->mobi()->hasDRM()) emit error(i18n("This book is protected by \
DRM and can be displayed only on designated device"), -1); + else emit \
error(i18n("Error while opening the Mobipocket document."), -1); delete newDocument;
return NULL;
}
--- trunk/playground/graphics/okular/mobipocket/mobidocument.cpp #882505:882506
@@ -22,11 +22,6 @@
if (doc->isValid()) setHtml(fixMobiMarkup(doc->text()));
}
-bool MobiDocument::isValid() const
-{
- return doc->isValid();
-}
-
MobiDocument::~MobiDocument()
{
delete doc;
--- trunk/playground/graphics/okular/mobipocket/mobidocument.h #882505:882506
@@ -24,7 +24,6 @@
public:
MobiDocument(const QString &fileName);
- bool isValid() const;
~MobiDocument();
Mobipocket::Document* mobi() const { return doc; }
--- trunk/playground/graphics/okular/mobipocket/mobipocket.cpp #882505:882506
@@ -86,7 +86,7 @@
////////////////////////////////////////////
struct DocumentPrivate
{
- DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), \
isUtf(false) {} + DocumentPrivate(QIODevice* d) : pdb(d), valid(true), \
firstImageRecord(0), isUtf(false), drm(false) {} PDB pdb;
Decompressor* dec;
quint16 ntextrecords;
@@ -94,6 +94,7 @@
quint16 firstImageRecord;
QMap<Document::MetaKey, QString> metadata;
bool isUtf;
+ bool drm;
void init();
void findFirstImage();
@@ -137,7 +138,8 @@
if (!valid) return;
QByteArray mhead=pdb.getRecord(0);
dec = Decompressor::create(mhead[1], pdb);
- if (!dec) {
+ if ((int)mhead[12]!=0 || (int)mhead[13]!=0) drm=true;
+ if (!dec || drm) {
valid=false;
return;
}
@@ -232,7 +234,7 @@
bool Document::isValid() const
{
- return d->pdb.isValid();
+ return d->valid;
}
QImage Document::getImage(int i) const
@@ -248,4 +250,9 @@
return d->metadata;
}
+bool Document::hasDRM() const
+{
+ return d->drm;
}
+
+}
--- trunk/playground/graphics/okular/mobipocket/mobipocket.h #882505:882506
@@ -43,6 +43,9 @@
int imageCount() const;
QImage getImage(int i) const;
bool isValid() const;
+
+ // if true then isValid() will return false
+ bool hasDRM() const;
private:
DocumentPrivate* const d;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic