mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
feat: add logger module & rewrite kobo suspend script in lua
This commit is contained in:
@@ -21,7 +21,7 @@ local Event = require("ui/event")
|
||||
local Device = require("device")
|
||||
local util = require("ffi/util")
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local KeyValuePage = require("ui/widget/keyvaluepage")
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
@@ -302,7 +302,7 @@ function FileManager:init()
|
||||
self.loaded_modules = {}
|
||||
-- koreader plugins
|
||||
for _,plugin_module in ipairs(PluginLoader:loadPlugins()) do
|
||||
DEBUG("Loaded plugin", plugin_module.name, "at", plugin_module.path)
|
||||
logger.info("FM loaded plugin", plugin_module.name, "at", plugin_module.path)
|
||||
if not plugin_module.is_doc_only then
|
||||
-- Keep references to the modules which do not register into menu.
|
||||
table.insert(self.loaded_modules, plugin_module:new{ ui = self, })
|
||||
@@ -363,7 +363,7 @@ function FileManager:toggleReverseCollate()
|
||||
end
|
||||
|
||||
function FileManager:onClose()
|
||||
DEBUG("close filemanager")
|
||||
logger.dbg("close filemanager")
|
||||
UIManager:close(self)
|
||||
if self.onExit then
|
||||
self:onExit()
|
||||
|
||||
@@ -8,7 +8,6 @@ local Geom = require("ui/geometry")
|
||||
local Device = require("device")
|
||||
local Screensaver = require("ui/screensaver")
|
||||
local Screen = Device.screen
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
local FileSearcher = require("apps/filemanager/filemanagerfilesearcher")
|
||||
local Search = require("apps/filemanager/filemanagersearch")
|
||||
@@ -335,7 +334,6 @@ end
|
||||
|
||||
function FileManagerMenu:onCloseFileManagerMenu()
|
||||
local last_tab_index = self.menu_container[1].last_index
|
||||
DEBUG("remember menu tab index", last_tab_index)
|
||||
G_reader_settings:saveSetting("filemanagermenu_tab_index", last_tab_index)
|
||||
UIManager:close(self.menu_container)
|
||||
return true
|
||||
|
||||
@@ -9,7 +9,7 @@ local Menu = require("ui/widget/menu")
|
||||
local Screen = require("device").screen
|
||||
local util = require("ffi/util")
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
local SetDefaults = require("apps/filemanager/filemanagersetdefaults")
|
||||
@@ -71,7 +71,7 @@ function Search:getCalibre()
|
||||
-- check if we find the calibre file
|
||||
-- check 1st file
|
||||
if SEARCH_LIBRARY_PATH == nil then
|
||||
DEBUG("search Calibre database")
|
||||
logger.dbg("search Calibre database")
|
||||
self.metafile_1 = findcalibre("/mnt")
|
||||
if not self.metafile_1 then
|
||||
self.error = _("SEARCH_LIBRARY_PATH should be defined in DEFAULTS.LUA.")
|
||||
@@ -85,7 +85,7 @@ function Search:getCalibre()
|
||||
if io.open(SEARCH_LIBRARY_PATH .. calibre,"r") == nil then
|
||||
if io.open(SEARCH_LIBRARY_PATH .. "." .. calibre,"r") == nil then
|
||||
self.error = SEARCH_LIBRARY_PATH .. calibre .. " " .. _("not found.")
|
||||
DEBUG(self.error)
|
||||
logger.err(self.error)
|
||||
else
|
||||
self.metafile_1 = SEARCH_LIBRARY_PATH .. "." .. calibre
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ local FrameContainer = require("ui/widget/container/framecontainer")
|
||||
local OPDSBrowser = require("ui/widget/opdsbrowser")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Screen = require("device").screen
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
@@ -79,7 +79,7 @@ function OPDSCatalog:onCloseWidget()
|
||||
end
|
||||
|
||||
function OPDSCatalog:showCatalog()
|
||||
DEBUG("show OPDS catalog")
|
||||
logger.dbg("show OPDS catalog")
|
||||
UIManager:show(OPDSCatalog:new{
|
||||
dimen = Screen:getSize(),
|
||||
onExit = function()
|
||||
@@ -89,7 +89,7 @@ function OPDSCatalog:showCatalog()
|
||||
end
|
||||
|
||||
function OPDSCatalog:onClose()
|
||||
DEBUG("close OPDS catalog")
|
||||
logger.dbg("close OPDS catalog")
|
||||
UIManager:close(self)
|
||||
if self.onExit then
|
||||
self:onExit()
|
||||
|
||||
@@ -9,7 +9,7 @@ local Screen = require("device").screen
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Event = require("ui/event")
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderBookmark = InputContainer:new{
|
||||
@@ -285,7 +285,7 @@ function ReaderBookmark:addBookmark(item)
|
||||
_middle = math.floor((_start + _end)/2)
|
||||
-- won't add duplicated bookmarks
|
||||
if self:isBookmarkSame(item, self.bookmarks[_middle]) then
|
||||
DEBUG("skip adding duplicated bookmark")
|
||||
logger.warn("skip adding duplicated bookmark")
|
||||
return
|
||||
end
|
||||
if self:isBookmarkInPageOrder(item, self.bookmarks[_middle]) then
|
||||
@@ -351,7 +351,7 @@ function ReaderBookmark:toggleBookmark(pn_or_xp)
|
||||
end
|
||||
|
||||
function ReaderBookmark:getPreviousBookmarkedPage(pn_or_xp)
|
||||
DEBUG("go to next bookmark from", pn_or_xp)
|
||||
logger.dbg("go to next bookmark from", pn_or_xp)
|
||||
for i = 1, #self.bookmarks do
|
||||
if self:isBookmarkInPageOrder({page = pn_or_xp}, self.bookmarks[i]) then
|
||||
return self.bookmarks[i].page
|
||||
@@ -360,7 +360,7 @@ function ReaderBookmark:getPreviousBookmarkedPage(pn_or_xp)
|
||||
end
|
||||
|
||||
function ReaderBookmark:getNextBookmarkedPage(pn_or_xp)
|
||||
DEBUG("go to next bookmark from", pn_or_xp)
|
||||
logger.dbg("go to next bookmark from", pn_or_xp)
|
||||
for i = #self.bookmarks, 1, -1 do
|
||||
if self:isBookmarkInReversePageOrder({page = pn_or_xp}, self.bookmarks[i]) then
|
||||
return self.bookmarks[i].page
|
||||
|
||||
@@ -6,7 +6,7 @@ local UIManager = require("ui/uimanager")
|
||||
local Screen = require("device").screen
|
||||
local Device = require("device")
|
||||
local JSON = require("json")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
@@ -127,10 +127,10 @@ function ReaderDictionary:onLookupDone()
|
||||
end
|
||||
|
||||
function ReaderDictionary:stardictLookup(word, box)
|
||||
DEBUG("lookup word:", word, box)
|
||||
logger.dbg("lookup word:", word, box)
|
||||
-- escape quotes and other funny characters in word
|
||||
word = self:cleanSelection(word)
|
||||
DEBUG("stripped word:", word)
|
||||
logger.dbg("stripped word:", word)
|
||||
if word == "" then
|
||||
return
|
||||
end
|
||||
@@ -162,7 +162,6 @@ function ReaderDictionary:stardictLookup(word, box)
|
||||
std_out:close()
|
||||
end
|
||||
end
|
||||
--DEBUG("result str:", word, results_str)
|
||||
local ok, results = pcall(JSON.decode, results_str)
|
||||
if ok and results then
|
||||
-- we may get duplicates (sdcv may do multiple queries,
|
||||
@@ -176,7 +175,7 @@ function ReaderDictionary:stardictLookup(word, box)
|
||||
end
|
||||
end
|
||||
else
|
||||
DEBUG("JSON data cannot be decoded", results)
|
||||
logger.warn("JSON data cannot be decoded", results)
|
||||
end
|
||||
end
|
||||
if #final_results == 0 then
|
||||
@@ -190,13 +189,12 @@ function ReaderDictionary:stardictLookup(word, box)
|
||||
}
|
||||
end
|
||||
self:onLookupDone()
|
||||
--DEBUG("lookup result table:", word, final_results)
|
||||
self:showDict(word, tidyMarkup(final_results), box)
|
||||
end
|
||||
|
||||
function ReaderDictionary:showDict(word, results, box)
|
||||
if results and results[1] then
|
||||
DEBUG("showing quick lookup window", word, results)
|
||||
logger.dbg("showing quick lookup window", word, results)
|
||||
self.dict_window = DictQuickLookup:new{
|
||||
window_list = self.dict_window_list,
|
||||
ui = self.ui,
|
||||
@@ -218,7 +216,7 @@ function ReaderDictionary:showDict(word, results, box)
|
||||
end
|
||||
|
||||
function ReaderDictionary:onUpdateDefaultDict(dict)
|
||||
DEBUG("make default dictionary:", dict)
|
||||
logger.dbg("make default dictionary:", dict)
|
||||
self.default_dictionary = dict
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = T(_("%1 is now the default dictionary for this document."), dict),
|
||||
@@ -232,7 +230,7 @@ function ReaderDictionary:onReadSettings(config)
|
||||
end
|
||||
|
||||
function ReaderDictionary:onSaveSettings()
|
||||
DEBUG("save default dictionary", self.default_dictionary)
|
||||
logger.dbg("save default dictionary", self.default_dictionary)
|
||||
self.ui.doc_settings:saveSetting("default_dictionary", self.default_dictionary)
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ local GestureRange = require("ui/gesturerange")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Screen = require("device").screen
|
||||
local Device = require("device")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -40,11 +40,11 @@ end
|
||||
function ReaderFrontLight:onAdjust(arg, ges)
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd.fl_intensity ~= nil then
|
||||
DEBUG("frontlight intensity", powerd.fl_intensity)
|
||||
logger.dbg("frontlight intensity", powerd.fl_intensity)
|
||||
local step = math.ceil(#self.steps * ges.distance / self.gestureScale)
|
||||
DEBUG("step = ", step)
|
||||
logger.dbg("step = ", step)
|
||||
local delta_int = self.steps[step] or self.steps[#self.steps]
|
||||
DEBUG("delta_int = ", delta_int)
|
||||
logger.dbg("delta_int = ", delta_int)
|
||||
local new_intensity
|
||||
if ges.direction == "north" then
|
||||
new_intensity = powerd.fl_intensity + delta_int
|
||||
@@ -71,13 +71,13 @@ end
|
||||
|
||||
function ReaderFrontLight:onSwipe(arg, ges)
|
||||
if ges.direction == "north" or ges.direction == "south" then
|
||||
DEBUG("onSwipe activated")
|
||||
logger.dbg("onSwipe activated")
|
||||
return self:onShowIntensity()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderFrontLight:onPanRelease(arg, ges)
|
||||
DEBUG("onPanRelease activated")
|
||||
logger.dbg("onPanRelease activated")
|
||||
return self:onShowIntensity()
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
|
||||
@@ -168,7 +168,7 @@ function ReaderHighlight:onTapPageSavedHighlight(ges)
|
||||
if boxes then
|
||||
for index, box in pairs(boxes) do
|
||||
if inside_box(pos, box) then
|
||||
DEBUG("Tap on hightlight")
|
||||
logger.dbg("Tap on hightlight")
|
||||
return self:onShowHighlightDialog(page, i)
|
||||
end
|
||||
end
|
||||
@@ -188,7 +188,7 @@ function ReaderHighlight:onTapXPointerSavedHighlight(ges)
|
||||
if boxes then
|
||||
for index, box in pairs(boxes) do
|
||||
if inside_box(pos, box) then
|
||||
DEBUG("Tap on hightlight")
|
||||
logger.dbg("Tap on hightlight")
|
||||
return self:onShowHighlightDialog(page, i)
|
||||
end
|
||||
end
|
||||
@@ -228,15 +228,15 @@ function ReaderHighlight:onHold(_, ges)
|
||||
-- disable hold gesture if highlighting is disabled
|
||||
if self.view.highlight.disabled then return true end
|
||||
self.hold_pos = self.view:screenToPageTransform(ges.pos)
|
||||
DEBUG("hold position in page", self.hold_pos)
|
||||
logger.dbg("hold position in page", self.hold_pos)
|
||||
if not self.hold_pos then
|
||||
DEBUG("not inside page area")
|
||||
logger.dbg("not inside page area")
|
||||
return true
|
||||
end
|
||||
|
||||
local ok, word = pcall(self.ui.document.getWordFromPosition, self.ui.document, self.hold_pos)
|
||||
if ok and word then
|
||||
DEBUG("selected word:", word)
|
||||
logger.dbg("selected word:", word)
|
||||
self.selected_word = word
|
||||
if self.ui.document.info.has_pages then
|
||||
local boxes = {}
|
||||
@@ -253,24 +253,24 @@ end
|
||||
|
||||
function ReaderHighlight:onHoldPan(_, ges)
|
||||
if self.hold_pos == nil then
|
||||
DEBUG("no previous hold position")
|
||||
logger.dbg("no previous hold position")
|
||||
return true
|
||||
end
|
||||
local page_area = self.view:getScreenPageArea(self.hold_pos.page)
|
||||
if ges.pos:notIntersectWith(page_area) then
|
||||
DEBUG("not inside page area", ges, page_area)
|
||||
logger.dbg("not inside page area", ges, page_area)
|
||||
return true
|
||||
end
|
||||
|
||||
self.holdpan_pos = self.view:screenToPageTransform(ges.pos)
|
||||
DEBUG("holdpan position in page", self.holdpan_pos)
|
||||
logger.dbg("holdpan position in page", self.holdpan_pos)
|
||||
local old_text = self.selected_text and self.selected_text.text
|
||||
self.selected_text = self.ui.document:getTextFromPositions(self.hold_pos, self.holdpan_pos)
|
||||
if self.selected_text and old_text and old_text == self.selected_text.text then
|
||||
-- no modification
|
||||
return
|
||||
end
|
||||
DEBUG("selected text:", self.selected_text)
|
||||
logger.dbg("selected text:", self.selected_text)
|
||||
if self.selected_text then
|
||||
self.view.highlight.temp[self.hold_pos.page] = self.selected_text.sboxes
|
||||
-- remove selected word if hold moves out of word box
|
||||
@@ -292,7 +292,7 @@ function ReaderHighlight:lookup(selected_word)
|
||||
-- or we will do OCR
|
||||
elseif selected_word.sbox and self.hold_pos then
|
||||
local word = self.ui.document:getOCRWord(self.hold_pos.page, selected_word)
|
||||
DEBUG("OCRed word:", word)
|
||||
logger.dbg("OCRed word:", word)
|
||||
local word_box = self.view:pageToScreenTransform(self.hold_pos.page, selected_word.sbox)
|
||||
self.ui:handleEvent(Event:new("LookupWord", word, word_box, self))
|
||||
end
|
||||
@@ -304,7 +304,7 @@ function ReaderHighlight:translate(selected_text)
|
||||
-- or we will do OCR
|
||||
else
|
||||
local text = self.ui.document:getOCRText(self.hold_pos.page, selected_text)
|
||||
DEBUG("OCRed text:", text)
|
||||
logger.dbg("OCRed text:", text)
|
||||
self.ui:handleEvent(Event:new("TranslateText", self, text))
|
||||
end
|
||||
end
|
||||
@@ -314,7 +314,7 @@ function ReaderHighlight:onHoldRelease()
|
||||
self:lookup(self.selected_word)
|
||||
self.selected_word = nil
|
||||
elseif self.selected_text then
|
||||
DEBUG("show highlight dialog")
|
||||
logger.dbg("show highlight dialog")
|
||||
self.highlight_dialog = ButtonDialog:new{
|
||||
buttons = {
|
||||
{
|
||||
@@ -380,7 +380,7 @@ function ReaderHighlight:highlightFromHoldPos()
|
||||
if self.hold_pos then
|
||||
if not self.selected_text then
|
||||
self.selected_text = self.ui.document:getTextFromPositions(self.hold_pos, self.hold_pos)
|
||||
DEBUG("selected text:", self.selected_text)
|
||||
logger.dbg("selected text:", self.selected_text)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -410,7 +410,7 @@ end
|
||||
|
||||
function ReaderHighlight:saveHighlight()
|
||||
self:handleEvent(Event:new("AddHighlight"))
|
||||
DEBUG("save highlight")
|
||||
logger.dbg("save highlight")
|
||||
local page = self.hold_pos.page
|
||||
if self.hold_pos and self.selected_text and self.selected_text.pos0
|
||||
and self.selected_text.pos1 then
|
||||
@@ -443,12 +443,11 @@ function ReaderHighlight:saveHighlight()
|
||||
self:exportToDocument(page, hl_item)
|
||||
end
|
||||
end
|
||||
--DEBUG("saved hightlights", self.view.highlight.saved[page])
|
||||
end
|
||||
|
||||
--[[
|
||||
function ReaderHighlight:exportToClippings(page, item)
|
||||
DEBUG("export highlight to clippings", item)
|
||||
logger.dbg("export highlight to clippings", item)
|
||||
local clippings = io.open("/mnt/us/documents/My Clippings.txt", "a+")
|
||||
if clippings and item.text then
|
||||
local current_locale = os.setlocale()
|
||||
@@ -466,13 +465,13 @@ end
|
||||
--]]
|
||||
|
||||
function ReaderHighlight:exportToDocument(page, item)
|
||||
DEBUG("export highlight to document", item)
|
||||
logger.dbg("export highlight to document", item)
|
||||
self.ui.document:saveHighlight(page, item)
|
||||
end
|
||||
|
||||
function ReaderHighlight:addNote()
|
||||
self:handleEvent(Event:new("addNote"))
|
||||
DEBUG("add Note")
|
||||
logger.dbg("add Note")
|
||||
end
|
||||
|
||||
function ReaderHighlight:lookupWikipedia()
|
||||
@@ -482,7 +481,7 @@ function ReaderHighlight:lookupWikipedia()
|
||||
end
|
||||
|
||||
function ReaderHighlight:onHighlightSearch()
|
||||
DEBUG("search highlight")
|
||||
logger.dbg("search highlight")
|
||||
self:highlightFromHoldPos()
|
||||
if self.selected_text then
|
||||
local text = require("util").stripePunctuations(self.selected_text.text)
|
||||
@@ -491,7 +490,7 @@ function ReaderHighlight:onHighlightSearch()
|
||||
end
|
||||
|
||||
function ReaderHighlight:onHighlightDictLookup()
|
||||
DEBUG("dictionary lookup highlight")
|
||||
logger.dbg("dictionary lookup highlight")
|
||||
self:highlightFromHoldPos()
|
||||
if self.selected_text then
|
||||
self.ui:handleEvent(Event:new("LookupWord", self.selected_text.text))
|
||||
@@ -499,15 +498,15 @@ function ReaderHighlight:onHighlightDictLookup()
|
||||
end
|
||||
|
||||
function ReaderHighlight:shareHighlight()
|
||||
DEBUG("share highlight")
|
||||
logger.info("share highlight")
|
||||
end
|
||||
|
||||
function ReaderHighlight:moreAction()
|
||||
DEBUG("more action")
|
||||
logger.info("more action")
|
||||
end
|
||||
|
||||
function ReaderHighlight:deleteHighlight(page, i)
|
||||
DEBUG("delete highlight")
|
||||
logger.dbg("delete highlight")
|
||||
local removed = table.remove(self.view.highlight.saved[page], i)
|
||||
self.ui.bookmark:removeBookmark({
|
||||
page = self.ui.document.info.has_pages and page or removed.pos0,
|
||||
@@ -516,7 +515,7 @@ function ReaderHighlight:deleteHighlight(page, i)
|
||||
end
|
||||
|
||||
function ReaderHighlight:editHighlight()
|
||||
DEBUG("edit highlight")
|
||||
logger.info("edit highlight")
|
||||
end
|
||||
|
||||
function ReaderHighlight:onReadSettings(config)
|
||||
|
||||
@@ -5,7 +5,6 @@ local Device = require("device")
|
||||
local Screensaver = require("ui/screensaver")
|
||||
local Event = require("ui/event")
|
||||
local Screen = require("device").screen
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderMenu = InputContainer:new{
|
||||
@@ -215,7 +214,6 @@ end
|
||||
|
||||
function ReaderMenu:onCloseReaderMenu()
|
||||
self.last_tab_index = self.menu_container[1].last_index
|
||||
DEBUG("remember menu tab index", self.last_tab_index)
|
||||
self:onSaveSettings()
|
||||
UIManager:close(self.menu_container)
|
||||
return true
|
||||
|
||||
@@ -6,7 +6,7 @@ local Screen = Device.screen
|
||||
local Event = require("ui/event")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Math = require("optmath")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ users change font size, page margin or line spacing or close and reopen the
|
||||
book, the page view will be roughly the same.
|
||||
--]]
|
||||
function ReaderPaging:setPagePosition(page, pos)
|
||||
DEBUG("set page position", pos)
|
||||
logger.dbg("set page position", pos)
|
||||
self.page_positions[page] = pos
|
||||
end
|
||||
|
||||
@@ -241,7 +241,7 @@ function ReaderPaging:getPagePosition(page)
|
||||
-- fractional page number the reader runs silently well, but the
|
||||
-- number won't fit to retrieve page position.
|
||||
page = math.floor(page)
|
||||
DEBUG("get page position", self.page_positions[page])
|
||||
logger.dbg("get page position", self.page_positions[page])
|
||||
return self.page_positions[page] or 0
|
||||
end
|
||||
|
||||
@@ -298,7 +298,7 @@ function ReaderPaging:enterFlippingMode()
|
||||
self.orig_reflow_mode = self.view.document.configurable.text_wrap
|
||||
self.orig_scroll_mode = self.view.page_scroll
|
||||
self.orig_zoom_mode = self.view.zoom_mode
|
||||
DEBUG("store zoom mode", self.orig_zoom_mode)
|
||||
logger.dbg("store zoom mode", self.orig_zoom_mode)
|
||||
self.view.document.configurable.text_wrap = 0
|
||||
self.view.page_scroll = self.flipping_scroll_mode
|
||||
Input.disable_double_tap = false
|
||||
@@ -311,7 +311,7 @@ function ReaderPaging:exitFlippingMode()
|
||||
Input.disable_double_tap = true
|
||||
self.flipping_zoom_mode = self.view.zoom_mode
|
||||
self.flipping_scroll_mode = self.view.page_scroll
|
||||
DEBUG("restore zoom mode", self.orig_zoom_mode)
|
||||
logger.dbg("restore zoom mode", self.orig_zoom_mode)
|
||||
self.ui:handleEvent(Event:new("ExitFlippingMode", self.orig_zoom_mode))
|
||||
end
|
||||
|
||||
@@ -421,7 +421,7 @@ function ReaderPaging:onViewRecalculate(visible_area, page_area)
|
||||
end
|
||||
|
||||
function ReaderPaging:onGotoPercent(percent)
|
||||
DEBUG("goto document offset in percent:", percent)
|
||||
logger.dbg("goto document offset in percent:", percent)
|
||||
local dest = math.floor(self.number_of_pages * percent / 100)
|
||||
if dest < 1 then dest = 1 end
|
||||
if dest > self.number_of_pages then
|
||||
@@ -493,7 +493,7 @@ function ReaderPaging:getTopPage()
|
||||
end
|
||||
|
||||
function ReaderPaging:onInitScrollPageStates(orig_mode)
|
||||
DEBUG("init scroll page states", orig_mode)
|
||||
logger.dbg("init scroll page states", orig_mode)
|
||||
if self.view.page_scroll and self.view.state.page then
|
||||
self.orig_page = self.current_page
|
||||
self.view.page_states = {}
|
||||
@@ -671,7 +671,7 @@ end
|
||||
|
||||
function ReaderPaging:onScrollPanRel(diff)
|
||||
if diff == 0 then return true end
|
||||
DEBUG("pan relative height:", diff)
|
||||
logger.dbg("pan relative height:", diff)
|
||||
local offset = Geom:new{x = 0, y = diff}
|
||||
local blank_area = Geom:new{}
|
||||
blank_area:setSizeTo(self.view.dimen)
|
||||
@@ -746,7 +746,7 @@ function ReaderPaging:onScrollPageRel(page_diff)
|
||||
end
|
||||
|
||||
function ReaderPaging:onGotoPageRel(diff)
|
||||
DEBUG("goto relative page:", diff)
|
||||
logger.dbg("goto relative page:", diff)
|
||||
local new_va = self.visible_area:copy()
|
||||
local x_pan_off, y_pan_off = 0, 0
|
||||
|
||||
@@ -852,7 +852,7 @@ function ReaderPaging:_gotoPage(number, orig_mode)
|
||||
return true
|
||||
end
|
||||
if number > self.number_of_pages or number < 1 then
|
||||
DEBUG("wrong page number: "..number.."!")
|
||||
logger.warn("wrong page number: "..number.."!")
|
||||
return false
|
||||
end
|
||||
-- this is an event to allow other controllers to be aware of this change
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Device = require("device")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderPanning = InputContainer:new{
|
||||
@@ -37,9 +36,8 @@ function ReaderPanning:onSetDimensions(dimensions)
|
||||
self.dimen = dimensions
|
||||
end
|
||||
|
||||
function ReaderPanning:onPanning(args, key)
|
||||
function ReaderPanning:onPanning(args, _)
|
||||
local dx, dy = unpack(args)
|
||||
DEBUG("key =", key)
|
||||
-- for now, bounds checking/calculation is done in the view
|
||||
self.view:PanningUpdate(
|
||||
dx * self.panning_steps.normal * self.dimen.w / 100,
|
||||
|
||||
@@ -5,7 +5,7 @@ local Device = require("device")
|
||||
local Input = require("device").input
|
||||
local Event = require("ui/event")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local pan_rate = Screen.eink and 4.0 or 10.0
|
||||
@@ -348,7 +348,7 @@ function ReaderRolling:onNotCharging()
|
||||
end
|
||||
|
||||
function ReaderRolling:onGotoPercent(percent)
|
||||
DEBUG("goto document offset in percent:", percent)
|
||||
logger.dbg("goto document offset in percent:", percent)
|
||||
self:_gotoPercent(percent)
|
||||
self.xpointer = self.ui.document:getXPointer()
|
||||
return true
|
||||
@@ -385,7 +385,7 @@ function ReaderRolling:onRestoreBookLocation(saved_location)
|
||||
end
|
||||
|
||||
function ReaderRolling:onGotoViewRel(diff)
|
||||
DEBUG("goto relative screen:", diff, ", in mode: ", self.view.view_mode)
|
||||
logger.dbg("goto relative screen:", diff, ", in mode: ", self.view.view_mode)
|
||||
if self.view.view_mode == "scroll" then
|
||||
local pan_diff = diff * self.ui.dimen.h
|
||||
if self.show_overlap_enable then
|
||||
@@ -412,10 +412,9 @@ function ReaderRolling:onGotoViewRel(diff)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRolling:onPanning(args, key)
|
||||
function ReaderRolling:onPanning(args, _)
|
||||
--@TODO disable panning in page view_mode? 22.12 2012 (houqp)
|
||||
local _, dy = unpack(args)
|
||||
DEBUG("key =", key)
|
||||
self:_gotoPos(self.current_pos + dy * self.panning_steps.normal)
|
||||
self.xpointer = self.ui.document:getXPointer()
|
||||
return true
|
||||
@@ -533,13 +532,13 @@ currently we don't need to get page links on each page/pos update
|
||||
since we can check link on the fly when tapping on the screen
|
||||
--]]
|
||||
function ReaderRolling:updatePageLink()
|
||||
DEBUG("update page link")
|
||||
logger.dbg("update page link")
|
||||
local links = self.ui.document:getPageLinks()
|
||||
self.view.links = links
|
||||
end
|
||||
|
||||
function ReaderRolling:updateBatteryState()
|
||||
DEBUG("update battery state")
|
||||
logger.dbg("update battery state")
|
||||
if self.view.view_mode == "page" then
|
||||
local powerd = Device:getPowerDevice()
|
||||
-- -1 is CR_BATTERY_STATE_CHARGING @ crengine/crengine/include/lvdocview.h
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderSearch = InputContainer:new{
|
||||
@@ -63,7 +63,7 @@ function ReaderSearch:onShowSearchDialog(text)
|
||||
}
|
||||
},
|
||||
tap_close_callback = function()
|
||||
DEBUG("highlight clear")
|
||||
logger.dbg("highlight clear")
|
||||
self.ui.highlight:clear()
|
||||
end,
|
||||
}
|
||||
@@ -75,7 +75,7 @@ function ReaderSearch:onShowSearchDialog(text)
|
||||
end
|
||||
|
||||
function ReaderSearch:search(pattern, origin)
|
||||
DEBUG("search pattern", pattern)
|
||||
logger.dbg("search pattern", pattern)
|
||||
if pattern == nil or pattern == '' then return end
|
||||
local direction = self.direction
|
||||
local case = self.case_insensitive
|
||||
|
||||
@@ -14,6 +14,7 @@ local Screen = Device.screen
|
||||
local Geom = require("ui/geometry")
|
||||
local Event = require("ui/event")
|
||||
local dbg = require("dbg")
|
||||
local logger = require("logger")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -176,7 +177,6 @@ function ReaderView:paintTo(bb, x, y)
|
||||
|
||||
-- dim last read area
|
||||
if self.dim_area.w ~= 0 and self.dim_area.h ~= 0 then
|
||||
--dbg("dim area", self.dim_area)
|
||||
if self.page_overlap_style == "dim" then
|
||||
bb:dimRect(
|
||||
self.dim_area.x, self.dim_area.y,
|
||||
@@ -226,7 +226,7 @@ function ReaderView:screenToPageTransform(pos)
|
||||
else
|
||||
pos.page = self.ui.document:getCurrentPage()
|
||||
-- local last_y = self.ui.document:getCurrentPos()
|
||||
dbg("document has no pages at", pos)
|
||||
logger.dbg("document has no pages at", pos)
|
||||
return pos
|
||||
end
|
||||
end
|
||||
@@ -556,14 +556,14 @@ function ReaderView:recalculate()
|
||||
end
|
||||
|
||||
function ReaderView:PanningUpdate(dx, dy)
|
||||
dbg("pan by", dx, dy)
|
||||
logger.dbg("pan by", dx, dy)
|
||||
local old = self.visible_area:copy()
|
||||
self.visible_area:offsetWithin(self.page_area, dx, dy)
|
||||
if self.visible_area ~= old then
|
||||
-- flag a repaint
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
dbg("on pan: page_area", self.page_area)
|
||||
dbg("on pan: visible_area", self.visible_area)
|
||||
logger.dbg("on pan: page_area", self.page_area)
|
||||
logger.dbg("on pan: visible_area", self.visible_area)
|
||||
self.ui:handleEvent(
|
||||
Event:new("ViewRecalculate", self.visible_area, self.page_area))
|
||||
end
|
||||
@@ -571,7 +571,7 @@ function ReaderView:PanningUpdate(dx, dy)
|
||||
end
|
||||
|
||||
function ReaderView:PanningStart(x, y)
|
||||
dbg("panning start", x, y)
|
||||
logger.dbg("panning start", x, y)
|
||||
if not self.panning_visible_area then
|
||||
self.panning_visible_area = self.visible_area:copy()
|
||||
end
|
||||
@@ -650,7 +650,6 @@ function ReaderView:onSetDimensions(dimensions)
|
||||
end
|
||||
|
||||
function ReaderView:onRestoreDimensions(dimensions)
|
||||
--dbg("restore dimen", dimensions)
|
||||
self:resetLayout()
|
||||
self.dimen = dimensions
|
||||
-- recalculate view
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local ReaderDictionary = require("apps/reader/modules/readerdictionary")
|
||||
local Translator = require("ui/translator")
|
||||
local Wikipedia = require("ui/wikipedia")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
|
||||
@@ -77,14 +77,14 @@ function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
self:initLanguages(word)
|
||||
-- use first lang from self.wiki_languages, which may have been rotated by DictQuickLookup
|
||||
local lang = self.wiki_languages[1]
|
||||
DEBUG("lookup word:", word, box, get_fullpage)
|
||||
logger.dbg("lookup word:", word, box, get_fullpage)
|
||||
-- no need to clean word if get_fullpage, as it is the exact wikipetia page title
|
||||
if word and not get_fullpage then
|
||||
-- escape quotes and other funny characters in word
|
||||
word = self:cleanSelection(word)
|
||||
-- no need to lower() word with wikipedia search
|
||||
end
|
||||
DEBUG("stripped word:", word)
|
||||
logger.dbg("stripped word:", word)
|
||||
if word == "" then
|
||||
return
|
||||
end
|
||||
@@ -128,9 +128,9 @@ function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
}
|
||||
table.insert(results, result)
|
||||
end
|
||||
DEBUG("lookup result:", word, results)
|
||||
logger.dbg("lookup result:", word, results)
|
||||
else
|
||||
DEBUG("error:", pages)
|
||||
logger.dbg("error:", pages)
|
||||
-- dummy results
|
||||
results = {
|
||||
{
|
||||
@@ -140,7 +140,7 @@ function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
is_fullpage = get_fullpage,
|
||||
}
|
||||
}
|
||||
DEBUG("dummy result table:", word, results)
|
||||
logger.dbg("dummy result table:", word, results)
|
||||
end
|
||||
self:onLookupDone()
|
||||
self:showDict(word, results, box)
|
||||
|
||||
@@ -7,7 +7,7 @@ local Input = require("device").input
|
||||
local Screen = require("device").screen
|
||||
local Geom = require("ui/geometry")
|
||||
local Event = require("ui/event")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -143,7 +143,7 @@ function ReaderZooming:onToggleFreeZoom(arg, ges)
|
||||
self.orig_zoom = self.zoom
|
||||
local xpos, ypos
|
||||
self.zoom, xpos, ypos = self:getRegionalZoomCenter(self.current_page, ges.pos)
|
||||
DEBUG("zoom center", self.zoom, xpos, ypos)
|
||||
logger.info("zoom center", self.zoom, xpos, ypos)
|
||||
self.ui:handleEvent(Event:new("SetZoomMode", "free"))
|
||||
if xpos == nil or ypos == nil then
|
||||
xpos = ges.pos.x * self.zoom / self.orig_zoom
|
||||
@@ -173,13 +173,13 @@ function ReaderZooming:onRotationUpdate(rotation)
|
||||
end
|
||||
|
||||
function ReaderZooming:onZoom(direction)
|
||||
DEBUG("zoom", direction)
|
||||
logger.info("zoom", direction)
|
||||
if direction == "in" then
|
||||
self.zoom = self.zoom * 1.333333
|
||||
elseif direction == "out" then
|
||||
self.zoom = self.zoom * 0.75
|
||||
end
|
||||
DEBUG("zoom is now at", self.zoom)
|
||||
logger.info("zoom is now at", self.zoom)
|
||||
self:onSetZoomMode("free")
|
||||
self.view:onZoomUpdate(self.zoom)
|
||||
return true
|
||||
@@ -188,7 +188,7 @@ end
|
||||
function ReaderZooming:onSetZoomMode(new_mode)
|
||||
self.view.zoom_mode = new_mode
|
||||
if self.zoom_mode ~= new_mode then
|
||||
DEBUG("setting zoom mode to", new_mode)
|
||||
logger.info("setting zoom mode to", new_mode)
|
||||
self.ui:handleEvent(Event:new("ZoomModeUpdate", new_mode))
|
||||
self.zoom_mode = new_mode
|
||||
self:setZoom()
|
||||
|
||||
@@ -12,7 +12,7 @@ local Device = require("device")
|
||||
local Screen = require("device").screen
|
||||
local Event = require("ui/event")
|
||||
local Cache = require("cache")
|
||||
local dbg = require("dbg")
|
||||
local logger = require("logger")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -309,7 +309,7 @@ function ReaderUI:init()
|
||||
})
|
||||
-- koreader plugins
|
||||
for _,plugin_module in ipairs(PluginLoader:loadPlugins()) do
|
||||
dbg("Loaded plugin", plugin_module.name, "at", plugin_module.path)
|
||||
logger.info("RD loaded plugin", plugin_module.name, "at", plugin_module.path)
|
||||
self:registerModule(plugin_module.name, plugin_module:new{
|
||||
dialog = self.dialog,
|
||||
view = self.view,
|
||||
@@ -332,7 +332,7 @@ function ReaderUI:init()
|
||||
end
|
||||
|
||||
function ReaderUI:showReader(file)
|
||||
dbg("show reader ui")
|
||||
logger.dbg("show reader ui")
|
||||
require("readhistory"):addItem(file)
|
||||
if lfs.attributes(file, "mode") ~= "file" then
|
||||
UIManager:show(InfoMessage:new{
|
||||
@@ -347,7 +347,7 @@ function ReaderUI:showReader(file)
|
||||
-- doShowReader might block for a long time, so force repaint here
|
||||
UIManager:forceRePaint()
|
||||
UIManager:nextTick(function()
|
||||
dbg("creating coroutine for showing reader")
|
||||
logger.dbg("creating coroutine for showing reader")
|
||||
local co = coroutine.create(function()
|
||||
self:doShowReader(file)
|
||||
end)
|
||||
@@ -362,7 +362,7 @@ end
|
||||
|
||||
local _running_instance = nil
|
||||
function ReaderUI:doShowReader(file)
|
||||
dbg("opening file", file)
|
||||
logger.info("opening file", file)
|
||||
-- keep only one instance running
|
||||
if _running_instance then
|
||||
_running_instance:onClose()
|
||||
@@ -375,7 +375,7 @@ function ReaderUI:doShowReader(file)
|
||||
return
|
||||
end
|
||||
if document.is_locked then
|
||||
dbg("document is locked")
|
||||
logger.info("document is locked")
|
||||
self._coroutine = coroutine.running() or self._coroutine
|
||||
self:unlockDocumentWithPassword(document)
|
||||
if coroutine.running() then
|
||||
@@ -400,7 +400,7 @@ function ReaderUI:_getRunningInstance()
|
||||
end
|
||||
|
||||
function ReaderUI:unlockDocumentWithPassword(document, try_again)
|
||||
dbg("show input password dialog")
|
||||
logger.dbg("show input password dialog")
|
||||
self.password_dialog = InputDialog:new{
|
||||
title = try_again and _("Password is incorrect, try again?")
|
||||
or _("Input document password"),
|
||||
@@ -495,10 +495,10 @@ function ReaderUI:notifyCloseDocument()
|
||||
end
|
||||
|
||||
function ReaderUI:onClose()
|
||||
dbg("closing reader")
|
||||
logger.dbg("closing reader")
|
||||
self:saveSettings()
|
||||
if self.document ~= nil then
|
||||
dbg("closing document")
|
||||
logger.dbg("closing document")
|
||||
self:notifyCloseDocument()
|
||||
end
|
||||
UIManager:close(self.dialog, "full")
|
||||
|
||||
@@ -4,7 +4,7 @@ A global LRU cache
|
||||
local md5 = require("ffi/MD5")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local DataStorage = require("datastorage")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
if require("device"):isAndroid() then
|
||||
require("jit").off(true, true)
|
||||
@@ -99,7 +99,7 @@ function Cache:insert(key, object)
|
||||
self:drop(key)
|
||||
-- guarantee that we have enough memory in cache
|
||||
if (object.size > self.max_memsize) then
|
||||
DEBUG("too much memory claimed for", key)
|
||||
logger.warn("too much memory claimed for", key)
|
||||
return
|
||||
end
|
||||
-- delete objects that least recently used
|
||||
@@ -135,7 +135,7 @@ function Cache:check(key, ItemClass)
|
||||
self:insert(key, item)
|
||||
return item
|
||||
else
|
||||
DEBUG("discard cache", msg)
|
||||
logger.warn("discard cache", msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -163,7 +163,7 @@ function Cache:serialize()
|
||||
local cache_item = self.cache[key]
|
||||
-- only dump cache item that requests serialization explicitly
|
||||
if cache_item.persistent and cache_item.dump then
|
||||
DEBUG("dump cache item", key)
|
||||
logger.dbg("dump cache item", key)
|
||||
cache_size = cache_item:dump(cache_path..md5.sum(key)) or 0
|
||||
if cache_size > 0 then break end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
local logger = require("logger")
|
||||
local dump = require("dump")
|
||||
local isAndroid, android = pcall(require, "android")
|
||||
|
||||
@@ -30,6 +31,7 @@ end
|
||||
function Dbg:turnOn()
|
||||
if self.is_on == true then return end
|
||||
self.is_on = true
|
||||
logger:setLevel(logger.levels.dbg)
|
||||
|
||||
Dbg_mt.__call = function(dbg, ...) LvDEBUG(math.huge, ...) end
|
||||
Dbg.guard = function(_, mod, method, pre_guard, post_guard)
|
||||
@@ -53,6 +55,7 @@ end
|
||||
function Dbg:turnOff()
|
||||
if self.is_on == false then return end
|
||||
self.is_on = false
|
||||
logger:setLevel(logger.levels.info)
|
||||
function Dbg_mt.__call() end
|
||||
function Dbg.guard() end
|
||||
if self.ev_log then
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local Generic = require("device/generic/device")
|
||||
local _, android = pcall(require, "android")
|
||||
local ffi = require("ffi")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local function yes() return true end
|
||||
local function no() return false end
|
||||
@@ -17,13 +17,13 @@ local Device = Generic:new{
|
||||
}
|
||||
|
||||
function Device:init()
|
||||
self.screen = require("ffi/framebuffer_android"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_android"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/android/powerd"):new{device = self}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = require("device/android/event_map"),
|
||||
handleMiscEv = function(this, ev)
|
||||
DEBUG("Android application event", ev.code)
|
||||
logger.dbg("Android application event", ev.code)
|
||||
if ev.code == ffi.C.APP_CMD_SAVE_STATE then
|
||||
return "SaveState"
|
||||
elseif ev.code == ffi.C.APP_CMD_GAINED_FOCUS then
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local Event = require("ui/event")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local function yes() return true end
|
||||
@@ -60,8 +60,8 @@ function Device:init()
|
||||
local is_eink = G_reader_settings:readSetting("eink")
|
||||
self.screen.eink = (is_eink == nil) or is_eink
|
||||
|
||||
DEBUG("initializing for device", self.model)
|
||||
DEBUG("framebuffer resolution:", self.screen:getSize())
|
||||
logger.info("initializing for device", self.model)
|
||||
logger.info("framebuffer resolution:", self.screen:getSize())
|
||||
|
||||
if not self.input then
|
||||
self.input = require("device/input"):new{device = self}
|
||||
@@ -71,7 +71,7 @@ function Device:init()
|
||||
end
|
||||
|
||||
if self.viewport then
|
||||
DEBUG("setting a viewport:", self.viewport)
|
||||
logger.dbg("setting a viewport:", self.viewport)
|
||||
self.screen:setViewport(self.viewport)
|
||||
self.input:registerEventAdjustHook(
|
||||
self.input.adjustTouchTranslate,
|
||||
@@ -97,7 +97,7 @@ function Device:onPowerEvent(ev)
|
||||
-- don't let power key press wake up device when the cover is in closed state
|
||||
self:rescheduleSuspend()
|
||||
else
|
||||
DEBUG("Resuming...")
|
||||
logger.dbg("Resuming...")
|
||||
local UIManager = require("ui/uimanager")
|
||||
UIManager:unschedule(self.suspend)
|
||||
local network_manager = require("ui/network/manager")
|
||||
@@ -119,7 +119,7 @@ function Device:onPowerEvent(ev)
|
||||
-- Already in screen saver mode, no need to update UI/state before
|
||||
-- suspending the hardware. This usually happens when sleep cover
|
||||
-- is closed after the device was sent to suspend state.
|
||||
DEBUG("Already in screen saver mode, suspending...")
|
||||
logger.dbg("Already in screen saver mode, suspending...")
|
||||
self:rescheduleSuspend()
|
||||
end
|
||||
-- else we we not in screensaver mode
|
||||
@@ -134,7 +134,7 @@ function Device:onPowerEvent(ev)
|
||||
-- flushing settings first in case the screensaver takes too long time
|
||||
-- that flushing has no chance to run
|
||||
UIManager:broadcastEvent(Event:new("FlushSettings"))
|
||||
DEBUG("Suspending...")
|
||||
logger.dbg("Suspending...")
|
||||
-- always suspend in portrait mode
|
||||
self.orig_rotation_mode = self.screen:getRotationMode()
|
||||
self.screen:setRotationMode(0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local BasePowerD = {
|
||||
fl_min = 0, -- min frontlight intensity
|
||||
@@ -61,7 +61,7 @@ end
|
||||
function BasePowerD:setIntensity(intensity)
|
||||
if intensity == self.fl_intensity then return end
|
||||
self.fl_intensity = self:normalizeIntensity(intensity)
|
||||
DEBUG("set light intensity", self.fl_intensity)
|
||||
logger.dbg("set light intensity", self.fl_intensity)
|
||||
self:setIntensityHW()
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local Geom = require("ui/geometry")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
--[[
|
||||
Current detectable gestures:
|
||||
@@ -92,7 +92,6 @@ function GestureDetector:feedEvent(tevs)
|
||||
repeat
|
||||
local tev = table.remove(tevs)
|
||||
if tev then
|
||||
--DEBUG("tev fed|",tev.timev.sec,"|",tev.timev.usec,"|",tev.x,"|",tev.y,"|",tev.id,"| Evt",tev.slot)
|
||||
local slot = tev.slot
|
||||
if not self.states[slot] then
|
||||
self:clearState(slot) -- initiate state
|
||||
@@ -241,7 +240,7 @@ end
|
||||
this method handles both single and double tap
|
||||
--]]
|
||||
function GestureDetector:tapState(tev)
|
||||
DEBUG("in tap state...")
|
||||
logger.dbg("in tap state...")
|
||||
local slot = tev.slot
|
||||
if tev.id == -1 then
|
||||
-- end of tap event
|
||||
@@ -258,7 +257,7 @@ function GestureDetector:tapState(tev)
|
||||
w = 0, h = 0,
|
||||
}
|
||||
local tap_span = pos0:distance(pos1)
|
||||
DEBUG("two-finger tap detected with span", tap_span)
|
||||
logger.dbg("two-finger tap detected with span", tap_span)
|
||||
self:clearStates()
|
||||
return {
|
||||
ges = "two_finger_tap",
|
||||
@@ -314,27 +313,27 @@ function GestureDetector:handleDoubleTap(tev)
|
||||
self:clearState(slot)
|
||||
ges_ev.ges = "double_tap"
|
||||
self.last_taps[slot] = nil
|
||||
DEBUG("double tap detected in slot", slot)
|
||||
logger.dbg("double tap detected in slot", slot)
|
||||
return ges_ev
|
||||
end
|
||||
|
||||
-- set current tap to last tap
|
||||
self.last_taps[slot] = cur_tap
|
||||
|
||||
DEBUG("set up tap timer")
|
||||
logger.dbg("set up tap timer")
|
||||
-- deadline should be calculated by adding current tap time and the interval
|
||||
local deadline = cur_tap.timev + TimeVal:new{
|
||||
sec = 0,
|
||||
usec = not self.input.disable_double_tap and self.DOUBLE_TAP_INTERVAL or 0,
|
||||
}
|
||||
self.input:setTimeout(function()
|
||||
DEBUG("in tap timer", self.last_taps[slot] ~= nil)
|
||||
logger.dbg("in tap timer", self.last_taps[slot] ~= nil)
|
||||
-- double tap will set last_tap to nil so if it is not, then
|
||||
-- user must only tapped once
|
||||
if self.last_taps[slot] ~= nil then
|
||||
self.last_taps[slot] = nil
|
||||
-- we are using closure here
|
||||
DEBUG("single tap detected in slot", slot, ges_ev.pos)
|
||||
logger.dbg("single tap detected in slot", slot, ges_ev.pos)
|
||||
return ges_ev
|
||||
end
|
||||
end, deadline)
|
||||
@@ -349,18 +348,17 @@ function GestureDetector:handleNonTap(tev)
|
||||
-- switched from other state, probably from initialState
|
||||
-- we return nil in this case
|
||||
self.states[slot] = self.tapState
|
||||
DEBUG("set up hold timer")
|
||||
logger.dbg("set up hold timer")
|
||||
local deadline = tev.timev + TimeVal:new{
|
||||
sec = 0, usec = self.HOLD_INTERVAL
|
||||
}
|
||||
self.input:setTimeout(function()
|
||||
if self.states[slot] == self.tapState then
|
||||
-- timer set in tapState, so we switch to hold
|
||||
DEBUG("hold gesture detected in slot", slot)
|
||||
logger.dbg("hold gesture detected in slot", slot)
|
||||
return self:switchState("holdState", tev, true)
|
||||
end
|
||||
end, deadline)
|
||||
--DEBUG("handle non-tap", tev)
|
||||
return {
|
||||
ges = "touch",
|
||||
pos = Geom:new{
|
||||
@@ -383,7 +381,7 @@ function GestureDetector:handleNonTap(tev)
|
||||
end
|
||||
|
||||
function GestureDetector:panState(tev)
|
||||
DEBUG("in pan state...")
|
||||
logger.dbg("in pan state...")
|
||||
local slot = tev.slot
|
||||
if tev.id == -1 then
|
||||
-- end of pan, signal swipe gesture if necessary
|
||||
@@ -399,7 +397,7 @@ function GestureDetector:panState(tev)
|
||||
elseif ges_ev.ges == "outward_pan" then
|
||||
ges_ev.ges = "spread"
|
||||
end
|
||||
DEBUG(ges_ev.ges, ges_ev.direction, ges_ev.distance, "detected")
|
||||
logger.dbg(ges_ev.ges, ges_ev.direction, ges_ev.distance, "detected")
|
||||
end
|
||||
return ges_ev
|
||||
else
|
||||
@@ -430,7 +428,7 @@ function GestureDetector:handleSwipe(tev)
|
||||
elseif swipe_direction == "east" and DCHANGE_EAST_SWIPE_TO_WEST then
|
||||
swipe_direction = "west"
|
||||
end
|
||||
DEBUG("swipe", swipe_direction, swipe_distance, "detected in slot", slot)
|
||||
logger.dbg("swipe", swipe_direction, swipe_distance, "detected in slot", slot)
|
||||
self:clearState(slot)
|
||||
return {
|
||||
ges = "swipe",
|
||||
@@ -467,7 +465,6 @@ function GestureDetector:handlePan(tev)
|
||||
y = self.last_tevs[slot].y,
|
||||
w = 0, h = 0,
|
||||
}
|
||||
--DEBUG(pan_ev.ges, pan_ev, "detected")
|
||||
return pan_ev
|
||||
end
|
||||
end
|
||||
@@ -518,11 +515,11 @@ function GestureDetector:handleTwoFingerPan(tev)
|
||||
end
|
||||
ges_ev.direction = self.DIRECTION_TABLE[tpan_dir]
|
||||
end
|
||||
DEBUG(ges_ev.ges, ges_ev.direction, ges_ev.distance, "detected")
|
||||
logger.dbg(ges_ev.ges, ges_ev.direction, ges_ev.distance, "detected")
|
||||
return ges_ev
|
||||
elseif self.states[rslot] == self.holdState then
|
||||
local angle = self:getRotate(rstart_pos, tstart_pos, tend_pos)
|
||||
DEBUG("rotate", angle, "detected")
|
||||
logger.dbg("rotate", angle, "detected")
|
||||
return {
|
||||
ges = "rotate",
|
||||
pos = rstart_pos,
|
||||
@@ -545,18 +542,18 @@ function GestureDetector:handlePanRelease(tev)
|
||||
time = tev.timev,
|
||||
}
|
||||
if self.detectings[0] and self.detectings[1] then
|
||||
DEBUG("two finger pan release detected")
|
||||
logger.dbg("two finger pan release detected")
|
||||
pan_ev.ges = "two_finger_pan_release"
|
||||
self:clearStates()
|
||||
else
|
||||
DEBUG("pan release detected in slot", slot)
|
||||
logger.dbg("pan release detected in slot", slot)
|
||||
self:clearState(slot)
|
||||
end
|
||||
return pan_ev
|
||||
end
|
||||
|
||||
function GestureDetector:holdState(tev, hold)
|
||||
DEBUG("in hold state...")
|
||||
logger.dbg("in hold state...")
|
||||
local slot = tev.slot
|
||||
-- when we switch to hold state, we pass additional param "hold"
|
||||
if tev.id ~= -1 and hold and self.last_tevs[slot].x and self.last_tevs[slot].y then
|
||||
@@ -572,7 +569,7 @@ function GestureDetector:holdState(tev, hold)
|
||||
}
|
||||
elseif tev.id == -1 and self.last_tevs[slot] ~= nil then
|
||||
-- end of hold, signal hold release
|
||||
DEBUG("hold_release detected in slot", slot)
|
||||
logger.dbg("hold_release detected in slot", slot)
|
||||
local last_x = self.last_tevs[slot].x
|
||||
local last_y = self.last_tevs[slot].y
|
||||
self:clearState(slot)
|
||||
|
||||
@@ -2,6 +2,7 @@ local Event = require("ui/event")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local input = require("ffi/input")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local Key = require("device/key")
|
||||
local GestureDetector = require("device/gesturedetector")
|
||||
@@ -145,10 +146,10 @@ function Input:init()
|
||||
-- user custom event map
|
||||
local ok, custom_event_map = pcall(dofile, "custom.event.map.lua")
|
||||
if ok then
|
||||
DEBUG("custom event map", custom_event_map)
|
||||
for key, value in pairs(custom_event_map) do
|
||||
self.event_map[key] = value
|
||||
end
|
||||
logger.info("loaded custom event map", custom_event_map)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -386,7 +387,6 @@ function Input:handleTouchEv(ev)
|
||||
local touch_ges = self.gesture_detector:feedEvent(self.MTSlots)
|
||||
self.MTSlots = {}
|
||||
if touch_ges then
|
||||
--DEBUG("ges", touch_ges)
|
||||
self:gestureAdjustHook(touch_ges)
|
||||
return Event:new("Gesture",
|
||||
self.gesture_detector:adjustGesCoordinate(touch_ges)
|
||||
@@ -483,10 +483,6 @@ function Input:handleOasisOrientationEv(ev)
|
||||
|
||||
local old_rotation_mode = self.device.screen:getRotationMode()
|
||||
local old_screen_mode = self.device.screen:getScreenMode()
|
||||
DEBUG:v("old_rotation_mode: ", old_rotation_mode)
|
||||
DEBUG:v("new_rotation_mode: ", rotation_mode)
|
||||
DEBUG:v("old_screen_mode: ", old_screen_mode)
|
||||
DEBUG:v("new_screen_mode: ", screen_mode)
|
||||
if rotation_mode ~= old_rotation_mode and screen_mode == old_screen_mode then
|
||||
self.device.screen:setRotationMode(rotation_mode)
|
||||
local UIManager = require("ui/uimanager")
|
||||
@@ -588,7 +584,7 @@ function Input:waitEvent(timeout_us)
|
||||
-- TODO: return an event that can be handled
|
||||
os.exit(0)
|
||||
end
|
||||
--DEBUG("got error waiting for events:", ev)
|
||||
logger.warn("got error waiting for events:", ev)
|
||||
if ev ~= "Waiting for input failed: 4\n" then
|
||||
-- we only abort if the error is not EINTR
|
||||
break
|
||||
@@ -598,11 +594,11 @@ function Input:waitEvent(timeout_us)
|
||||
if ok and ev then
|
||||
if DEBUG.is_on and ev then
|
||||
DEBUG:logEv(ev)
|
||||
DEBUG:v("ev", ev)
|
||||
logger.dbg("ev", ev)
|
||||
end
|
||||
self:eventAdjustHook(ev)
|
||||
if ev.type == EV_KEY then
|
||||
DEBUG("key ev", ev)
|
||||
logger.dbg("key ev", ev)
|
||||
return self:handleKeyBoardEv(ev)
|
||||
elseif ev.type == EV_ABS and ev.code == ABS_OASIS_ORIENTATION then
|
||||
return self:handleOasisOrientationEv(ev)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local Generic = require("device/generic/device")
|
||||
local util = require("ffi/util")
|
||||
local Event = require("ui/event")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local function yes() return true end
|
||||
local function no() return false end -- luacheck: ignore
|
||||
@@ -189,7 +189,7 @@ local KindleBasic2 = Kindle:new{
|
||||
}
|
||||
|
||||
function Kindle2:init()
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
is_charging_file = "/sys/devices/platform/charger/charging",
|
||||
@@ -204,7 +204,7 @@ function Kindle2:init()
|
||||
end
|
||||
|
||||
function KindleDXG:init()
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
is_charging_file = "/sys/devices/platform/charger/charging",
|
||||
@@ -220,7 +220,7 @@ function KindleDXG:init()
|
||||
end
|
||||
|
||||
function Kindle3:init()
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
batt_capacity_file = "/sys/devices/system/luigi_battery/luigi_battery0/battery_capacity",
|
||||
@@ -237,7 +237,7 @@ function Kindle3:init()
|
||||
end
|
||||
|
||||
function Kindle4:init()
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
batt_capacity_file = "/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity",
|
||||
@@ -258,7 +258,7 @@ local ABS_MT_POSITION_X = 53
|
||||
local ABS_MT_POSITION_Y = 54
|
||||
-- luacheck: pop
|
||||
function KindleTouch:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
batt_capacity_file = "/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity",
|
||||
@@ -282,7 +282,7 @@ function KindleTouch:init()
|
||||
end
|
||||
|
||||
function KindlePaperWhite:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
fl_intensity_file = "/sys/devices/system/fl_tps6116x/fl_tps6116x0/fl_intensity",
|
||||
@@ -297,7 +297,7 @@ function KindlePaperWhite:init()
|
||||
end
|
||||
|
||||
function KindlePaperWhite2:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
fl_intensity_file = "/sys/class/backlight/max77696-bl/brightness",
|
||||
@@ -312,7 +312,7 @@ function KindlePaperWhite2:init()
|
||||
end
|
||||
|
||||
function KindleBasic:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
batt_capacity_file = "/sys/devices/system/wario_battery/wario_battery0/battery_capacity",
|
||||
@@ -326,7 +326,7 @@ function KindleBasic:init()
|
||||
end
|
||||
|
||||
function KindleVoyage:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
fl_intensity_file = "/sys/class/backlight/max77696-bl/brightness",
|
||||
@@ -378,7 +378,7 @@ function KindleVoyage:init()
|
||||
end
|
||||
|
||||
function KindlePaperWhite3:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
fl_intensity_file = "/sys/class/backlight/max77696-bl/brightness",
|
||||
@@ -393,7 +393,7 @@ function KindlePaperWhite3:init()
|
||||
end
|
||||
|
||||
function KindleOasis:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
fl_intensity_file = "/sys/class/backlight/max77696-bl/brightness",
|
||||
@@ -460,7 +460,7 @@ function KindleOasis:init()
|
||||
end
|
||||
|
||||
function KindleBasic2:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
device = self,
|
||||
batt_capacity_file = "/sys/class/power_supply/bd7181x_bat/capacity",
|
||||
@@ -480,12 +480,12 @@ local function isSpecialOffers()
|
||||
-- Look at the current blanket modules to see if the SO screensavers are enabled...
|
||||
local lipc = require("liblipclua")
|
||||
if not lipc then
|
||||
DEBUG("could not load liblibclua")
|
||||
logger.warn("could not load liblibclua")
|
||||
return false
|
||||
end
|
||||
local lipc_handle = lipc.init("com.github.koreader.device")
|
||||
if not lipc_handle then
|
||||
DEBUG("could not get lipc handle")
|
||||
logger.warn("could not get lipc handle")
|
||||
return false
|
||||
end
|
||||
local so = false
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
local Generic = require("device/generic/device")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local Geom = require("ui/geometry")
|
||||
local dbg = require("dbg")
|
||||
local util = require("ffi/util")
|
||||
local _ = require("gettext")
|
||||
local logger = require("logger")
|
||||
|
||||
local function yes() return true end
|
||||
|
||||
@@ -123,7 +124,7 @@ local KoboPika = Kobo:new{
|
||||
}
|
||||
|
||||
function Kobo:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = dbg}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/kobo/powerd"):new{device = self}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
@@ -320,16 +321,131 @@ function Kobo:getFirmwareVersion()
|
||||
end
|
||||
|
||||
function Kobo:suspend()
|
||||
dbg("Executing kobo suspend script...")
|
||||
os.execute("./suspend.sh")
|
||||
dbg("Returned from kobo suspend script.")
|
||||
logger.info("Kobo Suspend: Going to sleep . . .")
|
||||
local f, re, err_msg, err_code
|
||||
-- NOTE: Sleep as little as possible here, sleeping has a tendency to make
|
||||
-- everything mysteriously hang...
|
||||
|
||||
-- Depending on device/FW version, some kernels do not support
|
||||
-- wakeup_count, account for that
|
||||
--
|
||||
-- NOTE: ... and of course, it appears to be broken, which probably
|
||||
-- explains why nickel doesn't use this facility...
|
||||
-- (By broken, I mean that the system wakes up right away).
|
||||
-- So, unless that changes, unconditionally disable it.
|
||||
|
||||
--[[
|
||||
|
||||
local has_wakeup_count = false
|
||||
f = io.open("/sys/power/wakeup_count", "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
has_wakeup_count = true
|
||||
end
|
||||
|
||||
-- Clear the kernel ring buffer... (we're missing a proper -C flag...)
|
||||
--dmesg -c >/dev/null
|
||||
|
||||
-- Go to sleep
|
||||
local curr_wakeup_count
|
||||
if has_wakeup_count then
|
||||
curr_wakeup_count = "$(cat /sys/power/wakeup_count)"
|
||||
logger.info("Kobo Suspend: Current WakeUp count:", curr_wakeup_count)
|
||||
end
|
||||
|
||||
-]]
|
||||
|
||||
f = io.open("/sys/power/state-extended", "w")
|
||||
if not f then
|
||||
logger.err("Cannot open /sys/power/state-extended for writing!")
|
||||
return false
|
||||
end
|
||||
-- NOTE: Sets gSleep_Mode_Suspend to 1. Used as a flag throughout the
|
||||
-- kernel to suspend/resume various subsystems
|
||||
-- cf. kernel/power/main.c @ L#207
|
||||
re, err_msg, err_code = f:write("1\n")
|
||||
logger.info("Write syscall returned: ", re)
|
||||
if not re then
|
||||
logger.err('write error: ', err_msg, err_code)
|
||||
end
|
||||
io.close(f)
|
||||
logger.info("Kobo Suspend: Asked the kernel to put subsystems to sleep")
|
||||
|
||||
util.sleep(2)
|
||||
logger.info("Kobo Suspend: Waited for 2s because of reasons...")
|
||||
|
||||
os.execute("sync")
|
||||
logger.info("Kobo Suspend: Synced FS")
|
||||
|
||||
--[[
|
||||
|
||||
if has_wakeup_count then
|
||||
f = io.open("/sys/power/wakeup_count", "w")
|
||||
if not f then
|
||||
logger.err("Cannot open /sys/power/wakeup_count")
|
||||
return false
|
||||
end
|
||||
re, err_msg, err_code = f:write(tostring(curr_wakeup_count), "\n")
|
||||
logger.info("Kobo Suspend: Wrote WakeUp count:", curr_wakeup_count)
|
||||
if not re then
|
||||
logger.err("Kobo Suspend: failed to write WakeUp count:",
|
||||
err_msg,
|
||||
err_code)
|
||||
end
|
||||
io.close(f)
|
||||
end
|
||||
|
||||
--]]
|
||||
|
||||
logger.info("Kobo Suspend: Asking for a suspend to RAM . . .")
|
||||
f = io.open("/sys/power/state", "w")
|
||||
if not f then
|
||||
-- TODO: update state-extended?
|
||||
return false
|
||||
end
|
||||
re, err_msg, err_code = f:write("mem\n")
|
||||
-- NOTE: At this point, we *should* be in suspend to RAM, as such,
|
||||
-- execution should only resume on wakeup...
|
||||
|
||||
logger.info("Kobo Suspend: ZzZ ZzZ ZzZ? Write syscall returned: ", re)
|
||||
if not re then
|
||||
logger.err('write error: ', err_msg, err_code)
|
||||
end
|
||||
io.close(f)
|
||||
-- NOTE: Ideally, we'd need a way to warn the user that suspending
|
||||
-- gloriously failed at this point...
|
||||
-- We can safely assume that just from a non-zero return code, without
|
||||
-- looking at the detailed stderr message
|
||||
-- (most of the failures we'll see are -EBUSY anyway)
|
||||
-- For reference, when that happens to nickel, it appears to keep retrying
|
||||
-- to wakeup & sleep ad nauseam,
|
||||
-- which is where the non-sensical 1 -> mem -> 0 loop idea comes from...
|
||||
-- cf. nickel_suspend_strace.txt for more details.
|
||||
|
||||
logger.info("Kobo Suspend: Woke up!")
|
||||
|
||||
--[[
|
||||
|
||||
if has_wakeup_count then
|
||||
logger.info("WakeUp count: $(cat /sys/power/wakeup_count)")
|
||||
end
|
||||
|
||||
-- Print tke kernel log since our attempt to sleep...
|
||||
--dmesg -c
|
||||
|
||||
--]]
|
||||
|
||||
-- NOTE: We unflag /sys/power/state-extended in Kobo:resume() to keep
|
||||
-- things tidy and easier to follow
|
||||
end
|
||||
|
||||
function Kobo:resume()
|
||||
-- Unflag subsystems for suspend
|
||||
-- Now that we're up, unflag subsystems for suspend...
|
||||
os.execute("echo 0 > /sys/power/state-extended")
|
||||
-- HACK: wait a bit for the kernel to catch up
|
||||
os.execute("sleep 0.1")
|
||||
logger.info("Kobo Suspend: Unflagged kernel subsystems for suspend")
|
||||
|
||||
-- HACK: wait a bit (0.1 sec) for the kernel to catch up
|
||||
util.usleep(100000)
|
||||
-- cf. #1862, I can reliably break IR touch input on resume...
|
||||
-- cf. also #1943 for the rationale behind applying this workaorund in every case...
|
||||
local f = io.open("/sys/devices/virtual/input/input1/neocmd", "r")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local Generic = require("device/generic/device") -- <= look at this file!
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
-- luacheck: push
|
||||
-- luacheck: ignore
|
||||
@@ -51,7 +51,6 @@ local PocketBook = Generic:new{
|
||||
|
||||
function PocketBook:init()
|
||||
self.input:registerEventAdjustHook(function(_input, ev)
|
||||
--DEBUG("ev", ev.type, ev.code, ev.value)
|
||||
if ev.type == EVT_KEYDOWN or ev.type == EVT_KEYUP then
|
||||
ev.code = ev.code
|
||||
ev.value = ev.type == EVT_KEYDOWN and 1 or 0
|
||||
@@ -96,7 +95,7 @@ local PocketBook840 = PocketBook:new{
|
||||
}
|
||||
|
||||
function PocketBook840:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
||||
self.powerd = require("device/pocketbook/powerd"):new{device = self}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local Generic = require("device/generic/device")
|
||||
local util = require("ffi/util")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local function yes() return true end
|
||||
local function no() return false end
|
||||
@@ -33,13 +33,13 @@ function Device:init()
|
||||
end
|
||||
|
||||
if util.haveSDL2() then
|
||||
self.screen = require("ffi/framebuffer_SDL2_0"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_SDL2_0"):new{device = self, debug = logger.dbg}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = require("device/sdl/event_map_sdl2"),
|
||||
}
|
||||
else
|
||||
self.screen = require("ffi/framebuffer_SDL1_2"):new{device = self, debug = DEBUG}
|
||||
self.screen = require("ffi/framebuffer_SDL1_2"):new{device = self, debug = logger.dbg}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = require("device/sdl/event_map_sdl"),
|
||||
|
||||
@@ -6,7 +6,7 @@ local DataStorage = require("datastorage")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("device").screen
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local ffi = require("ffi")
|
||||
|
||||
local CreDocument = Document:new{
|
||||
@@ -61,7 +61,7 @@ function CreDocument:engineInit()
|
||||
if not _v:find("/urw/") then
|
||||
local ok, err = pcall(cre.registerFont, _v)
|
||||
if not ok then
|
||||
DEBUG(err)
|
||||
logger.err("failed to register crengine font", err)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -157,9 +157,9 @@ end
|
||||
|
||||
function CreDocument:getWordFromPosition(pos)
|
||||
local word_box = self._document:getWordFromPosition(pos.x, pos.y)
|
||||
DEBUG("CreDocument: get word box", word_box)
|
||||
logger.dbg("CreDocument: get word box", word_box)
|
||||
local text_range = self._document:getTextFromPositions(pos.x, pos.y, pos.x, pos.y)
|
||||
DEBUG("CreDocument: get text range", text_range)
|
||||
logger.dbg("CreDocument: get text range", text_range)
|
||||
local wordbox = {
|
||||
word = text_range.text == "" and word_box.word or text_range.text,
|
||||
page = self._document:getCurrentPage(),
|
||||
@@ -182,7 +182,7 @@ end
|
||||
|
||||
function CreDocument:getTextFromPositions(pos0, pos1)
|
||||
local text_range = self._document:getTextFromPositions(pos0.x, pos0.y, pos1.x, pos1.y)
|
||||
DEBUG("CreDocument: get text range", text_range)
|
||||
logger.dbg("CreDocument: get text range", text_range)
|
||||
if text_range then
|
||||
-- local line_boxes = self:getScreenBoxesFromPositions(text_range.pos0, text_range.pos1)
|
||||
return {
|
||||
@@ -198,7 +198,6 @@ function CreDocument:getScreenBoxesFromPositions(pos0, pos1)
|
||||
local line_boxes = {}
|
||||
if pos0 and pos1 then
|
||||
local word_boxes = self._document:getWordBoxesFromPositions(pos0, pos1)
|
||||
-- DEBUG("word boxes", word_boxes)
|
||||
for i = 1, #word_boxes do
|
||||
local line_box = word_boxes[i]
|
||||
table.insert(line_boxes, Geom:new{
|
||||
@@ -207,7 +206,6 @@ function CreDocument:getScreenBoxesFromPositions(pos0, pos1)
|
||||
h = line_box.y1 - line_box.y0,
|
||||
})
|
||||
end
|
||||
--DEBUG("line boxes", line_boxes)
|
||||
end
|
||||
return line_boxes
|
||||
end
|
||||
@@ -244,7 +242,7 @@ function CreDocument:renderPage(pageno, rect, zoom, rotation)
|
||||
end
|
||||
|
||||
function CreDocument:gotoXPointer(xpointer)
|
||||
DEBUG("CreDocument: goto xpointer", xpointer)
|
||||
logger.dbg("CreDocument: goto xpointer", xpointer)
|
||||
self._document:gotoXPointer(xpointer)
|
||||
end
|
||||
|
||||
@@ -277,27 +275,27 @@ function CreDocument:getLinkFromPosition(pos)
|
||||
end
|
||||
|
||||
function Document:gotoPos(pos)
|
||||
DEBUG("CreDocument: goto position", pos)
|
||||
logger.dbg("CreDocument: goto position", pos)
|
||||
self._document:gotoPos(pos)
|
||||
end
|
||||
|
||||
function CreDocument:gotoPage(page)
|
||||
DEBUG("CreDocument: goto page", page)
|
||||
logger.dbg("CreDocument: goto page", page)
|
||||
self._document:gotoPage(page)
|
||||
end
|
||||
|
||||
function CreDocument:gotoLink(link)
|
||||
DEBUG("CreDocument: goto link", link)
|
||||
logger.dbg("CreDocument: goto link", link)
|
||||
self._document:gotoLink(link)
|
||||
end
|
||||
|
||||
function CreDocument:goBack()
|
||||
DEBUG("CreDocument: go back")
|
||||
logger.dbg("CreDocument: go back")
|
||||
self._document:goBack()
|
||||
end
|
||||
|
||||
function CreDocument:goForward(link)
|
||||
DEBUG("CreDocument: go forward")
|
||||
logger.dbg("CreDocument: go forward")
|
||||
self._document:goForward()
|
||||
end
|
||||
|
||||
@@ -307,20 +305,20 @@ end
|
||||
|
||||
function CreDocument:setFontFace(new_font_face)
|
||||
if new_font_face then
|
||||
DEBUG("CreDocument: set font face", new_font_face)
|
||||
logger.dbg("CreDocument: set font face", new_font_face)
|
||||
self._document:setStringProperty("font.face.default", new_font_face)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:setHyphDictionary(new_hyph_dictionary)
|
||||
if new_hyph_dictionary then
|
||||
DEBUG("CreDocument: set hyphenation dictionary", new_hyph_dictionary)
|
||||
logger.dbg("CreDocument: set hyphenation dictionary", new_hyph_dictionary)
|
||||
self._document:setStringProperty("crengine.hyphenation.directory", new_hyph_dictionary)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:clearSelection()
|
||||
DEBUG("clear selection")
|
||||
logger.dbg("clear selection")
|
||||
self._document:clearSelection()
|
||||
end
|
||||
|
||||
@@ -330,14 +328,14 @@ end
|
||||
|
||||
function CreDocument:setFontSize(new_font_size)
|
||||
if new_font_size then
|
||||
DEBUG("CreDocument: set font size", new_font_size)
|
||||
logger.dbg("CreDocument: set font size", new_font_size)
|
||||
self._document:setFontSize(new_font_size)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:setViewMode(new_mode)
|
||||
if new_mode then
|
||||
DEBUG("CreDocument: set view mode", new_mode)
|
||||
logger.dbg("CreDocument: set view mode", new_mode)
|
||||
if new_mode == "scroll" then
|
||||
self._document:setViewMode(self.SCROLL_VIEW_MODE)
|
||||
else
|
||||
@@ -347,50 +345,50 @@ function CreDocument:setViewMode(new_mode)
|
||||
end
|
||||
|
||||
function CreDocument:setViewDimen(dimen)
|
||||
DEBUG("CreDocument: set view dimen", dimen)
|
||||
logger.dbg("CreDocument: set view dimen", dimen)
|
||||
self._document:setViewDimen(dimen.w, dimen.h)
|
||||
end
|
||||
|
||||
function CreDocument:setHeaderFont(new_font)
|
||||
if new_font then
|
||||
DEBUG("CreDocument: set header font", new_font)
|
||||
logger.dbg("CreDocument: set header font", new_font)
|
||||
self._document:setHeaderFont(new_font)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:zoomFont(delta)
|
||||
DEBUG("CreDocument: zoom font", delta)
|
||||
logger.dbg("CreDocument: zoom font", delta)
|
||||
self._document:zoomFont(delta)
|
||||
end
|
||||
|
||||
function CreDocument:setInterlineSpacePercent(percent)
|
||||
DEBUG("CreDocument: set interline space", percent)
|
||||
logger.dbg("CreDocument: set interline space", percent)
|
||||
self._document:setDefaultInterlineSpace(percent)
|
||||
end
|
||||
|
||||
function CreDocument:toggleFontBolder(toggle)
|
||||
DEBUG("CreDocument: toggle font bolder", toggle)
|
||||
logger.dbg("CreDocument: toggle font bolder", toggle)
|
||||
self._document:setIntProperty("font.face.weight.embolden", toggle)
|
||||
end
|
||||
|
||||
function CreDocument:setGammaIndex(index)
|
||||
DEBUG("CreDocument: set gamma index", index)
|
||||
logger.dbg("CreDocument: set gamma index", index)
|
||||
cre.setGammaIndex(index)
|
||||
end
|
||||
|
||||
function CreDocument:setStyleSheet(new_css)
|
||||
DEBUG("CreDocument: set style sheet", new_css)
|
||||
logger.dbg("CreDocument: set style sheet", new_css)
|
||||
self._document:setStyleSheet(new_css)
|
||||
end
|
||||
|
||||
function CreDocument:setEmbeddedStyleSheet(toggle)
|
||||
-- FIXME: occasional segmentation fault when switching embedded style sheet
|
||||
DEBUG("CreDocument: set embedded style sheet", toggle)
|
||||
logger.dbg("CreDocument: set embedded style sheet", toggle)
|
||||
self._document:setIntProperty("crengine.doc.embedded.styles.enabled", toggle)
|
||||
end
|
||||
|
||||
function CreDocument:setPageMargins(left, top, right, bottom)
|
||||
DEBUG("CreDocument: set page margins", left, top, right, bottom)
|
||||
logger.dbg("CreDocument: set page margins", left, top, right, bottom)
|
||||
self._document:setIntProperty("crengine.page.margin.left", left)
|
||||
self._document:setIntProperty("crengine.page.margin.top", top)
|
||||
self._document:setIntProperty("crengine.page.margin.right", right)
|
||||
@@ -399,7 +397,7 @@ end
|
||||
|
||||
function CreDocument:setFloatingPunctuation(enabled)
|
||||
-- FIXME: occasional segmentation fault when toggling floating punctuation
|
||||
DEBUG("CreDocument: set floating punctuation", enabled)
|
||||
logger.dbg("CreDocument: set floating punctuation", enabled)
|
||||
self._document:setIntProperty("crengine.style.floating.punctuation.enabled", enabled)
|
||||
end
|
||||
|
||||
@@ -408,27 +406,27 @@ function CreDocument:getVisiblePageCount()
|
||||
end
|
||||
|
||||
function CreDocument:setVisiblePageCount(new_count)
|
||||
DEBUG("CreDocument: set visible page count", new_count)
|
||||
logger.dbg("CreDocument: set visible page count", new_count)
|
||||
self._document:setVisiblePageCount(new_count)
|
||||
end
|
||||
|
||||
function CreDocument:setBatteryState(state)
|
||||
DEBUG("CreDocument: set battery state", state)
|
||||
logger.dbg("CreDocument: set battery state", state)
|
||||
self._document:setBatteryState(state)
|
||||
end
|
||||
|
||||
function CreDocument:isXPointerInCurrentPage(xp)
|
||||
DEBUG("CreDocument: check xpointer in current page", xp)
|
||||
logger.dbg("CreDocument: check xpointer in current page", xp)
|
||||
return self._document:isXPointerInCurrentPage(xp)
|
||||
end
|
||||
|
||||
function CreDocument:setStatusLineProp(prop)
|
||||
DEBUG("CreDocument: set status line property", prop)
|
||||
logger.dbg("CreDocument: set status line property", prop)
|
||||
self._document:setStringProperty("window.status.line", prop)
|
||||
end
|
||||
|
||||
function CreDocument:findText(pattern, origin, reverse, caseInsensitive)
|
||||
DEBUG("CreDocument: find text", pattern, origin, reverse, caseInsensitive)
|
||||
logger.dbg("CreDocument: find text", pattern, origin, reverse, caseInsensitive)
|
||||
return self._document:findText(
|
||||
pattern, origin, reverse, caseInsensitive and 1 or 0)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ local CacheItem = require("cacheitem")
|
||||
local Geom = require("ui/geometry")
|
||||
local Math = require("optmath")
|
||||
local Cache = require("cache")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
--[[
|
||||
This is an abstract interface to a document
|
||||
@@ -177,36 +177,30 @@ function Document:getPageDimensions(pageno, zoom, rotation)
|
||||
native_dimen.w, native_dimen.h = native_dimen.h, native_dimen.w
|
||||
end
|
||||
native_dimen:scaleBy(zoom)
|
||||
--DEBUG("dimen for pageno", pageno, "zoom", zoom, "rotation", rotation, "is", native_dimen)
|
||||
return native_dimen
|
||||
end
|
||||
|
||||
function Document:getPageBBox(pageno)
|
||||
local bbox = self.bbox[pageno] -- exact
|
||||
if bbox ~= nil then
|
||||
--DEBUG("bbox from", pageno)
|
||||
return bbox
|
||||
else
|
||||
local oddEven = Math.oddEven(pageno)
|
||||
bbox = self.bbox[oddEven] -- odd/even
|
||||
end
|
||||
if bbox ~= nil then -- last used up to this page
|
||||
--DEBUG("bbox from", oddEven)
|
||||
return bbox
|
||||
else
|
||||
for i = 0,pageno do
|
||||
bbox = self.bbox[ pageno - i ]
|
||||
if bbox ~= nil then
|
||||
--DEBUG("bbox from", pageno - i)
|
||||
return bbox
|
||||
end
|
||||
end
|
||||
end
|
||||
if bbox == nil then -- fallback bbox
|
||||
bbox = self:getUsedBBox(pageno)
|
||||
--DEBUG("bbox from ORIGINAL page")
|
||||
end
|
||||
--DEBUG("final bbox", bbox)
|
||||
return bbox
|
||||
end
|
||||
|
||||
@@ -287,10 +281,10 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
||||
-- we prefer to render the full page, if it fits into cache
|
||||
if not Cache:willAccept(size.w * size.h + 64) then
|
||||
-- whole page won't fit into cache
|
||||
DEBUG("rendering only part of the page")
|
||||
logger.dbg("rendering only part of the page")
|
||||
-- TODO: figure out how to better segment the page
|
||||
if not rect then
|
||||
DEBUG("aborting, since we do not have a specification for that part")
|
||||
logger.warn("aborting, since we do not have a specification for that part")
|
||||
-- required part not given, so abort
|
||||
return
|
||||
end
|
||||
@@ -323,7 +317,6 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
||||
dc:setZoom(zoom)
|
||||
|
||||
if gamma ~= self.GAMMA_NO_GAMMA then
|
||||
--DEBUG("gamma correction: ", gamma)
|
||||
dc:setGamma(gamma)
|
||||
end
|
||||
|
||||
@@ -339,7 +332,7 @@ end
|
||||
-- a hint for the cache engine to paint a full page to the cache
|
||||
-- TODO: this should trigger a background operation
|
||||
function Document:hintPage(pageno, zoom, rotation, gamma, render_mode)
|
||||
DEBUG("hinting page", pageno)
|
||||
logger.dbg("hinting page", pageno)
|
||||
self:renderPage(pageno, nil, zoom, rotation, gamma, render_mode)
|
||||
end
|
||||
|
||||
@@ -353,7 +346,6 @@ Draw page content to blitbuffer.
|
||||
--]]
|
||||
function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, render_mode)
|
||||
local tile = self:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
||||
DEBUG:v("document drawing", tile, rect)
|
||||
target:blitFrom(tile.bb,
|
||||
x, y,
|
||||
rect.x - tile.excerpt.x,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
--[[
|
||||
This is a registry for document providers
|
||||
@@ -34,7 +34,7 @@ function DocumentRegistry:openDocument(file)
|
||||
refs = 1,
|
||||
}
|
||||
else
|
||||
DEBUG("cannot open document", file, doc)
|
||||
logger.warn("cannot open document", file, doc)
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
@@ -8,6 +8,7 @@ local Geom = require("ui/geometry")
|
||||
local serial = require("serialize")
|
||||
local Cache = require("cache")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local util = require("ffi/util")
|
||||
|
||||
local KoptInterface = {
|
||||
@@ -25,20 +26,20 @@ local ContextCacheItem = CacheItem:new{}
|
||||
function ContextCacheItem:onFree()
|
||||
if self.kctx.free then
|
||||
KoptInterface:waitForContext(self.kctx)
|
||||
DEBUG("free koptcontext", self.kctx)
|
||||
logger.dbg("free koptcontext", self.kctx)
|
||||
self.kctx:free()
|
||||
end
|
||||
end
|
||||
|
||||
function ContextCacheItem:dump(filename)
|
||||
if self.kctx:isPreCache() == 0 then
|
||||
DEBUG("dumping koptcontext to", filename)
|
||||
logger.dbg("dumping koptcontext to", filename)
|
||||
return serial.dump(self.size, KOPTContext.totable(self.kctx), filename)
|
||||
end
|
||||
end
|
||||
|
||||
function ContextCacheItem:load(filename)
|
||||
DEBUG("loading koptcontext from", filename)
|
||||
logger.dbg("loading koptcontext from", filename)
|
||||
local size, kc_table = serial.load(filename)
|
||||
self.size = size
|
||||
self.kctx = KOPTContext.fromtable(kc_table)
|
||||
@@ -48,7 +49,7 @@ local OCREngine = CacheItem:new{}
|
||||
|
||||
function OCREngine:onFree()
|
||||
if self.ocrengine.freeOCR then
|
||||
DEBUG("free OCREngine", self.ocrengine)
|
||||
logger.dbg("free OCREngine", self.ocrengine)
|
||||
self.ocrengine:freeOCR()
|
||||
end
|
||||
end
|
||||
@@ -57,7 +58,7 @@ function KoptInterface:waitForContext(kc)
|
||||
-- if koptcontext is being processed in background thread
|
||||
-- the isPreCache will return 1.
|
||||
while kc and kc:isPreCache() == 1 do
|
||||
DEBUG("waiting for background rendering")
|
||||
logger.dbg("waiting for background rendering")
|
||||
util.usleep(100000)
|
||||
end
|
||||
return kc
|
||||
@@ -142,17 +143,13 @@ function KoptInterface:getAutoBBox(doc, pageno)
|
||||
if not cached then
|
||||
local page = doc._document:openPage(pageno)
|
||||
local kc = self:createContext(doc, pageno, bbox)
|
||||
--DEBUGBT()
|
||||
--DEBUG("getAutoBBox:native page size", native_size)
|
||||
page:getPagePix(kc)
|
||||
local x0, y0, x1, y1 = kc:getAutoBBox()
|
||||
local w, h = native_size.w, native_size.h
|
||||
if (x1 - x0)/w > 0.1 or (y1 - y0)/h > 0.1 then
|
||||
bbox.x0, bbox.y0, bbox.x1, bbox.y1 = x0, y0, x1, y1
|
||||
--DEBUG("getAutoBBox:auto detected bbox", bbox)
|
||||
else
|
||||
bbox = Document.getPageBBox(doc, pageno)
|
||||
--DEBUG("getAutoBBox:use manual bbox", bbox)
|
||||
end
|
||||
Cache:insert(hash, CacheItem:new{ autobbox = bbox })
|
||||
page:close()
|
||||
@@ -182,7 +179,7 @@ function KoptInterface:getSemiAutoBBox(doc, pageno)
|
||||
auto_bbox.y0 = auto_bbox.y0 + bbox.y0
|
||||
auto_bbox.x1 = auto_bbox.x1 + bbox.x0
|
||||
auto_bbox.y1 = auto_bbox.y1 + bbox.y0
|
||||
DEBUG("Semi-auto detected bbox", auto_bbox)
|
||||
logger.dbg("Semi-auto detected bbox", auto_bbox)
|
||||
page:close()
|
||||
Cache:insert(hash, CacheItem:new{ semiautobbox = auto_bbox })
|
||||
kc:free()
|
||||
@@ -206,17 +203,16 @@ function KoptInterface:getCachedContext(doc, pageno)
|
||||
-- If kctx is not cached, create one and get reflowed bmp in foreground.
|
||||
local kc = self:createContext(doc, pageno, bbox)
|
||||
local page = doc._document:openPage(pageno)
|
||||
DEBUG("reflowing page", pageno, "in foreground")
|
||||
logger.dbg("reflowing page", pageno, "in foreground")
|
||||
-- reflow page
|
||||
--local secs, usecs = util.gettime()
|
||||
page:reflow(kc, 0)
|
||||
page:close()
|
||||
--local nsecs, nusecs = util.gettime()
|
||||
--local dur = nsecs - secs + (nusecs - usecs) / 1000000
|
||||
--DEBUG("Reflow duration:", dur)
|
||||
--self:logReflowDuration(pageno, dur)
|
||||
local fullwidth, fullheight = kc:getPageDim()
|
||||
DEBUG("reflowed page", pageno, "fullwidth:", fullwidth, "fullheight:", fullheight)
|
||||
logger.dbg("reflowed page", pageno, "fullwidth:", fullwidth, "fullheight:", fullheight)
|
||||
self.last_context_size = fullwidth * fullheight + 128 -- estimation
|
||||
Cache:insert(kctx_hash, ContextCacheItem:new{
|
||||
persistent = true,
|
||||
@@ -332,7 +328,7 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, re
|
||||
kc:setZoom(zoom)
|
||||
page:getPagePix(kc)
|
||||
page:close()
|
||||
DEBUG("optimizing page", pageno)
|
||||
logger.dbg("optimizing page", pageno)
|
||||
kc:optimizePage()
|
||||
local fullwidth, fullheight = kc:getPageDim()
|
||||
-- prepare cache item with contained blitbuffer
|
||||
@@ -379,7 +375,7 @@ function KoptInterface:hintReflowedPage(doc, pageno, zoom, rotation, gamma, rend
|
||||
if not cached then
|
||||
local kc = self:createContext(doc, pageno, bbox)
|
||||
local page = doc._document:openPage(pageno)
|
||||
DEBUG("hinting page", pageno, "in background")
|
||||
logger.dbg("hinting page", pageno, "in background")
|
||||
-- reflow will return immediately and running in background thread
|
||||
kc:setPreCache()
|
||||
page:reflow(kc, 0)
|
||||
@@ -407,7 +403,6 @@ draw cached tile pixels into target blitbuffer.
|
||||
--]]
|
||||
function KoptInterface:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, render_mode)
|
||||
local tile = self:renderPage(doc, pageno, rect, zoom, rotation, render_mode)
|
||||
--DEBUG("now painting", tile, rect)
|
||||
target:blitFrom(tile.bb,
|
||||
x, y,
|
||||
rect.x - tile.excerpt.x,
|
||||
@@ -615,7 +610,7 @@ get word from OCR in native page
|
||||
function KoptInterface:getNativeOCRWord(doc, pageno, rect)
|
||||
self.ocr_lang = doc.configurable.doc_language
|
||||
local hash = "ocrword|"..doc.file.."|"..pageno..rect.x..rect.y..rect.w..rect.h
|
||||
DEBUG("hash", hash)
|
||||
logger.dbg("hash", hash)
|
||||
local cached = Cache:check(hash)
|
||||
if not cached then
|
||||
local bbox = {
|
||||
@@ -630,13 +625,12 @@ function KoptInterface:getNativeOCRWord(doc, pageno, rect)
|
||||
page:getPagePix(kc)
|
||||
--kc:exportSrcPNGFile({rect}, nil, "ocr-word.png")
|
||||
local word_w, word_h = kc:getPageDim()
|
||||
--DEBUG(word_w, word_h)
|
||||
local _, word = pcall(
|
||||
kc.getTOCRWord, kc, "src",
|
||||
0, 0, word_w, word_h,
|
||||
self.tessocr_data, self.ocr_lang, self.ocr_type, 0, 1)
|
||||
Cache:insert(hash, CacheItem:new{ ocrword = word })
|
||||
DEBUG("word", word)
|
||||
logger.dbg("word", word)
|
||||
page:close()
|
||||
kc:free()
|
||||
return word
|
||||
@@ -652,7 +646,7 @@ function KoptInterface:getOCRText(doc, pageno, tboxes)
|
||||
if not Cache:check(self.ocrengine) then
|
||||
Cache:insert(self.ocrengine, OCREngine:new{ ocrengine = KOPTContext.new() })
|
||||
end
|
||||
DEBUG("Not implemented yet")
|
||||
logger.info("Not implemented yet")
|
||||
end
|
||||
|
||||
function KoptInterface:getClipPageContext(doc, pos0, pos1, pboxes, drawer)
|
||||
@@ -869,16 +863,12 @@ function KoptInterface:getWordFromReflowPosition(doc, boxes, pos)
|
||||
|
||||
local scratch_reflowed_page_boxes = self:getReflowedTextBoxesFromScratch(doc, pageno)
|
||||
local scratch_reflowed_word_box = self:getWordFromBoxes(scratch_reflowed_page_boxes, pos)
|
||||
--DEBUG("word box from scratch", scratch_reflowed_word_box)
|
||||
|
||||
local reflowed_page_boxes = self:getReflowedTextBoxes(doc, pageno)
|
||||
local reflowed_word_box = self:getWordFromBoxes(reflowed_page_boxes, pos)
|
||||
--DEBUG("word box from reflow", reflowed_word_box)
|
||||
|
||||
local reflowed_pos_abs = scratch_reflowed_word_box.box:center()
|
||||
local reflowed_pos_rel = getBoxRelativePosition(scratch_reflowed_word_box.box, reflowed_word_box.box)
|
||||
--DEBUG("word box absolote center", reflowed_pos_abs)
|
||||
--DEBUG("word box relative center", reflowed_pos_rel)
|
||||
|
||||
local native_pos = self:reflowToNativePosTransform(doc, pageno, reflowed_pos_abs, reflowed_pos_rel)
|
||||
local native_word_box = self:getWordFromBoxes(boxes, native_pos)
|
||||
@@ -946,10 +936,8 @@ transform position in native page to reflowed page
|
||||
]]--
|
||||
function KoptInterface:nativeToReflowPosTransform(doc, pageno, pos)
|
||||
local kc = self:getCachedContext(doc, pageno)
|
||||
--DEBUG("transform native pos", pos)
|
||||
local rpos = {}
|
||||
rpos.x, rpos.y = kc:nativeToReflowPosTransform(pos.x, pos.y)
|
||||
--DEBUG("transformed reflowed pos", rpos)
|
||||
return rpos
|
||||
end
|
||||
|
||||
@@ -958,11 +946,8 @@ transform position in reflowed page to native page
|
||||
]]--
|
||||
function KoptInterface:reflowToNativePosTransform(doc, pageno, abs_pos, rel_pos)
|
||||
local kc = self:getCachedContext(doc, pageno)
|
||||
--kc:setDebug()
|
||||
--DEBUG("transform reflowed pos", abs_pos, rel_pos)
|
||||
local npos = {}
|
||||
npos.x, npos.y = kc:reflowToNativePosTransform(abs_pos.x, abs_pos.y, rel_pos.x, rel_pos.y)
|
||||
--DEBUG("transformed native pos", npos)
|
||||
return npos
|
||||
end
|
||||
|
||||
@@ -998,12 +983,9 @@ function KoptInterface:getTextFromReflowPositions(doc, native_boxes, pos0, pos1)
|
||||
local reflowed_pos_rel0 = getBoxRelativePosition(scratch_reflowed_word_box0.box, reflowed_word_box0.box)
|
||||
local reflowed_pos_abs1 = scratch_reflowed_word_box1.box:center()
|
||||
local reflowed_pos_rel1 = getBoxRelativePosition(scratch_reflowed_word_box1.box, reflowed_word_box1.box)
|
||||
--DEBUG("absolute positions", reflowed_pos_abs0, reflowed_pos_abs1)
|
||||
--DEBUG("relative positions", reflowed_pos_rel0, reflowed_pos_rel1)
|
||||
|
||||
local native_pos0 = self:reflowToNativePosTransform(doc, pageno, reflowed_pos_abs0, reflowed_pos_rel0)
|
||||
local native_pos1 = self:reflowToNativePosTransform(doc, pageno, reflowed_pos_abs1, reflowed_pos_rel1)
|
||||
--DEBUG("native positions", native_pos0, native_pos1)
|
||||
|
||||
local reflowed_text_boxes = self:getTextFromBoxes(reflowed_page_boxes, pos0, pos1)
|
||||
local native_text_boxes = self:getTextFromBoxes(native_boxes, native_pos0, native_pos1)
|
||||
@@ -1127,7 +1109,6 @@ end
|
||||
function KoptInterface:findAllMatches(doc, pattern, caseInsensitive, page)
|
||||
local text_boxes = doc:getPageTextBoxes(page)
|
||||
if not text_boxes then return end
|
||||
--DEBUG("boxes", text_boxes)
|
||||
local matches = {}
|
||||
for indices in all_matches(text_boxes or {}, pattern, caseInsensitive) do
|
||||
for _, index in ipairs(indices) do
|
||||
@@ -1146,7 +1127,7 @@ function KoptInterface:findAllMatches(doc, pattern, caseInsensitive, page)
|
||||
end
|
||||
|
||||
function KoptInterface:findText(doc, pattern, origin, reverse, caseInsensitive, pageno)
|
||||
DEBUG("Koptinterface: find text", pattern, origin, reverse, caseInsensitive, pageno)
|
||||
logger.dbg("Koptinterface: find text", pattern, origin, reverse, caseInsensitive, pageno)
|
||||
local last_pageno = doc:getPageCount()
|
||||
local start_page, end_page
|
||||
if reverse == 1 then
|
||||
|
||||
@@ -3,7 +3,7 @@ local CacheItem = require("cacheitem")
|
||||
local KoptOptions = require("ui/data/koptoptions")
|
||||
local Document = require("document/document")
|
||||
local DrawContext = require("ffi/drawcontext")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
|
||||
local PdfDocument = Document:new{
|
||||
@@ -150,7 +150,7 @@ function PdfDocument:saveHighlight(pageno, item)
|
||||
end
|
||||
|
||||
function PdfDocument:writeDocument()
|
||||
DEBUG("writing document to", self.file)
|
||||
logger.info("writing document to", self.file)
|
||||
self._document:writeDocument(self.file)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local CacheItem = require("cacheitem")
|
||||
local serial = require("serialize")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local TileCacheItem = CacheItem:new{}
|
||||
|
||||
function TileCacheItem:onFree()
|
||||
if self.bb.free then
|
||||
DEBUG("free blitbuffer", self.bb)
|
||||
logger.dbg("free blitbuffer", self.bb)
|
||||
self.bb:free()
|
||||
end
|
||||
end
|
||||
|
||||
function TileCacheItem:dump(filename)
|
||||
DEBUG("dumping tile cache to", filename, self.excerpt)
|
||||
logger.dbg("dumping tile cache to", filename, self.excerpt)
|
||||
return serial.dump(self.size, self.excerpt, self.pageno,
|
||||
self.bb.w, self.bb.h, self.bb.pitch, self.bb:getType(),
|
||||
Blitbuffer.tostring(self.bb), filename)
|
||||
@@ -24,7 +24,7 @@ function TileCacheItem:load(filename)
|
||||
self.size, self.excerpt, self.pageno,
|
||||
w, h, pitch, bb_type, bb_data = serial.load(filename)
|
||||
self.bb = Blitbuffer.fromstring(w, h, bb_type, bb_data, pitch)
|
||||
DEBUG("loading tile cache from", filename, self)
|
||||
logger.dbg("loading tile cache from", filename, self)
|
||||
end
|
||||
|
||||
return TileCacheItem
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local isAndroid, android = pcall(require, "android")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local GetText = {
|
||||
translation = {},
|
||||
@@ -49,7 +49,7 @@ function GetText_mt.__index.changeLang(new_lang)
|
||||
local po = io.open(file, "r")
|
||||
|
||||
if not po then
|
||||
DEBUG("cannot open translation file " .. file)
|
||||
logger.err("cannot open translation file:", file)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
88
frontend/logger.lua
Normal file
88
frontend/logger.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
--[[--
|
||||
Logger module.
|
||||
See @{Logger.levels} for list of supported levels.
|
||||
|
||||
Example:
|
||||
|
||||
local logger = require("logger")
|
||||
logger.info("Something happened.")
|
||||
logger.err("House is on fire!")
|
||||
]]
|
||||
|
||||
local dump = require("dump")
|
||||
local isAndroid, android = pcall(require, "android")
|
||||
|
||||
local DEFAULT_DUMP_LVL = 10
|
||||
|
||||
--- Supported logging levels
|
||||
-- @table Logger.levels
|
||||
-- @field dbg debug
|
||||
-- @field info informational (default level)
|
||||
-- @field warn warning
|
||||
-- @field err error
|
||||
local LOG_LVL = {
|
||||
dbg = 1,
|
||||
info = 2,
|
||||
warn = 3,
|
||||
err = 4,
|
||||
}
|
||||
|
||||
local LOG_PREFIX = {
|
||||
dbg = 'DEBUG',
|
||||
info = 'INFO ',
|
||||
warn = 'WARN ',
|
||||
err = 'ERROR',
|
||||
}
|
||||
|
||||
local noop = function() end
|
||||
|
||||
local Logger = {
|
||||
levels = LOG_LVL,
|
||||
}
|
||||
|
||||
local function log(log_lvl, dump_lvl, ...)
|
||||
local line = ""
|
||||
for i,v in ipairs({...}) do
|
||||
if type(v) == "table" then
|
||||
line = line .. " " .. dump(v, dump_lvl)
|
||||
else
|
||||
line = line .. " " .. tostring(v)
|
||||
end
|
||||
end
|
||||
if isAndroid then
|
||||
android.LOGI(LOG_PREFIX[log_lvl]..line)
|
||||
else
|
||||
io.stdout:write(os.date("%x-%X"), " ", LOG_PREFIX[log_lvl], line, "\n")
|
||||
io.stdout:flush()
|
||||
end
|
||||
end
|
||||
|
||||
local LVL_FUNCTIONS = {
|
||||
dbg = function(...) log('dbg', DEFAULT_DUMP_LVL, ...) end,
|
||||
info = function(...) log('info', DEFAULT_DUMP_LVL, ...) end,
|
||||
warn = function(...) log('warn', DEFAULT_DUMP_LVL, ...) end,
|
||||
err = function(...) log('err', DEFAULT_DUMP_LVL, ...) end,
|
||||
}
|
||||
|
||||
|
||||
--[[--
|
||||
Set logging level. By default, level is set to info.
|
||||
|
||||
@int new_lvl new logging level, must be one of the levels from @{Logger.levels}
|
||||
|
||||
@usage
|
||||
Logger:setLevel(Logger.levels.warn)
|
||||
]]
|
||||
function Logger:setLevel(new_lvl)
|
||||
for lvl_name, lvl_value in pairs(LOG_LVL) do
|
||||
if new_lvl <= lvl_value then
|
||||
self[lvl_name] = LVL_FUNCTIONS[lvl_name]
|
||||
else
|
||||
self[lvl_name] = noop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Logger:setLevel(LOG_LVL.info)
|
||||
|
||||
return Logger
|
||||
@@ -1,5 +1,5 @@
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local PluginLoader = {
|
||||
plugin_path = "plugins"
|
||||
@@ -21,7 +21,7 @@ function PluginLoader:loadPlugins()
|
||||
package.cpath = path.."/lib/?.so;"..package.cpath
|
||||
local ok, plugin_module = pcall(dofile, mainfile)
|
||||
if not ok or not plugin_module then
|
||||
DEBUG("Error when loading", mainfile, plugin_module)
|
||||
logger.warn("Error when loading", mainfile, plugin_module)
|
||||
end
|
||||
if ok and plugin_module and not plugin_module.disabled then
|
||||
package.path = package_path
|
||||
|
||||
@@ -6,7 +6,7 @@ local lfs = require("libs/libkoreader-lfs")
|
||||
local Freetype = require("ffi/freetype")
|
||||
local Screen = require("device").screen
|
||||
local Device = require("device")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local Font = {
|
||||
fontmap = {
|
||||
@@ -83,7 +83,7 @@ function Font:getFace(font, size)
|
||||
realname = self.fontdir.."/"..realname
|
||||
local ok, face = pcall(Freetype.newFace, realname, size)
|
||||
if not ok then
|
||||
DEBUG("#! Font "..font.." ("..realname..") not supported: "..face)
|
||||
logger.warn("#! Font ", font, " (", realname, ") not supported: ", face)
|
||||
return nil
|
||||
end
|
||||
--- Freetype font face wrapper object
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local ffi = require("ffi")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local MessageQueue = require("ui/message/messagequeue")
|
||||
local _ = require("ffi/zeromq_h")
|
||||
local czmq = ffi.load("libs/libczmq.so.1")
|
||||
@@ -26,11 +26,11 @@ end
|
||||
|
||||
function FileMessageQueue:stop()
|
||||
if self.client ~= nil then
|
||||
DEBUG("stop filemq client")
|
||||
logger.dbg("stop filemq client")
|
||||
filemq.fmq_client_destroy(ffi.new('fmq_client_t *[1]', self.client))
|
||||
end
|
||||
if self.server ~= nil then
|
||||
DEBUG("stop filemq server")
|
||||
logger.dbg("stop filemq server")
|
||||
filemq.fmq_server_destroy(ffi.new('fmq_server_t *[1]', self.server))
|
||||
end
|
||||
if self.poller ~= nil then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local ffi = require("ffi")
|
||||
local Event = require("ui/event")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local _ = require("ffi/zeromq_h")
|
||||
local czmq = ffi.load("libs/libczmq.so.1")
|
||||
@@ -62,18 +62,16 @@ function MessageQueue:handleZMsgs(messages)
|
||||
end
|
||||
if #messages == 0 then return end
|
||||
local command = pop_string()
|
||||
DEBUG("ØMQ message", command)
|
||||
logger.dbg("ØMQ message", command)
|
||||
if command == "ENTER" then
|
||||
local id = pop_string()
|
||||
local name = pop_string()
|
||||
local header = pop_header()
|
||||
local endpoint = pop_string()
|
||||
--DEBUG(id, name, header, endpoint)
|
||||
return Event:new("ZyreEnter", id, name, header, endpoint)
|
||||
elseif command == "DELIVER" then
|
||||
local filename = pop_string()
|
||||
local fullname = pop_string()
|
||||
--DEBUG("received", filename)
|
||||
return Event:new("FileDeliver", filename, fullname)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local ffi = require("ffi")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local MessageQueue = require("ui/message/messagequeue")
|
||||
|
||||
local _ = require("ffi/zeromq_h")
|
||||
@@ -16,7 +16,7 @@ function StreamMessageQueue:start()
|
||||
self.socket = czmq.zsocket_new(self.context, ffi.C.ZMQ_STREAM)
|
||||
self.poller = czmq.zpoller_new(self.socket, nil)
|
||||
local endpoint = string.format("tcp://%s:%d", self.host, self.port)
|
||||
DEBUG("connect to endpoint", endpoint)
|
||||
logger.warn("connect to endpoint", endpoint)
|
||||
local rc = czmq.zsocket_connect(self.socket, endpoint)
|
||||
if rc ~= 0 then
|
||||
error("cannot connect to " .. endpoint)
|
||||
@@ -26,7 +26,7 @@ function StreamMessageQueue:start()
|
||||
-- @todo: check return of zmq_getsockopt
|
||||
zmq.zmq_getsockopt(self.socket, ffi.C.ZMQ_IDENTITY, buffer, id_size)
|
||||
self.id = ffi.string(buffer, id_size[0])
|
||||
DEBUG("id", #self.id, self.id)
|
||||
logger.dbg("id", #self.id, self.id)
|
||||
end
|
||||
|
||||
function StreamMessageQueue:stop()
|
||||
@@ -79,7 +79,6 @@ function StreamMessageQueue:waitEvent()
|
||||
end
|
||||
|
||||
function StreamMessageQueue:send(data)
|
||||
--DEBUG("send", data)
|
||||
local msg = czmq.zmsg_new()
|
||||
czmq.zmsg_addmem(msg, self.id, #self.id)
|
||||
czmq.zmsg_addmem(msg, data, #data)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local ffi = require("ffi")
|
||||
local DEBUG = require("dbg")
|
||||
local MessageQueue = require("ui/message/messagequeue")
|
||||
|
||||
local _ = require("ffi/zeromq_h")
|
||||
@@ -25,7 +24,6 @@ end
|
||||
|
||||
function ZyreMessageQueue:stop()
|
||||
if self.node ~= nil then
|
||||
DEBUG("stop zyre node")
|
||||
zyre.zyre_stop(self.node)
|
||||
zyre.zyre_destroy(ffi.new('zyre_t *[1]', self.node))
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ local lfs = require("libs/libkoreader-lfs")
|
||||
local DataStorage = require("datastorage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("device")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -59,7 +59,7 @@ function OTAManager:getOTAServer()
|
||||
end
|
||||
|
||||
function OTAManager:setOTAServer(server)
|
||||
DEBUG("Set OTA server:", server)
|
||||
logger.dbg("Set OTA server:", server)
|
||||
G_reader_settings:saveSetting("ota_server", server)
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ function OTAManager:getOTAChannel()
|
||||
end
|
||||
|
||||
function OTAManager:setOTAChannel(channel)
|
||||
DEBUG("Set OTA channel:", channel)
|
||||
logger.dbg("Set OTA channel:", channel)
|
||||
G_reader_settings:saveSetting("ota_channel", channel)
|
||||
end
|
||||
|
||||
@@ -84,12 +84,12 @@ function OTAManager:checkUpdate()
|
||||
local ota_zsync_file = self:getOTAServer() .. zsync_file
|
||||
local local_zsync_file = ota_dir .. zsync_file
|
||||
-- download zsync file from OTA server
|
||||
DEBUG("downloading zsync file", ota_zsync_file)
|
||||
logger.dbg("downloading zsync file", ota_zsync_file)
|
||||
local _, c, _ = http.request{
|
||||
url = ota_zsync_file,
|
||||
sink = ltn12.sink.file(io.open(local_zsync_file, "w"))}
|
||||
if c ~= 200 then
|
||||
DEBUG("cannot find zsync file", c)
|
||||
logger.warn("cannot find zsync file", c)
|
||||
return
|
||||
end
|
||||
-- parse OTA package version
|
||||
|
||||
@@ -6,7 +6,7 @@ local Font = require("ui/font")
|
||||
local Cache = require("cache")
|
||||
local CacheItem = require("cacheitem")
|
||||
local BlitBuffer = require("ffi/blitbuffer")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
if require("device"):isAndroid() then
|
||||
require("jit").off(true, true)
|
||||
@@ -87,14 +87,13 @@ function RenderText:getGlyph(face, charcode, bold)
|
||||
-- for some characters it cannot find in Fallbacks, it will crash here
|
||||
if fb_face.ftface:checkGlyph(charcode) ~= 0 then
|
||||
rendered_glyph = fb_face.ftface:renderGlyph(charcode, bold)
|
||||
--DEBUG("fallback to font", font)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not rendered_glyph then
|
||||
DEBUG("error rendering glyph (charcode=", charcode, ") for face", face)
|
||||
logger.warn("error rendering glyph (charcode=", charcode, ") for face", face)
|
||||
return
|
||||
end
|
||||
glyph = CacheItem:new{rendered_glyph}
|
||||
@@ -149,7 +148,7 @@ end
|
||||
-- @treturn RenderTextSize
|
||||
function RenderText:sizeUtf8Text(x, width, face, text, kerning, bold)
|
||||
if not text then
|
||||
DEBUG("sizeUtf8Text called without text");
|
||||
logger.warn("sizeUtf8Text called without text");
|
||||
return
|
||||
end
|
||||
|
||||
@@ -196,7 +195,7 @@ end
|
||||
-- @return int width of rendered bitmap
|
||||
function RenderText:renderUtf8Text(dest_bb, x, baseline, face, text, kerning, bold, fgcolor, width)
|
||||
if not text then
|
||||
DEBUG("renderUtf8Text called without text");
|
||||
logger.warn("renderUtf8Text called without text");
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ local UIManager = require("ui/uimanager")
|
||||
local Device = require("device")
|
||||
local Screen = Device.screen
|
||||
local DocSettings = require("docsettings")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local Screensaver = {
|
||||
}
|
||||
@@ -88,7 +88,7 @@ function Screensaver:getCoverImage(file)
|
||||
end
|
||||
|
||||
function Screensaver:show(kind, default_msg)
|
||||
DEBUG("show screensaver")
|
||||
logger.dbg("show screensaver")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local screensaver_settings = G_reader_settings:readSetting(kind .. "_screensaver") or {}
|
||||
-- first check book cover image, on by default
|
||||
@@ -137,7 +137,7 @@ function Screensaver:show(kind, default_msg)
|
||||
end
|
||||
|
||||
function Screensaver:close()
|
||||
DEBUG("close screensaver")
|
||||
logger.dbg("close screensaver")
|
||||
if self.left_msg then
|
||||
UIManager:close(self.left_msg)
|
||||
self.left_msg = nil
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local JSON = require("json")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
--[[
|
||||
-- Translate text using Google Translate.
|
||||
@@ -52,7 +52,6 @@ function Translator:loadPage(target_lang, source_lang, text)
|
||||
request['url'] = url.build(parsed)
|
||||
request['method'] = 'GET'
|
||||
request['sink'] = ltn12.sink.table(sink)
|
||||
DEBUG("request", request)
|
||||
http.TIMEOUT, https.TIMEOUT = 10, 10
|
||||
local httpRequest = parsed.scheme == 'http' and http.request or https.request
|
||||
-- first argument returned by skip is code
|
||||
@@ -64,7 +63,7 @@ function Translator:loadPage(target_lang, source_lang, text)
|
||||
end
|
||||
|
||||
if status ~= "HTTP/1.1 200 OK" then
|
||||
DEBUG("HTTP status not okay:", status)
|
||||
logger.warn("translator HTTP status not okay:", status)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -72,13 +71,12 @@ function Translator:loadPage(target_lang, source_lang, text)
|
||||
if content ~= "" and string.sub(content, 1,1) == "{" then
|
||||
local ok, result = pcall(JSON.decode, content)
|
||||
if ok and result then
|
||||
--DEBUG("translate result", result)
|
||||
return result
|
||||
else
|
||||
DEBUG("error:", result)
|
||||
logger.warn("translator error:", result)
|
||||
end
|
||||
else
|
||||
DEBUG("not JSON:", content)
|
||||
logger.warn("not JSON in translator response:", content)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,7 +84,7 @@ function Translator:detect(text)
|
||||
local result = self:loadPage("en", nil, text)
|
||||
if result then
|
||||
local src_lang = result.src
|
||||
DEBUG("detected language:", src_lang)
|
||||
logger.dbg("detected language:", src_lang)
|
||||
return src_lang
|
||||
else
|
||||
return self.default_lang
|
||||
|
||||
@@ -5,6 +5,7 @@ local Event = require("ui/event")
|
||||
local Geom = require("ui/geometry")
|
||||
local util = require("ffi/util")
|
||||
local dbg = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local noop = function() end
|
||||
@@ -136,10 +137,10 @@ end
|
||||
-- for refreshtype & refreshregion see description of setDirty()
|
||||
function UIManager:show(widget, refreshtype, refreshregion, x, y)
|
||||
if not widget then
|
||||
dbg("widget not exist to be closed")
|
||||
logger.dbg("widget not exist to be shown")
|
||||
return
|
||||
end
|
||||
dbg("show widget", widget.id or widget.name or "unknown")
|
||||
logger.dbg("show widget", widget.id or widget.name or "unknown")
|
||||
|
||||
self._running = true
|
||||
local window = {x = x or 0, y = y or 0, widget = widget}
|
||||
@@ -168,10 +169,10 @@ end
|
||||
-- for refreshtype & refreshregion see description of setDirty()
|
||||
function UIManager:close(widget, refreshtype, refreshregion)
|
||||
if not widget then
|
||||
dbg("widget not exist to be closed")
|
||||
logger.dbg("widget not exist to be closed")
|
||||
return
|
||||
end
|
||||
dbg("close widget", widget.id or widget.name)
|
||||
logger.dbg("close widget", widget.id or widget.name)
|
||||
local dirty = false
|
||||
-- first send close event to widget
|
||||
widget:handleEvent(Event:new("CloseWidget"))
|
||||
@@ -337,7 +338,7 @@ end
|
||||
-- set full refresh rate for e-ink screen
|
||||
-- and make the refresh rate persistant in global reader settings
|
||||
function UIManager:setRefreshRate(rate)
|
||||
dbg("set screen full refresh rate", rate)
|
||||
logger.dbg("set screen full refresh rate", rate)
|
||||
self.FULL_REFRESH_COUNT = rate
|
||||
G_reader_settings:saveSetting("full_refresh_count", rate)
|
||||
end
|
||||
@@ -349,7 +350,7 @@ end
|
||||
|
||||
-- signal to quit
|
||||
function UIManager:quit()
|
||||
dbg("quiting uimanager")
|
||||
logger.info("quiting uimanager")
|
||||
self._task_queue_dirty = false
|
||||
self._running = false
|
||||
self._run_forever = nil
|
||||
@@ -371,7 +372,6 @@ end
|
||||
|
||||
-- transmit an event to an active widget
|
||||
function UIManager:sendEvent(event)
|
||||
--dbg:v("send event", event)
|
||||
if #self._window_stack == 0 then return end
|
||||
|
||||
local top_widget = self._window_stack[#self._window_stack]
|
||||
@@ -511,7 +511,7 @@ function UIManager:_refresh(mode, region)
|
||||
if not region and mode == "partial" and not self.refresh_counted then
|
||||
self.refresh_count = (self.refresh_count + 1) % self.FULL_REFRESH_COUNT
|
||||
if self.refresh_count == self.FULL_REFRESH_COUNT - 1 then
|
||||
dbg("promote refresh to full refresh")
|
||||
logger.dbg("promote refresh to full refresh")
|
||||
mode = "full"
|
||||
end
|
||||
self.refresh_counted = true
|
||||
@@ -568,7 +568,7 @@ function UIManager:_repaint()
|
||||
-- we should have at least one refresh if we did repaint. If we don't, we
|
||||
-- add one now and log a warning if we are debugging
|
||||
if dirty and #self._refresh_stack == 0 then
|
||||
dbg("WARNING: no refresh got enqueued. Will do a partial full screen refresh, which might be inefficient")
|
||||
logger.warn("no refresh got enqueued. Will do a partial full screen refresh, which might be inefficient")
|
||||
self:_refresh("partial")
|
||||
end
|
||||
|
||||
@@ -610,7 +610,7 @@ function UIManager:handleInput()
|
||||
|
||||
-- stop when we have no window to show
|
||||
if #self._window_stack == 0 and not self._run_forever then
|
||||
dbg("no dialog left to show")
|
||||
logger.info("no dialog left to show")
|
||||
self:quit()
|
||||
return nil
|
||||
end
|
||||
@@ -655,7 +655,7 @@ function UIManager:handleInput()
|
||||
end
|
||||
|
||||
if self.looper then
|
||||
dbg("handle input in turbo I/O looper")
|
||||
logger.info("handle input in turbo I/O looper")
|
||||
self.looper:add_callback(function()
|
||||
-- FIXME: force close looper when there is unhandled error,
|
||||
-- otherwise the looper will hang. Any better solution?
|
||||
|
||||
@@ -22,7 +22,7 @@ local Screen = require("device").screen
|
||||
local Event = require("ui/event")
|
||||
local Device = require("device")
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -207,7 +207,7 @@ function ConfigOption:init()
|
||||
local current_item = nil
|
||||
local function value_diff(val1, val2, name)
|
||||
if type(val1) ~= type(val2) then
|
||||
DEBUG("different data types in option")
|
||||
logger.dbg("different data types in option")
|
||||
end
|
||||
if type(val1) == "number" then
|
||||
return math.abs(val1 - val2)
|
||||
@@ -539,20 +539,17 @@ function ConfigDialog:onShowConfigPanel(index)
|
||||
end
|
||||
|
||||
function ConfigDialog:onConfigChoice(option_name, option_value)
|
||||
--DEBUG("config option value", option_name, option_value)
|
||||
self.configurable[option_name] = option_value
|
||||
self.ui:handleEvent(Event:new("StartActivityIndicator"))
|
||||
return true
|
||||
end
|
||||
|
||||
function ConfigDialog:onConfigEvent(option_event, option_arg)
|
||||
--DEBUG("config option event", option_event, option_arg)
|
||||
self.ui:handleEvent(Event:new(option_event, option_arg))
|
||||
return true
|
||||
end
|
||||
|
||||
function ConfigDialog:onConfigEvents(option_events, arg_index)
|
||||
--DEBUG("config option events", option_events, arg_index)
|
||||
for i=1, #option_events do
|
||||
option_events[i].args = option_events[i].args or {}
|
||||
self.ui:handleEvent(Event:new(option_events[i].event, option_events[i].args[arg_index]))
|
||||
|
||||
@@ -26,7 +26,7 @@ local UIManager = require("ui/uimanager")
|
||||
local Device = require("device")
|
||||
local Screen = Device.screen
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
|
||||
@@ -115,7 +115,7 @@ function ConfirmBox:onClose()
|
||||
end
|
||||
|
||||
function ConfirmBox:onSelect()
|
||||
DEBUG("selected:", self.selected.x)
|
||||
logger.dbg("selected:", self.selected.x)
|
||||
if self.selected.x == 1 then
|
||||
self:ok_callback()
|
||||
else
|
||||
|
||||
@@ -19,7 +19,7 @@ local Device = require("device")
|
||||
local Geom = require("ui/geometry")
|
||||
local Event = require("ui/event")
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
@@ -384,7 +384,7 @@ function DictQuickLookup:update()
|
||||
}
|
||||
UIManager:setDirty("all", function()
|
||||
local update_region = self.dict_frame.dimen:combine(orig_dimen)
|
||||
DEBUG("update dict region", update_region)
|
||||
logger.dbg("update dict region", update_region)
|
||||
return "partial", update_region
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ local CacheItem = require("cacheitem")
|
||||
local Mupdf = require("ffi/mupdf")
|
||||
local Geom = require("ui/geometry")
|
||||
local Cache = require("cache")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
local ImageCache = Cache:new{
|
||||
max_memsize = 2*1024*1024, -- 2M of image cache
|
||||
@@ -40,7 +40,7 @@ local ImageCacheItem = CacheItem:new{}
|
||||
|
||||
function ImageCacheItem:onFree()
|
||||
if self.bb.free then
|
||||
DEBUG("free image blitbuffer", self.bb)
|
||||
logger.dbg("free image blitbuffer", self.bb)
|
||||
self.bb:free()
|
||||
end
|
||||
end
|
||||
@@ -87,7 +87,7 @@ function ImageWidget:_loadfile()
|
||||
self._bb = Mupdf.renderImageFile(self.file, self.width, self.height)
|
||||
else
|
||||
-- cache this image
|
||||
DEBUG("cache", hash)
|
||||
logger.dbg("cache", hash)
|
||||
cache = ImageCacheItem:new{
|
||||
bb = Mupdf.renderImageFile(self.file, self.width, self.height),
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ function InputDialog:init()
|
||||
enter_callback = self.enter_callback or function()
|
||||
for _,btn_row in ipairs(self.buttons) do
|
||||
for _,btn in ipairs(btn_row) do
|
||||
require('dbg')('looging for btn', btn)
|
||||
if btn.is_enter_default then
|
||||
btn.callback()
|
||||
return
|
||||
|
||||
@@ -24,7 +24,7 @@ local UIManager = require("ui/uimanager")
|
||||
local RenderText = require("ui/rendertext")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local util = require("ffi/util")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -292,7 +292,7 @@ function MenuItem:onTapSelect(arg, ges)
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self[1].invert = false
|
||||
UIManager:setDirty(self.show_parent, refreshfunc)
|
||||
DEBUG("creating coroutine for menu select")
|
||||
logger.dbg("creating coroutine for menu select")
|
||||
local co = coroutine.create(function()
|
||||
self.menu:onMenuSelect(self.table, pos)
|
||||
end)
|
||||
|
||||
@@ -10,7 +10,7 @@ local ButtonTable = require("ui/widget/buttontable")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Screen = require("device").screen
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
|
||||
@@ -113,7 +113,7 @@ function MultiConfirmBox:onClose()
|
||||
end
|
||||
|
||||
function MultiConfirmBox:onSelect()
|
||||
DEBUG("selected:", self.selected.x)
|
||||
logger.dbg("selected:", self.selected.x)
|
||||
if self.selected.x == 1 then
|
||||
self:choice1_callback()
|
||||
elseif self.selected.x == 2 then
|
||||
|
||||
@@ -11,7 +11,7 @@ local Screen = require("device").screen
|
||||
local url = require('socket.url')
|
||||
local util = require("ffi/util")
|
||||
local Cache = require("cache")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local socket = require('socket')
|
||||
@@ -63,7 +63,7 @@ function OPDSBrowser:init()
|
||||
end
|
||||
|
||||
function OPDSBrowser:addServerFromInput(fields)
|
||||
DEBUG("input catalog", fields)
|
||||
logger.dbg("input catalog", fields)
|
||||
local servers = G_reader_settings:readSetting("opds_servers") or {}
|
||||
table.insert(servers, {
|
||||
title = fields[1],
|
||||
@@ -74,7 +74,7 @@ function OPDSBrowser:addServerFromInput(fields)
|
||||
end
|
||||
|
||||
function OPDSBrowser:editCalibreFromInput(fields)
|
||||
DEBUG("input calibre server", fields)
|
||||
logger.dbg("input calibre server", fields)
|
||||
local calibre = G_reader_settings:readSetting("calibre_opds") or {}
|
||||
if fields[1] then
|
||||
calibre.host = fields[1]
|
||||
@@ -243,7 +243,7 @@ function OPDSBrowser:fetchFeed(feed_url)
|
||||
request['method'] = 'GET'
|
||||
request['sink'] = ltn12.sink.table(sink)
|
||||
request['headers'] = self:getAuthorizationHeader(parsed.host)
|
||||
DEBUG("request", request)
|
||||
logger.dbg("request", request)
|
||||
http.TIMEOUT, https.TIMEOUT = 10, 10
|
||||
local httpRequest = parsed.scheme == 'http' and http.request or https.request
|
||||
local code, headers, status = socket.skip(1, httpRequest(request))
|
||||
@@ -253,7 +253,6 @@ function OPDSBrowser:fetchFeed(feed_url)
|
||||
error(code)
|
||||
end
|
||||
|
||||
--DEBUG("response", code, headers, status)
|
||||
if code == 401 and status and status:find("Unauthorized") then
|
||||
self._coroutine = coroutine.running() or self._coroutine
|
||||
self:fetchWithLogin(parsed.host, function()
|
||||
@@ -266,7 +265,6 @@ function OPDSBrowser:fetchFeed(feed_url)
|
||||
else
|
||||
local xml = table.concat(sink)
|
||||
if xml ~= "" then
|
||||
--DEBUG("xml", xml)
|
||||
return xml
|
||||
end
|
||||
end
|
||||
@@ -326,7 +324,7 @@ function OPDSBrowser:parseFeed(feed_url)
|
||||
if cache then
|
||||
feed = cache.feed
|
||||
else
|
||||
DEBUG("cache", hash)
|
||||
logger.dbg("cache", hash)
|
||||
feed = self:fetchFeed(feed_url)
|
||||
if feed then
|
||||
CatalogCache:insert(hash, CatalogCacheItem:new{ feed = feed })
|
||||
@@ -344,7 +342,7 @@ function OPDSBrowser:getCatalog(feed_url)
|
||||
NetworkMgr:promptWifiOn()
|
||||
return
|
||||
elseif not ok and catalog then
|
||||
DEBUG("cannot get catalog info from", feed_url, catalog)
|
||||
logger.warn("cannot get catalog info from", feed_url, catalog)
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = util.template(
|
||||
_("Cannot get catalog info from %1"),
|
||||
@@ -355,7 +353,7 @@ function OPDSBrowser:getCatalog(feed_url)
|
||||
end
|
||||
|
||||
if ok and catalog then
|
||||
DEBUG("catalog", catalog)
|
||||
logger.dbg("catalog", catalog)
|
||||
return catalog
|
||||
end
|
||||
end
|
||||
@@ -431,7 +429,7 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url)
|
||||
end
|
||||
end
|
||||
if title == "Unknown" then
|
||||
DEBUG("Cannot handle title", entry.title)
|
||||
logger.warn("Cannot handle title", entry.title)
|
||||
end
|
||||
local author = "Unknown Author"
|
||||
if type(entry.author) == "table" and entry.author.name then
|
||||
@@ -451,7 +449,6 @@ end
|
||||
function OPDSBrowser:updateCatalog(item_table_url)
|
||||
local menu_table = self:genItemTableFromURL(item_table_url)
|
||||
if #menu_table > 0 then
|
||||
--DEBUG("menu table", menu_table)
|
||||
self:swithItemTable(nil, menu_table)
|
||||
if self.page_num <= 1 then
|
||||
self:onNext()
|
||||
@@ -475,24 +472,23 @@ function OPDSBrowser:downloadFile(item, format, remote_url)
|
||||
local lastdir = G_reader_settings:readSetting("lastdir")
|
||||
local download_dir = G_reader_settings:readSetting("download_dir") or lastdir
|
||||
local local_path = download_dir .. "/" .. item.author .. ' - ' .. item.title .. "." .. string.lower(format)
|
||||
DEBUG("downloading file", local_path, "from", remote_url)
|
||||
logger.dbg("downloading file", local_path, "from", remote_url)
|
||||
|
||||
local parsed = url.parse(remote_url)
|
||||
http.TIMEOUT, https.TIMEOUT = 10, 10
|
||||
local httpRequest = parsed.scheme == 'http' and http.request or https.request
|
||||
local r, c, h = httpRequest{
|
||||
local _, c, _ = httpRequest{
|
||||
url = remote_url,
|
||||
headers = self:getAuthorizationHeader(parsed.host),
|
||||
sink = ltn12.sink.file(io.open(local_path, "w")),
|
||||
}
|
||||
|
||||
if c == 200 then
|
||||
DEBUG("file downloaded to", local_path)
|
||||
logger.dbg("file downloaded to", local_path)
|
||||
if self.file_downloaded_callback then
|
||||
self.file_downloaded_callback(local_path)
|
||||
end
|
||||
else
|
||||
DEBUG("response", {r, c, h})
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Could not save file to:\n") .. local_path,
|
||||
timeout = 3,
|
||||
@@ -539,7 +535,7 @@ function OPDSBrowser:showDownloads(item)
|
||||
require("ui/downloadmgr"):new{
|
||||
title = _("Choose download directory"),
|
||||
onConfirm = function(path)
|
||||
DEBUG("set download directory to", path)
|
||||
logger.dbg("set download directory to", path)
|
||||
G_reader_settings:saveSetting("download_dir", path)
|
||||
end,
|
||||
}:chooseDir()
|
||||
@@ -559,7 +555,7 @@ function OPDSBrowser:onMenuSelect(item)
|
||||
item.callback()
|
||||
-- acquisition
|
||||
elseif item.acquisitions and #item.acquisitions > 0 then
|
||||
DEBUG("downloads available", item)
|
||||
logger.dbg("downloads available", item)
|
||||
self:showDownloads(item)
|
||||
-- navigation
|
||||
else
|
||||
@@ -574,7 +570,7 @@ function OPDSBrowser:onMenuSelect(item)
|
||||
end
|
||||
|
||||
function OPDSBrowser:editServerFromInput(item, fields)
|
||||
DEBUG("input catalog", fields)
|
||||
logger.dbg("input catalog", fields)
|
||||
local servers = {}
|
||||
for _, server in ipairs(G_reader_settings:readSetting("opds_servers") or {}) do
|
||||
if server.title == item.text or server.url == item.url then
|
||||
@@ -588,7 +584,7 @@ function OPDSBrowser:editServerFromInput(item, fields)
|
||||
end
|
||||
|
||||
function OPDSBrowser:editOPDSServer(item)
|
||||
DEBUG("edit", item)
|
||||
logger.dbg("edit", item)
|
||||
self.edit_server_dialog = MultiInputDialog:new{
|
||||
title = _("Edit OPDS catalog"),
|
||||
fields = {
|
||||
@@ -628,7 +624,7 @@ function OPDSBrowser:editOPDSServer(item)
|
||||
end
|
||||
|
||||
function OPDSBrowser:deleteOPDSServer(item)
|
||||
DEBUG("delete", item)
|
||||
logger.dbg("delete", item)
|
||||
local servers = {}
|
||||
for _, server in ipairs(G_reader_settings:readSetting("opds_servers") or {}) do
|
||||
if server.title ~= item.text or server.url ~= item.url then
|
||||
@@ -673,7 +669,7 @@ function OPDSBrowser:onMenuHold(item)
|
||||
end
|
||||
|
||||
function OPDSBrowser:onReturn()
|
||||
DEBUG("return to last page catalog")
|
||||
logger.dbg("return to last page catalog")
|
||||
if #self.paths > 0 then
|
||||
table.remove(self.paths)
|
||||
local path = self.paths[#self.paths]
|
||||
@@ -689,7 +685,7 @@ function OPDSBrowser:onReturn()
|
||||
end
|
||||
|
||||
function OPDSBrowser:onNext()
|
||||
DEBUG("fetch next page catalog")
|
||||
logger.dbg("fetch next page catalog")
|
||||
local hrefs = self.item_table.hrefs
|
||||
local page_num = self.page_num
|
||||
while page_num == self.page_num and hrefs and hrefs.next do
|
||||
|
||||
@@ -14,7 +14,7 @@ local Font = require("ui/font")
|
||||
local Screen = Device.screen
|
||||
local Geom = require("ui/geometry")
|
||||
local util = require("util")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
|
||||
local PhysicalNumericKey = WidgetContainer:new{
|
||||
@@ -112,7 +112,7 @@ end
|
||||
function PhysicalKeyboard:onKeyPress(ev)
|
||||
local key = ev.key
|
||||
if key == "Back" then
|
||||
DEBUG("TODO: exit keyboard")
|
||||
logger.warn("TODO: exit keyboard")
|
||||
elseif key == "Del" then
|
||||
self.inputbox:delChar()
|
||||
else
|
||||
|
||||
@@ -19,7 +19,7 @@ local RenderText = require("ui/rendertext")
|
||||
local Screen = require("device").screen
|
||||
local Geom = require("ui/geometry")
|
||||
local util = require("util")
|
||||
local DEBUG= require("dbg")
|
||||
local logger = require("logger")
|
||||
local TimeVal = require("ui/timeval")
|
||||
|
||||
local TextBoxWidget = Widget:new{
|
||||
@@ -316,7 +316,7 @@ function TextBoxWidget:onHoldWord(callback, ges)
|
||||
local x, y = ges.pos.x - self.dimen.x, ges.pos.y - self.dimen.y
|
||||
local line_num = math.ceil(y / self.line_height_px) + self.virtual_line_num-1
|
||||
local line = self.vertical_string_list[line_num]
|
||||
DEBUG("holding on line", line)
|
||||
logger.dbg("holding on line", line)
|
||||
if line then
|
||||
local char_start = line.offset
|
||||
local char_end -- char_end is non-inclusive
|
||||
@@ -429,7 +429,7 @@ function TextBoxWidget:onHoldReleaseText(callback, ges)
|
||||
end
|
||||
|
||||
local selected_text = table.concat(self.charlist, "", sel_start_idx, sel_end_idx)
|
||||
DEBUG("onHoldReleaseText (duration:", hold_duration, ") :", sel_start_idx, ">", sel_end_idx, "=", selected_text)
|
||||
logger.dbg("onHoldReleaseText (duration:", hold_duration, ") :", sel_start_idx, ">", sel_end_idx, "=", selected_text)
|
||||
callback(selected_text, hold_duration)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ local Device = require("device")
|
||||
local Screen = Device.screen
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
|
||||
local VirtualKey = InputContainer:new{
|
||||
@@ -97,7 +97,7 @@ end
|
||||
|
||||
function VirtualKey:update_keyboard()
|
||||
UIManager:setDirty(self.keyboard, function()
|
||||
DEBUG("update key region", self[1].dimen)
|
||||
logger.dbg("update key region", self[1].dimen)
|
||||
return "ui", self[1].dimen
|
||||
end)
|
||||
end
|
||||
@@ -270,17 +270,17 @@ function VirtualKeyboard:setLayout(key)
|
||||
end
|
||||
|
||||
function VirtualKeyboard:addChar(key)
|
||||
DEBUG("add char", key)
|
||||
logger.dbg("add char", key)
|
||||
self.inputbox:addChar(key)
|
||||
end
|
||||
|
||||
function VirtualKeyboard:delChar()
|
||||
DEBUG("delete char")
|
||||
logger.dbg("delete char")
|
||||
self.inputbox:delChar()
|
||||
end
|
||||
|
||||
function VirtualKeyboard:clear()
|
||||
DEBUG("clear input")
|
||||
logger.dbg("clear input")
|
||||
self.inputbox:clear()
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local JSON = require("json")
|
||||
local DEBUG = require("dbg")
|
||||
local logger = require("logger")
|
||||
|
||||
--[[
|
||||
-- Query wikipedia using Wikimedia Web API.
|
||||
@@ -76,7 +76,6 @@ function Wikipedia:loadPage(text, lang, intro, plain)
|
||||
request['url'] = url.build(parsed)
|
||||
request['method'] = 'GET'
|
||||
request['sink'] = ltn12.sink.table(sink)
|
||||
DEBUG("request", request)
|
||||
http.TIMEOUT, https.TIMEOUT = 10, 10
|
||||
local httpRequest = parsed.scheme == 'http' and http.request or https.request
|
||||
-- first argument returned by skip is code
|
||||
@@ -88,7 +87,7 @@ function Wikipedia:loadPage(text, lang, intro, plain)
|
||||
end
|
||||
|
||||
if status ~= "HTTP/1.1 200 OK" then
|
||||
DEBUG("HTTP status not okay:", status)
|
||||
logger.warn("HTTP status not okay:", status)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -96,13 +95,13 @@ function Wikipedia:loadPage(text, lang, intro, plain)
|
||||
if content ~= "" and string.sub(content, 1,1) == "{" then
|
||||
local ok, result = pcall(JSON.decode, content)
|
||||
if ok and result then
|
||||
DEBUG("wiki result", result)
|
||||
logger.dbg("wiki result", result)
|
||||
return result
|
||||
else
|
||||
DEBUG("error:", result)
|
||||
logger.warn("wiki error:", result)
|
||||
end
|
||||
else
|
||||
DEBUG("not JSON:", content)
|
||||
logger.warn("not JSON from wiki response:", content)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/bin/sh
|
||||
export PATH="${PATH}:/sbin:/usr/sbin"
|
||||
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Going to sleep . . ."
|
||||
# NOTE: Sleep as little as possible here, sleeping has a tendency to make everything mysteriously hang...
|
||||
|
||||
# Depending on device/FW version, some kernels do not support wakeup_count, account for that
|
||||
if [ -e "/sys/power/wakeup_count" ] ; then
|
||||
#HAS_WAKEUP_COUNT="true"
|
||||
# NOTE: ... and of course, it appears to be broken, which probably explains why nickel doesn't use this facility...
|
||||
# (By broken, I mean that the system wakes up right away).
|
||||
# So, unless that changes, unconditionally disable it.
|
||||
HAS_WAKEUP_COUNT="false"
|
||||
fi
|
||||
|
||||
# Clear the kernel ring buffer... (we're missing a proper -C flag...)
|
||||
#dmesg -c >/dev/null
|
||||
|
||||
# Go to sleep
|
||||
if [ "${HAS_WAKEUP_COUNT}" == "true" ] ; then
|
||||
current_wakeup_count="$(cat /sys/power/wakeup_count)"
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Current WakeUp count: ${current_wakeup_count}"
|
||||
fi
|
||||
echo 1 > /sys/power/state-extended
|
||||
# NOTE: Sets gSleep_Mode_Suspend to 1. Used as a flag throughout the kernel to suspend/resume various subsystems
|
||||
# cf. kernel/power/main.c @ L#207
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Asked the kernel to put subsystems to sleep"
|
||||
sleep 2
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Waited for 2s because of reasons..."
|
||||
sync
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Synced FS"
|
||||
if [ "${HAS_WAKEUP_COUNT}" == "true" ] ; then
|
||||
echo ${current_wakeup_count} > /sys/power/wakeup_count
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Wrote WakeUp count: ${current_wakeup_count} ($?)"
|
||||
fi
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Asking for a suspend to RAM . . ."
|
||||
echo mem > /sys/power/state
|
||||
# NOTE: At this point, we *should* be in suspend to RAM, as such, execution should only resume on wakeup...
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: ZzZ ZzZ ZzZ? ($?)"
|
||||
## NOTE: Ideally, we'd need a way to warn the user that suspending gloriously failed at this point...
|
||||
## We can safely assume that just from a non-zero return code, without looking at the detailed stderr message
|
||||
## (most of the failures we'll see are -EBUSY anyway)
|
||||
## For reference, when that happens to nickel, it appears to keep retrying to wakeup & sleep ad nauseam,
|
||||
## which is where the non-sensical 1 -> mem -> 0 loop idea comes from...
|
||||
## cf. nickel_suspend_strace.txt for more details.
|
||||
|
||||
if [ "${HAS_WAKEUP_COUNT}" == "true" ] ; then
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Woke up! (WakeUp count: $(cat /sys/power/wakeup_count))"
|
||||
else
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Woke up!"
|
||||
fi
|
||||
|
||||
# Print tke kernel log since our attempt to sleep...
|
||||
#dmesg -c
|
||||
|
||||
# Now that we're up, unflag subsystems for suspend...
|
||||
# NOTE: We do that in Kobo:resume() to keep things tidy and easier to follow
|
||||
#echo 0 > /sys/power/state-extended
|
||||
#echo "[$(date +'%x @ %X')] Kobo Suspend: Unflagged kernel subsystems for suspend"
|
||||
@@ -1,5 +1,5 @@
|
||||
#!./luajit
|
||||
io.stdout:write(string.format([[
|
||||
io.stdout:write([[
|
||||
---------------------------------------------
|
||||
launching...
|
||||
_ _____ ____ _
|
||||
@@ -8,8 +8,7 @@ io.stdout:write(string.format([[
|
||||
| . \ |_| | _ < __/ (_| | (_| | __/ |
|
||||
|_|\_\___/|_| \_\___|\__,_|\__,_|\___|_|
|
||||
|
||||
[*] Current time: %s
|
||||
]], os.date("%x-%X")))
|
||||
[*] Current time: ]], os.date("%x-%X"), "\n\n")
|
||||
io.stdout:flush()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user