Added blacklist feature
This commit is contained in:
parent
7730762f87
commit
a6a82cfd87
4 changed files with 25 additions and 2 deletions
|
@ -58,6 +58,13 @@ class ConfigurationReader(object):
|
|||
print 'shortcuts:', shortcuts
|
||||
return shortcuts
|
||||
|
||||
def __read_blacklist(self):
|
||||
fname = self.__get_global_val('blacklist_file')
|
||||
blacklist = []
|
||||
with open(fname, 'r') as csvfile:
|
||||
for row in csv.DictReader(csvfile):
|
||||
blacklist.append(row['number'])
|
||||
return blacklist
|
||||
|
||||
def read(self, f):
|
||||
self.__cp.read(f)
|
||||
|
@ -78,6 +85,7 @@ class ConfigurationReader(object):
|
|||
self.__dialconfig = fetapdtest.DialConfiguration(
|
||||
self.__get_global_val_int('dial_timeout'),
|
||||
self.__read_shortcuts(),
|
||||
self.__read_blacklist(),
|
||||
)
|
||||
|
||||
proxyconfigs = []
|
||||
|
|
|
@ -18,7 +18,11 @@ incoming_timeout = 60
|
|||
; gewaehlte nummer angerufen wird
|
||||
dial_timeout = 3
|
||||
|
||||
; CSV-Datei mit Kurzwahlen in der Form
|
||||
; Header: shortcut,number
|
||||
shortcuts_file = shortcuts.csv
|
||||
; CSV-Datei mit Rufnummern die automatisch abgelehnt werden sollen
|
||||
; Header: number
|
||||
linphone_config = linphone.conf
|
||||
|
||||
; Einer der Namen der unten eingetragenen Proxys
|
||||
|
|
|
@ -7,9 +7,10 @@ import configreader
|
|||
|
||||
|
||||
class DialConfiguration(object):
|
||||
def __init__(self, dial_timeout, shortcuts):
|
||||
def __init__(self, dial_timeout, shortcuts, blacklist):
|
||||
self.dial_timeout = dial_timeout
|
||||
self.shortcuts = shortcuts
|
||||
self.blacklist = blacklist
|
||||
|
||||
class IllegalEventError(Exception):
|
||||
pass
|
||||
|
@ -117,6 +118,13 @@ class RegisteringState(BaseState):
|
|||
class IdleState(BaseState):
|
||||
def on_incoming_call(self):
|
||||
print('incomfing call')
|
||||
caller = self._controller.phone.get_remote_number()
|
||||
print('From: %s' % caller)
|
||||
if caller in self._controller.dialconfig.blacklist:
|
||||
print('Caller on blacklist - declining')
|
||||
self._controller.phone.decline_call()
|
||||
return CallTerminatingState
|
||||
else:
|
||||
return SchelltState
|
||||
|
||||
def on_gabelschalter_up(self):
|
||||
|
|
|
@ -199,6 +199,9 @@ class PhoneInterface(object):
|
|||
self.__ttsproc.stdin.write(text + '\n')
|
||||
self.__ttsproc.stdin.flush()
|
||||
|
||||
def get_remote_number(self):
|
||||
return self.__core.current_call_remote_address.username
|
||||
|
||||
if __name__ == '__main__':
|
||||
def event_cb(evt):
|
||||
print 'Got event:', PhoneEvent.string(evt)
|
||||
|
|
Loading…
Reference in a new issue