Add a network info page (#2187)

Add network info page
pull/2193/head
Hzj_jie 8 years ago committed by Qingping Hou
parent 04d07699cf
commit ccbf8eac0c

@ -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)

Loading…
Cancel
Save