2
0
mirror of https://github.com/koreader/koreader synced 2024-11-16 06:12:56 +00:00
koreader/frontend/ui/networkmgr.lua

56 lines
1.3 KiB
Lua
Raw Normal View History

local ConfirmBox = require("ui/widget/confirmbox")
local UIManager = require("ui/uimanager")
local Device = require("ui/device")
local DEBUG = require("dbg")
local _ = require("gettext")
local NetworkMgr = {}
local function kindleEnableWifi(toggle)
local lipc = require("liblipclua")
local lipc_handle = nil
if lipc then
lipc_handle = lipc.init("com.github.koreader.networkmgr")
end
if lipc_handle then
lipc_handle:set_int_property("com.lab126.cmd", "wirelessEnable", toggle)
lipc_handle:close()
end
end
function NetworkMgr:turnOnWifi()
if Device:isKindle() then
kindleEnableWifi(1)
elseif Device:isKobo() then
2014-07-19 14:32:41 +00:00
os.execute("./wifi.sh on")
end
end
function NetworkMgr:turnOffWifi()
if Device:isKindle() then
kindleEnableWifi(0)
elseif Device:isKobo() then
2014-07-19 14:32:41 +00:00
os.execute("./wifi.sh off")
end
end
function NetworkMgr:promptWifiOn()
UIManager:show(ConfirmBox:new{
text = _("Do you want to Turn on Wifi?"),
ok_callback = function()
self:turnOnWifi()
end,
})
end
function NetworkMgr:promptWifiOff()
UIManager:show(ConfirmBox:new{
text = _("Do you want to Turn off Wifi?"),
ok_callback = function()
self:turnOffWifi()
end,
})
end
return NetworkMgr