mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
@@ -196,4 +196,19 @@ function Device:exit()
|
||||
self.screen:close()
|
||||
end
|
||||
|
||||
function Device:retrieveNetworkInfo()
|
||||
local std_out = io.popen("ifconfig | " ..
|
||||
"sed -n " ..
|
||||
"-e 's/ \\+$//g' " ..
|
||||
"-e 's/ \\+/ /g' " ..
|
||||
"-e 's/inet6\\? addr: \\?\\([^ ]\\+\\) .*$/\\1/p' " ..
|
||||
"-e 's/Link encap:\\(.*\\)/\\1/p'",
|
||||
"r")
|
||||
if std_out then
|
||||
local result = std_out:read("*all")
|
||||
std_out:close()
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
return Device
|
||||
|
||||
@@ -32,6 +32,7 @@ table.insert(common_settings, {
|
||||
sub_item_table = {
|
||||
NetworkMgr:getWifiMenuTable(),
|
||||
NetworkMgr:getProxyMenuTable(),
|
||||
NetworkMgr:getInfoMenuTable(),
|
||||
}
|
||||
})
|
||||
table.insert(common_settings, {
|
||||
|
||||
@@ -117,6 +117,24 @@ function NetworkMgr:getProxyMenuTable()
|
||||
}
|
||||
end
|
||||
|
||||
function NetworkMgr:getInfoMenuTable()
|
||||
return {
|
||||
text = _("Network info"),
|
||||
callback = function(menu)
|
||||
if Device.retrieveNetworkInfo then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = Device:retrieveNetworkInfo(),
|
||||
})
|
||||
else
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Cannot retrieve network info"),
|
||||
timeout = 3,
|
||||
})
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
function NetworkMgr:showNetworkMenu(complete_callback)
|
||||
local info = InfoMessage:new{text = _("Scanning…")}
|
||||
UIManager:show(info)
|
||||
|
||||
Reference in New Issue
Block a user