Extend history functions for phoneinterface

This commit is contained in:
sqozz 2022-07-13 09:21:07 +02:00
parent 858ba7bc2c
commit 2f461c7b35

View file

@ -94,18 +94,21 @@ class PhoneInterface(object):
def on_LinphoneCallIncomingReceived(self, event): def on_LinphoneCallIncomingReceived(self, event):
self.run_callbacks(PhoneEvent.CallIncoming) self.run_callbacks(PhoneEvent.CallIncoming)
self.current_call_id = event.call_id self.current_call_id = event.call_id
self.__history.log_call(self.get_remote_number(), True) self.current_history_id = self.__history.log_call(self.get_remote_number(), True)
def on_LinphoneCallOutgoingRinging(self, event): def on_LinphoneCallOutgoingRinging(self, event):
self.run_callbacks(PhoneEvent.CallRinging) self.run_callbacks(PhoneEvent.CallRinging)
self.__history.log_call(self.get_remote_number(), False) self.current_history_id = self.__history.log_call(self.get_remote_number(), False)
def on_LinphoneCallConnected(self, event): def on_LinphoneCallConnected(self, event):
self.call_connected_time = time.time()
self.run_callbacks(PhoneEvent.CallAccepted) self.run_callbacks(PhoneEvent.CallAccepted)
def on_LinphoneCallEnd(self, event): def on_LinphoneCallEnd(self, event):
self.__history.set_call_duration(self.current_history_id, int(time.time() - self.call_connected_time))
self.run_callbacks(PhoneEvent.CallEnded) self.run_callbacks(PhoneEvent.CallEnded)
self.current_call_id = None self.current_call_id = None
self.current_history_id = None
def __pollthread(self): def __pollthread(self):
while self.__running: while self.__running:
@ -146,9 +149,11 @@ class PhoneInterface(object):
self.__core.call(number) self.__core.call(number)
def accept_call(self): def accept_call(self):
self.__history.accept_call(self.current_history_id)
self.__core.answer(self.current_call_id) self.__core.answer(self.current_call_id)
def decline_call(self): def decline_call(self):
self.__history.decline_call(self.current_history_id)
self.__core.decline_call(self.__core.current_call) self.__core.decline_call(self.__core.current_call)
def end_call(self): def end_call(self):