diff --git a/Makefile b/Makefile index 92572d1e4..440697ea5 100644 --- a/Makefile +++ b/Makefile @@ -257,7 +257,6 @@ pbupdate: all cp $(POCKETBOOK_DIR)/koreader.app $(INSTALL_DIR)/applications cp $(POCKETBOOK_DIR)/koreader.app $(INSTALL_DIR)/system/bin - cp $(POCKETBOOK_DIR)/extensions.cfg $(INSTALL_DIR)/system/config cp -rfL $(INSTALL_DIR)/koreader $(INSTALL_DIR)/applications # create new package cd $(INSTALL_DIR) && \ diff --git a/frontend/apps/reader/readerui.lua b/frontend/apps/reader/readerui.lua index 8d68382ba..6aa2b291e 100644 --- a/frontend/apps/reader/readerui.lua +++ b/frontend/apps/reader/readerui.lua @@ -583,6 +583,7 @@ function ReaderUI:doShowReader(file, provider) local _, filename = util.splitFilePathName(file) Screen:setWindowTitle(filename) end + Device:notifyBookState(title, document) UIManager:show(reader) _running_instance = reader @@ -692,6 +693,7 @@ end function ReaderUI:onClose(full_refresh) logger.dbg("closing reader") + Device:notifyBookState(nil, nil) if full_refresh == nil then full_refresh = true end diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index bd8d2da6b..a65bd9296 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -307,6 +307,9 @@ function Device:info() return self.model end +-- Hardware specific method to track opened/closed books (nil on book close) +function Device:notifyBookState(title, document) end + -- Hardware specific method for UI to signal allowed/disallowed standby. -- The device is allowed to enter standby only from within waitForEvents, -- and only if allowed state is true at the time of waitForEvents() invocation. diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index a644f7567..5176788b6 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -17,6 +17,8 @@ _G.POCKETBOOK_FFI = true local function yes() return true end local function no() return false end +local ext_path = "/mnt/ext1/system/config/extensions.cfg" +local app_name = "koreader.app" local PocketBook = Generic:new{ model = "PocketBook", @@ -135,6 +137,18 @@ function PocketBook:init() Generic.init(self) end +function PocketBook:notifyBookState(title, document) + local fn = document and document.file or nil + logger.dbg("Notify book state", title or "[nil]", fn or "[nil]") + os.remove("/tmp/.current") + if fn then + local fo = io.open("/tmp/.current", "w+") + fo:write(fn) + fo:close() + end + inkview.SetSubtaskInfo(inkview.GetCurrentTask(), 0, title and (title .. " - koreader") or "koreader", fn) +end + function PocketBook:setDateTime(year, month, day, hour, min, sec) if hour == nil or min == nil then return true end -- If the device is rooted, we might actually have a fighting chance to change os clock. @@ -154,6 +168,44 @@ function PocketBook:setDateTime(year, month, day, hour, min, sec) end end +-- Predicate, so no self +function PocketBook.canAssociateFileExtensions() + local f = io.open(ext_path, "r") + if not f then return true end + local l = f:read("*line") + f:close() + if l and not l:match("^#koreader") then + return false + end + return true +end + +function PocketBook:associateFileExtensions(assoc) + -- First load the system-wide table, from which we'll snoop file types and icons + local info = {} + for l in io.lines("/ebrmain/config/extensions.cfg") do + local m = { l:match("^([^:]*):([^:]*):([^:]*):([^:]*):(.*)") } + info[m[1]] = m + end + local res = {"#koreader"} + for k,v in pairs(assoc) do + local t = info[k] + if t then + -- A system entry exists, so just change app, and reuse the rest + t[4] = app_name + else + -- Doesn't exist, so hallucinate up something + -- TBD: We have document opener in 'v', maybe consult mime in there? + local bn = k:match("%a+"):upper() + t = { k, '@' .. bn .. '_file', "1", app_name, "ICON_" .. bn } + end + table.insert(res, table.concat(t, ":")) + end + local out = io.open(ext_path, "w+") + out:write(table.concat(res, "\n")) + out:close() +end + function PocketBook:setAutoStandby(isAllowed) inkview.iv_sleepmode(isAllowed and 1 or 0) end diff --git a/platform/pocketbook/extensions.cfg b/platform/pocketbook/extensions.cfg deleted file mode 100644 index 5977d0ee0..000000000 --- a/platform/pocketbook/extensions.cfg +++ /dev/null @@ -1,10 +0,0 @@ -pdf:@PDF_file:1:koreader.app:ICON_PDF -djvu:@DJVU_file:1:koreader.app:ICON_DJVU -epub:@EPUB_file:1:koreader.app:ICON_EPUB -fb2:@FB2_file:1:koreader.app:ICON_FB2 -mobi:@MOBI_file:1:koreader.app:ICON_MOBI -zip:@ZIP_file:1:koreader.app:ICON_ZIP -cbz:@ZIP_file:1:koreader.app:ICON_ZIP - - -