diff --git a/ChangeLog.txt b/ChangeLog.txt
index c97044e..84b5b59 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,9 @@
+2017-04-07 10:49 cytown
+
+ * add txt file opened by kpvbooklet
+ * add KUAL KPVBooklet Settings feature for user controll opened by
+ KOReader/HackedUpReader/Original
+
2016-07-17 13:53 chrox
* check new document settings path for updating progress and possibly add
diff --git a/README.md b/README.md
index e721fd4..489ff49 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,11 @@
KPVBooklet for Kindle Touch, Kindle Paperwhite, New Kindle and Kindle Voyage
======================================
-KPVBooklet is a Kindle booklet for starting KoReader
+KPVBooklet is a Kindle booklet for starting KoReader/HackedUpReader
and updating last access and percentage finished information
in Kindle content catalog entry of the opened document.
+User can switch the open type in KUAL KPVBooklet extentions.
+
KPVBooklet is licensed under the MIT license. See the file
LICENSE for more details.
diff --git a/README_FIRST.txt b/README_FIRST.txt
index f90f7d2..185ceaa 100644
--- a/README_FIRST.txt
+++ b/README_FIRST.txt
@@ -1,7 +1,7 @@
KPVBooklet for Kindle Touch, Kindle Paperwhite and Kindle Voyage
=================================================
-KPVBooklet is a Kindle booklet for starting KOReader.
+KPVBooklet is a Kindle booklet for starting KOReader/HackedUpReader.
It also updates last access and percentage finished information in Kindle's
content catalog entry of the opened document.
diff --git a/build-updates.sh b/build-updates.sh
index 6267b43..af41a89 100755
--- a/build-updates.sh
+++ b/build-updates.sh
@@ -2,7 +2,7 @@
HACKNAME="kpvbooklet"
PKGNAME="${HACKNAME}"
-PKGVER="0.6.4"
+PKGVER="0.6.5"
# We need kindletool (https://github.com/NiLuJe/KindleTool) in $PATH
if (( $(kindletool version | wc -l) == 1 )) ; then
@@ -16,6 +16,9 @@ fi
# We also need GNU tar
TAR_BIN="tar"
+if [[ "$OSTYPE" == "darwin"* ]] ; then
+ TAR_BIN="gtar"
+fi
if ! ${TAR_BIN} --version | grep "GNU tar" > /dev/null 2>&1 ; then
echo "You need GNU tar to build this package."
exit 1
@@ -29,6 +32,7 @@ cp -f install.ffs build/install/install.ffs
cp -f build/jar/KPVBooklet.jar build/install/KPVBooklet.jar
cp -f mimes.install.sql build/install/mimes.install.sql
cp -f whispertouch.install.sql build/install/whispertouch.install.sql
+cp -rf extensions build/install/
cp -f uninstall.ffs build/uninstall/uninstall.ffs
cp -f mimes.uninstall.sql build/uninstall/mimes.uninstall.sql
diff --git a/build.xml b/build.xml
index 4cbebb5..3e5a1cc 100644
--- a/build.xml
+++ b/build.xml
@@ -7,8 +7,8 @@
-
-
+
+
@@ -17,15 +17,16 @@
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/extensions/kpvbooklet/config.xml b/extensions/kpvbooklet/config.xml
new file mode 100755
index 0000000..ff54bee
--- /dev/null
+++ b/extensions/kpvbooklet/config.xml
@@ -0,0 +1,12 @@
+
+
+
+ KPVBooklet
+ 0.1
+ cytown@gmail.com
+ KPVBooklet
+
+
+
+
+
diff --git a/extensions/kpvbooklet/menu.json b/extensions/kpvbooklet/menu.json
new file mode 100755
index 0000000..d1aacd2
--- /dev/null
+++ b/extensions/kpvbooklet/menu.json
@@ -0,0 +1,210 @@
+{
+ "items": [
+ {
+ "name": "KPVBooklet Settings",
+ "if": "\"/mnt/us/hackedupreader/bin/cr3\" -f",
+ "priority": 5,
+ "items": [
+
+ {
+ "name": "PDF file opened by KO* (Original)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdf=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdf=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "pdf 0",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set PDF opened by Original"
+ },
+ {
+ "name": "PDF file opened by Original* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdf=0$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "pdf 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set PDF opened by KOReader"
+ },
+ {
+ "name": "TXT file opened by KO* (HackedUp, Original)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "txt 2",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set TXT opened by HackedUpReader"
+ },
+ {
+ "name": "TXT file opened by HackedUp* (Original, KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=2$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "txt 0",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set TXT opened by Original"
+ },
+ {
+ "name": "TXT file opened by Original* (KO, HackedUp)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=0$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "txt 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set TXT opened by KOReader"
+ },
+ {
+ "name": "EPUB file opened by KO* (HackedUp)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^epub=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^epub=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "epub 2",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set EPUB opened by HackedUpReader"
+ },
+ {
+ "name": "EPUB file opened by HackedUp* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^epub=2$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "epub 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set EPUB opened by KOReader"
+ },
+ {
+ "name": "PDB file opened by KO* (HackedUp)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdb=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdb=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "pdb 2",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set PDB opened by HackedUpReader"
+ },
+ {
+ "name": "PDB file opened by HackedUp* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdb=2$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "pdb 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set PDB opened by KOReader"
+ },
+ {
+ "name": "FB2 file opened by KO* (HackedUp)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^fb2=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^fb2=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "fb2 2",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set FB2 opened by HackedUpReader"
+ },
+ {
+ "name": "FB2 file opened by HackedUp* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^fb2=2$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "fb2 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set FB2 opened by KOReader"
+ },
+ {
+ "name": "RTF file opened by KO* (HackedUp)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^rtf=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^rtf=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "rtf 2",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set RTF opened by HackedUpReader"
+ },
+ {
+ "name": "RTF file opened by HackedUp* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^rtf=2$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "rtf 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set RTF opened by KOReader"
+ },
+ {
+ "name": "CHM file opened by KO* (HackedUp)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^chm=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^chm=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "chm 2",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set CHM opened by HackedUpReader"
+ },
+ {
+ "name": "CHM file opened by HackedUp* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^chm=2$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "chm 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set CHM opened by KOReader"
+ }
+ ]
+ },
+ {
+ "name": "KPVBooklet Settings",
+ "if": "\"/mnt/us/hackedupreader/bin/cr3\" -f!",
+ "priority": 5,
+ "items": [
+
+ {
+ "name": "PDF file opened by KO* (Original)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdf=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdf=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "pdf 0",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set PDF opened by Original"
+ },
+ {
+ "name": "PDF file opened by Original* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^pdf=0$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "pdf 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set PDF opened by KOReader"
+ },
+ {
+ "name": "TXT file opened by KO* (Original)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=\" -g! \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=1$\" -g || ||",
+ "action": "./bin/booklet.sh",
+ "params": "txt 0",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set TXT opened by HackedUpReader"
+ },
+ {
+ "name": "TXT file opened by Original* (KO)",
+ "if": "\"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" -f \"/mnt/us/extensions/kpvbooklet/bin/booklet.ini\" \"^txt=0$\" -g &&",
+ "action": "./bin/booklet.sh",
+ "params": "txt 1",
+ "refresh": true,
+ "exitmenu": false,
+ "status": false,
+ "internal": "status set TXT opened by KOReader"
+ }
+ ]
+ }
+ ]
+}
diff --git a/install.ffs b/install.ffs
index bd8fc21..e7f7a9f 100755
--- a/install.ffs
+++ b/install.ffs
@@ -57,7 +57,10 @@ if [ "$VERSION" \> "5.4" ]; then
touch "/MNTUS_EXEC"
fi
-progress 80 "Mounting ro"
+progress 80 "Installing KUAL Extension"
+cp -r extensions/kpvbooklet /mnt/us/extensions/ || fail "Unable to copy KUAL Extension"
+
+progress 90 "Mounting ro"
mntroot ro || fail "Unable to mount ro"
progress 100 "Installation complete."
diff --git a/mimes.install.sql b/mimes.install.sql
index 8d56449..1b81366 100644
--- a/mimes.install.sql
+++ b/mimes.install.sql
@@ -16,6 +16,8 @@ INSERT OR IGNORE INTO "associations" VALUES('com.github.koreader.kpvbooklet','de
INSERT OR IGNORE INTO "associations" VALUES('com.github.koreader.kpvbooklet','application','MT:application/pdf','true');
+INSERT OR IGNORE INTO "associations" VALUES('com.github.koreader.kpvbooklet','application','MT:text/plain','true');
+
INSERT OR IGNORE INTO "mimetypes" VALUES('djvu','MT:image/x.djvu');
INSERT OR IGNORE INTO "extenstions" VALUES('djvu','MT:image/x.djvu');
INSERT OR IGNORE INTO "properties" VALUES('archive.displaytags.mimetypes','image/x.djvu','DjVu');
@@ -84,3 +86,6 @@ INSERT OR IGNORE INTO "associations" VALUES('com.github.koreader.kpvbooklet','ap
UPDATE "associations" SET defaultAssoc = 'false' WHERE interface = 'application' and contentId = 'MT:application/pdf' and handlerId = 'com.lab126.booklet.reader';
UPDATE "associations" SET defaultAssoc = 'true' WHERE interface = 'application' and contentId = 'MT:application/pdf' and handlerId = 'com.github.koreader.kpvbooklet';
+
+UPDATE "associations" SET defaultAssoc = 'false' WHERE interface = 'application' and contentId = 'MT:text/plain' and handlerId = 'com.lab126.booklet.reader';
+UPDATE "associations" SET defaultAssoc = 'true' WHERE interface = 'application' and contentId = 'MT:text/plain' and handlerId = 'com.github.koreader.kpvbooklet';
diff --git a/mimes.uninstall.sql b/mimes.uninstall.sql
index 4924b4d..100944c 100644
--- a/mimes.uninstall.sql
+++ b/mimes.uninstall.sql
@@ -13,3 +13,4 @@ DELETE FROM "associations" WHERE contentId='GL:*.doc' OR contentId='GL:*.fb2' OR
DELETE FROM "associations" WHERE contentId='GL:*.tcr' OR contentId='GL:*.xps' OR contentId='GL:*.zip';
UPDATE "associations" SET defaultAssoc = 'true' WHERE interface = 'application' and contentId = 'MT:application/pdf' and handlerId = 'com.lab126.booklet.reader';
+UPDATE "associations" SET defaultAssoc = 'true' WHERE interface = 'application' and contentId = 'MT:text/plain' and handlerId = 'com.lab126.booklet.reader';
diff --git a/src/com/github/chrox/kpvbooklet/KPVBooklet.java b/src/com/github/chrox/kpvbooklet/KPVBooklet.java
index 81b907c..0f504b7 100644
--- a/src/com/github/chrox/kpvbooklet/KPVBooklet.java
+++ b/src/com/github/chrox/kpvbooklet/KPVBooklet.java
@@ -4,6 +4,9 @@
import java.net.URI;
import java.lang.reflect.Field;
import java.io.PrintStream;
+import java.util.Properties;
+
+import org.kxml2.io.KXmlParser;
import com.github.chrox.kpvbooklet.ccadapter.CCAdapter;
import com.github.chrox.kpvbooklet.util.Log;
@@ -34,7 +37,7 @@ public int getIntProperty(String property) throws LipcException {
} else {
return 0;
}
- }
+ }
public void setProperty(String property, int val) throws LipcException {
if (property.equals("set")) {
counter = val;
@@ -43,7 +46,7 @@ public void setProperty(String property, int val) throws LipcException {
} else if(property.equals("reset")) {
counter = 0;
}
- }
+ }
}
public static int getCounter() {
@@ -54,7 +57,7 @@ public static void addCounter(int count) {
counter += count;
}
- public static void addBookletCounter() {
+ public static void addBookletCounter() {
try {
LipcSource source = LipcService.getInstance().createSource(timersource);
LipcPropertyProvider timerproperty = new TimerProperties();
@@ -66,7 +69,7 @@ public static void addBookletCounter() {
} catch(LipcException e) {
logger.println("E: " + e.toString());
e.printStackTrace(logger);
- }
+ }
}
}
@@ -74,23 +77,28 @@ public static void addBookletCounter() {
* A booklet for launching koreader directly from Kindle home screen.
*
* Modified by chrox@github.
+ * Modified by cytown@github
*
* @author Patric Mueller <bhaak@gmx.net>
*/
public class KPVBooklet extends ReaderBooklet {
- private final String koreader = "/mnt/us/koreader/koreader.sh";
- private final String kor_history = "/mnt/us/koreader/history/";
- private final String kpdfview = "/mnt/us/kindlepdfviewer/kpdf.sh";
- private final String kpv_history = "/mnt/us/kindlepdfviewer/history/";
- private final String gandalf = "/var/local/mkk/gandalf";
- private final String su = "/var/local/mkk/su";
+ private final String BOOKLET_CONFIG = "/mnt/us/extensions/kpvbooklet/bin/booklet.ini";
+ private final String HACKUP_READER = "/mnt/us/hackedupreader/bin/cr3";
+ private final String HACKUP_READER_HISTORY = "/mnt/us/hackedupreader/.settings/cr3hist.bmk";
+ private final String KOREADER = "/mnt/us/koreader/koreader.sh";
+ private final String KOR_HISTORY = "/mnt/us/koreader/history/";
+ private final String KPDFVIEW = "/mnt/us/kindlepdfviewer/kpdf.sh";
+ private final String KPV_HISTORY = "/mnt/us/kindlepdfviewer/history/";
+ private final String GANDALF = "/var/local/mkk/gandalf";
+ private final String SU = "/var/local/mkk/su";
private static String PRIVILEGE_HINT_PREFIX = "?";
private Process readerProcess;
private String history_dir;
private CCAdapter ccrequest = CCAdapter.INSTANCE;
- private static final PrintStream logger = Log.INSTANCE;
+ private static final PrintStream LOGGER = Log.INSTANCE;
+ private boolean isHackupExist;
public KPVBooklet() {
// Check current privileges...
@@ -98,16 +106,46 @@ public KPVBooklet() {
if ("root".equals(currentUsername)) {
PRIVILEGE_HINT_PREFIX = "#";
} else {
- if (new File(gandalf).exists()) {
+ if (new File(GANDALF).exists()) {
PRIVILEGE_HINT_PREFIX = "$";
} else {
PRIVILEGE_HINT_PREFIX = "%";
}
}
log("I: KPVBooklet");
+ isHackupExist = new File(HACKUP_READER).exists();
+
BookletTimer.addBookletCounter();
}
+ private String getOpenType(String type) {
+ Properties prop = new Properties();
+ InputStream input = null;
+ String openType = "1";
+
+ try {
+
+ input = new FileInputStream(BOOKLET_CONFIG);
+
+ // load a properties file
+ prop.load(input);
+
+ // get the property value and print it out
+ openType = (prop.getProperty(type, "1"));
+ } catch (Exception ex) {
+ log("W:" + ex.toString());
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (Exception e) {
+ log("W:" + e.toString());
+ }
+ }
+ }
+ return openType;
+ }
+
public void start(URI contentURI) {
log("I: start()");
log("I: kpvbooklet launching times " + BookletTimer.getCounter());
@@ -115,34 +153,36 @@ public void start(URI contentURI) {
String path = contentURI.getPath();
int dot = path.lastIndexOf('.');
String ext = (dot == -1) ? "" : path.substring(dot+1).toLowerCase();
- if (ext.equals("pdf")) {
- String query = contentURI.getQuery();
- if (query != null && query.indexOf("action=goto") >= 0) {
- log("I: Opening " + path + " with native reader...");
- super.start(contentURI);
- return;
- }
+ String openType = getOpenType(ext);
+ if (openType.equals("0")) {
+ log("I: Opening " + path + " with native reader...");
+ super.start(contentURI);
+ return;
+ }
+ String reader = KOREADER;
+ if (isHackupExist && openType.equals("2")) {
+ reader = HACKUP_READER;
}
- log("I: Opening " + path + " with koreader...");
+ log("I: Opening " + path + " with " + reader + "...");
String[] cmd;
if ("$".equals(PRIVILEGE_HINT_PREFIX)) {
log("I: Call Gandalf for help...");
- cmd = new String[] {su, "-s", "/bin/ash", "-c", koreader + " \"" + path + "\""};
+ cmd = new String[] {SU, "-s", "/bin/ash", "-c", reader + " \"" + path + "\""};
} else {
- cmd = new String[] {"/bin/sh", koreader, path};
+ cmd = new String[] {"/bin/sh", reader, path};
}
try {
readerProcess = Runtime.getRuntime().exec(cmd);
- history_dir = kor_history;
+ history_dir = KOR_HISTORY;
} catch (IOException e) {
readerProcess = null;
log("W: koreader not found, will check legacy kindlepdfviewer instead.");
}
// fallback to kpdf.sh if we cannot exec koreader.sh
- if (readerProcess == null) {
+ if (readerProcess == null && !openType.equals("2")) {
log("I: Opening " + path + " with kindlepdfviewer...");
- cmd[cmd.length - 2] = kpdfview;
- history_dir = kpv_history;
+ cmd[cmd.length - 2] = KPDFVIEW;
+ history_dir = KPV_HISTORY;
try {
readerProcess = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
@@ -150,7 +190,7 @@ public void start(URI contentURI) {
}
}
- Thread thread = new ReaderWaitThread(history_dir, path);
+ Thread thread = new ReaderWaitThread(history_dir, path, openType);
thread.start();
}
@@ -193,10 +233,12 @@ private void killQuitProcess(Process process)
class ReaderWaitThread extends Thread {
private String history_dir = "";
private String content_path = "";
+ private String openType = "";
- public ReaderWaitThread(String dir, String path) {
+ public ReaderWaitThread(String dir, String path, String type) {
history_dir = dir;
content_path = path;
+ openType = type;
}
public void run() {
try {
@@ -208,7 +250,16 @@ public void run() {
try {
// update content catlog after reader exits
- ccrequest.updateCC(content_path, extractPercentFinished(history_dir, content_path));
+ float last_percent = 0f;
+ if (openType.equals("2")) {
+ last_percent = extractPercentFinished2(content_path);
+ } else {
+ last_percent = extractPercentFinished(history_dir, content_path);
+ }
+ log("I: update percent: " + last_percent);
+ if (last_percent >= 0f) {
+ ccrequest.updateCC(content_path, last_percent);
+ }
} catch (Exception e) {
log("E: " + e.toString());
}
@@ -258,15 +309,83 @@ private float extractPercentFinished(String history_dir, String path) {
percent_finished = Float.parseFloat(value) * 100;
}
}
- }
- br.close();
+ }
+ br.close();
} catch (IOException e) {
log("E: " + e.toString());
}
return percent_finished;
}
+ /**
+ * Extract last_percent in document history file
+ * @param file path
+ */
+ private float extractPercentFinished2(String path) {
+ float percent_finished = -1.0f;
+ int lastSlash = path.lastIndexOf('/');
+ String parentname = (lastSlash == -1) ? "" : path.substring(0, lastSlash+1);
+ String filename = (lastSlash == -1) ? "" : path.substring(lastSlash+1);
+ File settingsFile = new File(HACKUP_READER_HISTORY);
+ if (!settingsFile.exists()) {
+ return -1f;
+ }
+
+ log("I: find hackedupreader settings for: " + path);
+ FileInputStream stream = null;
+ try {
+ KXmlParser parser = new KXmlParser();
+ parser.setFeature(KXmlParser.FEATURE_PROCESS_NAMESPACES, true);
+ stream = new FileInputStream(settingsFile);
+ // skip it because the file header has
+ stream.skip(3);
+ parser.setInput(stream, "UTF-8");
+ String currName = null;
+ String currPath = null;
+ while(parser.next() != KXmlParser.END_DOCUMENT){
+ if (parser.getEventType() == KXmlParser.START_TAG) {
+
+ String n = parser.getName();
+ // log("name: " + n);
+ if ("file".equals(n)) {
+ currName = null;
+ currPath = null;
+ }
+ if ("doc-filename".equals(n)) {
+ currName = parser.nextText();
+ log("filename === " + currName);
+ }
+ if ("doc-filepath".equals(n)) {
+ currPath = parser.nextText();
+ log("path === " + currPath);
+ }
+ if ("bookmark".equals(n) && filename.equals(currName) && parentname.equals(currPath)) {
+ String type = parser.getAttributeValue(null, "type");
+ if ("lastpos".equals(type)) {
+ String percent = parser.getAttributeValue(null, "percent");
+ percent = percent.substring(0, percent.length() - 1);
+ float fff = Float.parseFloat(percent);
+ log("found === " + type + " : " + percent + " : " + fff);
+ percent_finished = fff;
+ break;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ log("E: " + e.toString());
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (Exception e) {}
+ }
+ }
+ return percent_finished;
+ }
+
private void log(String msg) {
- logger.println(msg);
+ LOGGER.println(msg);
}
}
diff --git a/uninstall.ffs b/uninstall.ffs
index 6c4c8f5..044d646 100755
--- a/uninstall.ffs
+++ b/uninstall.ffs
@@ -42,6 +42,9 @@ progress 50 "Restoring appreg.db"
[ -f /var/local/appreg.db.bak ] && rm -f /var/local/appreg.db.bak
sqlite3 /var/local/appreg.db < mimes.uninstall.sql
+progress 70 "Removing KUAL Extension"
+rm -rf /mnt/us/extensions/kpvbooklet
+
progress 80 "Mounting ro"
mntroot ro || fail "Unable to mount ro"