Browse Source

Added blacklist feature

pull/1/head
klonfish 9 years ago
parent
commit
a6a82cfd87
  1. 8
      configreader.py
  2. 4
      fetap.ini.example
  3. 12
      fetapdtest.py
  4. 3
      phoneinterface.py

8
configreader.py

@ -58,6 +58,13 @@ class ConfigurationReader(object): @@ -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): @@ -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 = []

4
fetap.ini.example

@ -18,7 +18,11 @@ incoming_timeout = 60 @@ -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

12
fetapdtest.py

@ -7,9 +7,10 @@ import configreader @@ -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,7 +118,14 @@ class RegisteringState(BaseState): @@ -117,7 +118,14 @@ class RegisteringState(BaseState):
class IdleState(BaseState):
def on_incoming_call(self):
print('incomfing call')
return SchelltState
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):
print('gabel up')

3
phoneinterface.py

@ -199,6 +199,9 @@ class PhoneInterface(object): @@ -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…
Cancel
Save