From 62d3310717be06d22f31c5af8fd88efc38066053 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Thu, 9 May 2024 14:26:08 +0100 Subject: [PATCH] PocketBook: Open links in the on-device web browser Many PocketBook devices include a web browser, but when clicking a link in KOReader, there was no option to open the link in the browser, there was only an option to show a QR code (which can then be scanned by a smartphone). This commit implements `canOpenLink`/`openLink` on PocketBook using the "browser.app", if available. Tested on PB740 (InkPad 3). Fixes: https://github.com/koreader/koreader/issues/11782 Related: https://github.com/koreader/koreader/issues/6597 --- frontend/device/pocketbook/device.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index fdb5717c4931..7ccaa758559f 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -428,6 +428,27 @@ function PocketBook:setEventHandlers(uimgr) end end +local function getBrowser() + if util.pathExists("/usr/bin/browser.app") then + return true, "/usr/bin/browser.app" + elseif util.pathExists("/ebrmain/bin/browser.app") then + return true, "/ebrmain/bin/browser.app" + end + return false +end + +function PocketBook:canOpenLink() + return inkview.MultitaskingSupported() and getBrowser() +end + +function PocketBook:openLink(link) + local found, bin = getBrowser() + if not found or not link or type(link) ~= "string" then return end + + local argv = ffi.new("const char *[1]", {link}) + inkview.OpenBook2(bin, 1, argv, 0) +end + -- Pocketbook HW rotation modes start from landsape, CCW local function landscape_ccw() return { 1, 0, 3, 2, -- PORTRAIT, LANDSCAPE, PORTRAIT_180, LANDSCAPE_180