You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
#!/usr/bin/env lua5.1
|
|
require 'ngcp.xavp'
|
|
|
|
-- class NGCPPeerPrefs
|
|
NGCPPeerPrefs = {
|
|
__class__ = 'NGCPPeerPrefs'
|
|
}
|
|
NGCPPeerPrefs_MT = { __index = NGCPPeerPrefs }
|
|
|
|
function NGCPPeerPrefs:new(config)
|
|
local t = {
|
|
config = config,
|
|
db_table = "peer_preferences"
|
|
}
|
|
setmetatable( t, NGCPPeerPrefs_MT )
|
|
return t
|
|
end
|
|
|
|
function NGCPPeerPrefs:caller_load(uuid)
|
|
self:_load(0,uuid)
|
|
end
|
|
|
|
function NGCPPeerPrefs:callee_load(uuid)
|
|
self:_load(1,uuid)
|
|
end
|
|
|
|
function NGCPPeerPrefs:_load(level, uuid)
|
|
local con = self.config:getDBConnection()
|
|
local query = "SELECT * FROM " .. self.db_table .. " WHERE uuid = '" .. uuid .. "'"
|
|
local cur = assert (con:execute(query))
|
|
local row = cur:fetch({}, "a")
|
|
if row then
|
|
self.xavp = NGCPXAvp:new(level,'peer',row)
|
|
end
|
|
cur:close()
|
|
con:close()
|
|
end
|
|
|
|
function NGCPPeerPrefs:clean(...)
|
|
if self.xavp then
|
|
self.xavp:clean()
|
|
end
|
|
end
|
|
-- class
|
|
--EOF |