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. 10
      fetapdtest.py
  4. 3
      phoneinterface.py

8
configreader.py

@ -58,6 +58,13 @@ class ConfigurationReader(object):
print 'shortcuts:', shortcuts print 'shortcuts:', shortcuts
return 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): def read(self, f):
self.__cp.read(f) self.__cp.read(f)
@ -78,6 +85,7 @@ class ConfigurationReader(object):
self.__dialconfig = fetapdtest.DialConfiguration( self.__dialconfig = fetapdtest.DialConfiguration(
self.__get_global_val_int('dial_timeout'), self.__get_global_val_int('dial_timeout'),
self.__read_shortcuts(), self.__read_shortcuts(),
self.__read_blacklist(),
) )
proxyconfigs = [] proxyconfigs = []

4
fetap.ini.example

@ -18,7 +18,11 @@ incoming_timeout = 60
; gewaehlte nummer angerufen wird ; gewaehlte nummer angerufen wird
dial_timeout = 3 dial_timeout = 3
; CSV-Datei mit Kurzwahlen in der Form
; Header: shortcut,number
shortcuts_file = shortcuts.csv shortcuts_file = shortcuts.csv
; CSV-Datei mit Rufnummern die automatisch abgelehnt werden sollen
; Header: number
linphone_config = linphone.conf linphone_config = linphone.conf
; Einer der Namen der unten eingetragenen Proxys ; Einer der Namen der unten eingetragenen Proxys

10
fetapdtest.py

@ -7,9 +7,10 @@ import configreader
class DialConfiguration(object): class DialConfiguration(object):
def __init__(self, dial_timeout, shortcuts): def __init__(self, dial_timeout, shortcuts, blacklist):
self.dial_timeout = dial_timeout self.dial_timeout = dial_timeout
self.shortcuts = shortcuts self.shortcuts = shortcuts
self.blacklist = blacklist
class IllegalEventError(Exception): class IllegalEventError(Exception):
pass pass
@ -117,6 +118,13 @@ class RegisteringState(BaseState):
class IdleState(BaseState): class IdleState(BaseState):
def on_incoming_call(self): def on_incoming_call(self):
print('incomfing call') 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 return SchelltState
def on_gabelschalter_up(self): def on_gabelschalter_up(self):

3
phoneinterface.py

@ -199,6 +199,9 @@ class PhoneInterface(object):
self.__ttsproc.stdin.write(text + '\n') self.__ttsproc.stdin.write(text + '\n')
self.__ttsproc.stdin.flush() self.__ttsproc.stdin.flush()
def get_remote_number(self):
return self.__core.current_call_remote_address.username
if __name__ == '__main__': if __name__ == '__main__':
def event_cb(evt): def event_cb(evt):
print 'Got event:', PhoneEvent.string(evt) print 'Got event:', PhoneEvent.string(evt)

Loading…
Cancel
Save