applications/luci-asterisk:
[project/luci.git] / applications / luci-asterisk / luasrc / model / cbi / asterisk / phones.lua
index 7831824..7c8f03f 100644 (file)
@@ -34,21 +34,23 @@ sip_table.template  = "cbi/tblsection"
 sip_table.extedit   = luci.dispatcher.build_url("admin", "asterisk", "phones", "sip", "%s")
 sip_table.addremove = true
 
 sip_table.extedit   = luci.dispatcher.build_url("admin", "asterisk", "phones", "sip", "%s")
 sip_table.addremove = true
 
-sip_table.hidden = {
-       type        = "friend",
-       qualify     = "yes",
-       host        = "dynamic",
-       nat         = "no",
-       canreinvite = "no"
-}
-
 function sip_table.filter(self, s)
 function sip_table.filter(self, s)
-       return s and cbimap.uci:get("asterisk", s, "type") ~= "peer"
+       return s and not cbimap.uci:get_bool("asterisk", s, "provider")
 end
 
 function sip_table.create(self, section)
        if TypedSection.create(self, section) then
                created = section
 end
 
 function sip_table.create(self, section)
        if TypedSection.create(self, section) then
                created = section
+               cbimap.uci:tset("asterisk", section, {
+                       type        = "friend",
+                       qualify     = "yes",
+                       provider    = "no",
+                       host        = "dynamic",
+                       nat         = "no",
+                       canreinvite = "no",
+                       extension   = section:match("^%d+$") and section or "",
+                       username    = section:match("^%d+$") and section or ""
+               })
        else
                self.invalid_cts = true
        end
        else
                self.invalid_cts = true
        end
@@ -65,13 +67,13 @@ function sip_table.parse(self, ...)
 end
 
 
 end
 
 
-user = sip_table:option(DummyValue, "username")
+user = sip_table:option(DummyValue, "username", "Username")
 function user.cfgvalue(self, s)
        return sip_peers[s] and sip_peers[s].callerid or
                AbstractValue.cfgvalue(self, s)
 end
 
 function user.cfgvalue(self, s)
        return sip_peers[s] and sip_peers[s].callerid or
                AbstractValue.cfgvalue(self, s)
 end
 
-host = sip_table:option(DummyValue, "host")
+host = sip_table:option(DummyValue, "host", "Hostname")
 function host.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.address then
                return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
 function host.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.address then
                return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
@@ -80,15 +82,10 @@ function host.cfgvalue(self, s)
        end
 end
 
        end
 end
 
-context = sip_table:option(DummyValue, "context")
+context = sip_table:option(DummyValue, "context", "Dialplan")
 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
 
 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
 
-nat = sip_table:option(DummyValue, "nat")
-function nat.cfgvalue(self, s)
-       return sip_peers[s] and sip_peers[s].info.Nat or "none"
-end
-
-online = sip_table:option(DummyValue, "online")
+online = sip_table:option(DummyValue, "online", "Registered")
 function online.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.online == nil then
                return "n/a"
 function online.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.online == nil then
                return "n/a"
@@ -100,7 +97,7 @@ function online.cfgvalue(self, s)
        end
 end
 
        end
 end
 
-delay = sip_table:option(DummyValue, "delay")
+delay = sip_table:option(DummyValue, "delay", "Delay")
 function delay.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.online then
                return "%i ms" % sip_peers[s].info.delay
 function delay.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.online then
                return "%i ms" % sip_peers[s].info.delay