|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
|
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
local Device = require("ui/device")
|
|
|
|
|
local DEBUG = require("dbg")
|
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
|
|
local OTAManager = {
|
|
|
|
|
ota_server = "http://vislab.bjmu.edu.cn/apps/koreader/ota/",
|
|
|
|
@ -78,11 +82,46 @@ end
|
|
|
|
|
function OTAManager:zsync()
|
|
|
|
|
if self:_buildLocalPackage() == 0 then
|
|
|
|
|
return os.execute(string.format(
|
|
|
|
|
"./zsync -i %s -o %s -u %s %s &",
|
|
|
|
|
"./zsync -i %s -o %s -u %s %s",
|
|
|
|
|
self.installed_package, self.updated_package,
|
|
|
|
|
self.ota_server, "ota/" .. self:getZsyncFilename()
|
|
|
|
|
))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function OTAManager:genMenuEntry()
|
|
|
|
|
return {
|
|
|
|
|
text = _("Check update"),
|
|
|
|
|
callback = function()
|
|
|
|
|
local ota_version = OTAManager:checkUpdate()
|
|
|
|
|
if ota_version == 0 then
|
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
|
text = _("Your koreader is updated."),
|
|
|
|
|
})
|
|
|
|
|
elseif ota_version == nil then
|
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
|
text = _("OTA server is not available."),
|
|
|
|
|
})
|
|
|
|
|
elseif ota_version then
|
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
|
text = _("Do you want to update to version ")..ota_version.."?",
|
|
|
|
|
ok_callback = function()
|
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
|
text = _("Downloading may take several minutes..."),
|
|
|
|
|
timeout = 3,
|
|
|
|
|
})
|
|
|
|
|
UIManager:scheduleIn(1, function()
|
|
|
|
|
if OTAManager:zsync() == 0 then
|
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
|
text = _("Koreader will be updated on next restart."),
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return OTAManager
|
|
|
|
|