koreader / kindlepdfviewer

(DEPRECATED, please use KOReader instead) A PDF (plus DJVU, ePub, TXT, CHM, FB2, HTML...) viewer made for e-ink framebuffer devices, using muPDF, djvulibre, crengine
GNU General Public License v3.0
498 stars 98 forks source link

Just another KPV launcher for KPW (Deprecated) #648

Closed chrox closed 11 years ago

chrox commented 11 years ago

I have implemented a prototype of KPV launcher for Kindle touch and Kindle Paperwhite. The launcher runs as a JBPatch which overrides native Kindle ReaderBooklet class on handling PDF documents in runtime. The source code can be found at https://gist.github.com/4193209

With this patch when opening certain types of documents in Kindle's home screen KPV is launched with the file path as the second parameter. And it will return to Kindle home screen when KPV is closed. In this way of launching KPV is treated more as a reader plugin than as a standalone reader app.

An obvious shortcoming of this launching method is that patches probably need to be compiled against almost every future firmware version thanks to Amazon's 'ever-more aggressive' obfuscation in the run-time libraries.

DO_NOT_INSTALL_THIS_LAUNCHER_IT_HAS_HIGH_PROBABILITY_TO_BRICK_YOUR_KPW

HOW_TO_INSTALL:

  1. copy jbpatch.jar to /opt/amazon/ebook/lib (You should compile the lattest version 3 from https://bitbucket.org/ixtab/jbpatcher/)
  2. add -istart jbpatch.jar before any other -istart line in /opt/amazon/ebook/bin/init.xargs
  3. compile com.mobileread.chrox.patch.kpw.kpvlauncher.530.jar from the gist mentioned above and copy it to /mnt/us/opt/jbpatch
  4. modify kpdf.sh in KPV dist according to the gist mentioned above
  5. run restart framework in your kindle

Binaries of jbpatch.jar and com.mobileread.chrox.patch.kpw.kpvlauncher.530.jar can be downloaded at https://github.com/chrox/misc/downloads if you don't want to compile them yourself. You need to select binaries according to your firmware version.

HOW_TO_ADD_MORE_TYPES: The SQLite database located at /var/local/appreg.db defines application association and document mime types. You can simply insert these records into appreg.db as follows to support EPUB type:

INSERT INTO "mimetypes" VALUES('epub','MT:application/epub+zip');
INSERT INTO "extenstions" VALUES('epub','MT:application/epub+zip');
INSERT INTO "properties" VALUES('archive.displaytags.mimetypes','application/epub+zip','EPUB');
INSERT INTO "associations" VALUES('com.lab126.booklet.reader','application','MT:application/epub+zip','true');
INSERT INTO "associations" VALUES('com.lab126.generic.extractor','extractor','GL:*.epub','true');

And in the gist https://gist.github.com/4193209 up to 15 mime types and app association records are predefined in mimes.sql. After running sqlite3 appreg.db < mimes.sql and restart scanner your kindle should be able to recognize "djvu","epub","cbz","chm","doc","fb2","htm","html","pdb","rtf","tcr","xps","zip" files in home screen. And opening these documents will launch KPV accordingly.

HOW_TO_DEBUG: When kindle framework is started jbpatch.jar is automatically loaded as configed in /opt/amazon/ebook/bin/init.xargs. You can watch the jbpatch log with the command of watch 'tail /tmp/jbpatch.log' and spot any bug of this patch.

KNOWN_BUGS:

Occasionally when returned from KPV to Kindle home screen there is an "Application Error" dialog showing that an application could not be started. So you should close the dialog before any other operation. I am thinking about how to eliminate this dialog.

SUGGESTED_FEATURES: Reading history and progress should be synchronizable between native ContentCatalog and KPV.