libs/core: fixes luci.model.wireless
This commit is contained in:
parent
e93a3e0c74
commit
1a9b5381c0
1 changed files with 17 additions and 16 deletions
|
@ -23,12 +23,12 @@ local iwi = require "iwinfo"
|
||||||
local utl = require "luci.util"
|
local utl = require "luci.util"
|
||||||
local uct = require "luci.model.uci.bind"
|
local uct = require "luci.model.uci.bind"
|
||||||
|
|
||||||
module "luci.model.network.wireless"
|
module "luci.model.wireless"
|
||||||
|
|
||||||
local ub = uct.bind("wireless")
|
local ub = uct.bind("wireless")
|
||||||
local st, ifs
|
local st, ifs
|
||||||
|
|
||||||
function init(self, cursor)
|
function init(cursor)
|
||||||
cursor:unload("wireless")
|
cursor:unload("wireless")
|
||||||
cursor:load("wireless")
|
cursor:load("wireless")
|
||||||
ub:init(cursor)
|
ub:init(cursor)
|
||||||
|
@ -42,7 +42,7 @@ function init(self, cursor)
|
||||||
function(s)
|
function(s)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
local id = "%s.network%d" %{ self.device, count }
|
local id = "%s.network%d" %{ s.device, count }
|
||||||
|
|
||||||
ifs[id] = {
|
ifs[id] = {
|
||||||
id = id,
|
id = id,
|
||||||
|
@ -80,10 +80,10 @@ function get_network(self, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function shortname(self, iface)
|
function shortname(self, iface)
|
||||||
if iface.dev and iface.dev.wifi then
|
if iface.wdev and iface.winfo then
|
||||||
return "%s %q" %{
|
return "%s %q" %{
|
||||||
i18n.translate("a_s_if_iwmode_" .. (iface.dev.wifi.mode or "ap")),
|
i18n.translate("a_s_if_iwmode_" .. iface:active_mode(), iface.winfo.mode(iface.wdev)),
|
||||||
iface.dev.wifi.ssid or iface.dev.wifi.bssid or "(hidden)"
|
iface:active_ssid() or "(hidden)"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return iface:name()
|
return iface:name()
|
||||||
|
@ -91,11 +91,11 @@ function shortname(self, iface)
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_i18n(self, iface)
|
function get_i18n(self, iface)
|
||||||
if iface.dev and iface.dev.wifi then
|
if iface.wdev and iface.winfo then
|
||||||
return "%s: %s %q" %{
|
return "%s: %s %q (%s)" %{
|
||||||
i18n.translate("a_s_if_wifinet", "Wireless Network"),
|
i18n.translate("a_s_if_wifinet", "Wireless Network"),
|
||||||
i18n.translate("a_s_if_iwmode_" .. (iface.dev.wifi.mode or "ap"), iface.dev.wifi.mode or "AP"),
|
i18n.translate("a_s_if_iwmode_" .. iface:active_mode(), iface.winfo.mode(iface.wdev)),
|
||||||
iface.dev.wifi.ssid or iface.dev.wifi.bssid or "(hidden)"
|
iface:active_ssid() or "(hidden)", iface.wdev
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return "%s: %q" %{ i18n.translate("a_s_if_wifinet", "Wireless Network"), iface:name() }
|
return "%s: %q" %{ i18n.translate("a_s_if_wifinet", "Wireless Network"), iface:name() }
|
||||||
|
@ -199,18 +199,19 @@ function network._init(self, sid)
|
||||||
return s['.name'] ~= sid
|
return s['.name'] ~= sid
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self.id = "%s.network%d" %{ self.device, count }
|
|
||||||
|
|
||||||
local dev = st:get("wireless", sid, "ifname")
|
local dev = st:get("wireless", sid, "ifname")
|
||||||
or st:get("wireless", sid, "device")
|
or st:get("wireless", sid, "device")
|
||||||
|
|
||||||
local wtype = dev and iwi.type(dev)
|
if dev then
|
||||||
|
self.id = "%s.network%d" %{ dev, count }
|
||||||
|
|
||||||
|
local wtype = iwi.type(dev)
|
||||||
if dev and wtype then
|
if dev and wtype then
|
||||||
self.winfo = iwi[wtype]
|
self.winfo = iwi[wtype]
|
||||||
self.wdev = dev
|
self.wdev = dev
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function network.name(self)
|
function network.name(self)
|
||||||
return self.id
|
return self.id
|
||||||
|
|
Loading…
Reference in a new issue