build: split into luci and luci-addons packages
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / wireless / apdevice.lua
index 930371e..66b21ab 100644 (file)
@@ -11,41 +11,36 @@ You may obtain a copy of the License at
 
 $Id$
 ]]--
-
-local iwinfo = require "iwinfo"
+local niulib = require "luci.niulib"
 local cursor = require "luci.model.uci".inst
-cursor:unload("wireless")
-
-m = Map("wireless", "Configure Private Access Point")
-s = m:section(NamedSection, "ap", "interface", "Wireless Radio Device",
-"Select the wireless radio device that should be used to run the access"..
-" point. Note that wireless radios will not show up here if you already use"..
-" them for connecting to the Internet and are not capable of being used as"..
-" an access point in parallel.")
+
+m = Map("wireless", translate("Configure Private Access Point"))
+s = m:section(NamedSection, "ap", "wifi-iface", translate("Wireless Radio Device"),
+translate(
+"Select the wireless radio device that should be used to run the interface."..
+" Note that wireless radios will not show up here if you already use"..
+" them for other wireless services and are not capable of being used by"..
+" more than one service simultaneously or run this specific service at all."))
 s.anonymous = true
 s.addremove = false
 
-l = s:option(ListValue, "device", "Device providing Access Point")
-
-local used = {}
-cursor:foreach("wireless", "wifi-iface", function(s)
-       if s[".name"] ~= "ap" and s._niu == 1 then
-               used[s.device] = 1
-       end
-end)
+local l = s:option(ListValue, "device", translate("Wireless Device"))
 
-for k in pairs(used) do
-       local t = iwinfo.type(k)
-       if t and iwinfo[t] then
-               used[k] = (iwinfo[t].mbssid_support() < 1)
-       end
+for _, wifi in ipairs(niulib.wifi_get_available("ap")) do
+       l:value(wifi, translate("WLAN-Adapter (%s)") % wifi)
+end
+l:value("none", translate("Disable Private Access Point"))
+
+
+local extend = cursor:get("wireless", "bridge", "network")
+       and cursor:get("wireless", "bridge", "ssid")
+       
+if extend ~= cursor:get("wireless", "ap", "ssid") then
+       local templ = s:option(ListValue, "_cfgtpl", translate("Configuration Template"))
+       templ:depends({["!default"] = 1})
+       templ:depends({["!reverse"] = 1, device = "none"})
+       templ:value("", translate("Access Point (Current Settings)"))
+       templ:value("bridge", translate("Extend network %s") % extend)
 end
-
-cursor:foreach("wireless", "wifi-device", function(s)
-       if not used[s[".name"]] then
-               l:value(s[".name"], "Radio %s" % s[".name"])
-       end
-end)
-l:value("none", "Disable Private Access Point")
 
 return m