diff --git a/phoneinterface.py b/phoneinterface.py index 1dc3d46..70a3feb 100644 --- a/phoneinterface.py +++ b/phoneinterface.py @@ -94,18 +94,21 @@ class PhoneInterface(object): def on_LinphoneCallIncomingReceived(self, event): self.run_callbacks(PhoneEvent.CallIncoming) 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): 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): + self.call_connected_time = time.time() self.run_callbacks(PhoneEvent.CallAccepted) 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.current_call_id = None + self.current_history_id = None def __pollthread(self): while self.__running: @@ -146,9 +149,11 @@ class PhoneInterface(object): self.__core.call(number) def accept_call(self): + self.__history.accept_call(self.current_history_id) self.__core.answer(self.current_call_id) def decline_call(self): + self.__history.decline_call(self.current_history_id) self.__core.decline_call(self.__core.current_call) def end_call(self):