From 81f2b1695f1c9b6c3e2d9cd496c297a185ab280a Mon Sep 17 00:00:00 2001 From: sqozz Date: Thu, 25 Feb 2021 10:33:32 +0100 Subject: [PATCH] Add unregister function --- README.md | 1 + pylinphone.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index c44a554..3b21fdc 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Currently implemented Features: * play dtmf tones (`dtmf`) * get call status (`call-status`) * get call stats (`call-stats`) +* unregister an account (`unregister`) Features supported by the unix socket (linphone deamon): diff --git a/pylinphone.py b/pylinphone.py index 8bb86db..a33eac7 100644 --- a/pylinphone.py +++ b/pylinphone.py @@ -28,6 +28,14 @@ class LinphoneCommunicationSocket(): answer = self.send_command(("register {identity} {proxy_address} {password} {userid} {realm} {parameters}".format(identity=identity, proxy_address=proxy_address, password=password, userid=userid, realm=realm, parameters="" if parameters else parameters))) return int(answer["data"][0].split(":", 1)[1].strip()) #id of newly registered account + def unregister(self, register_id): + self.send_command("unregister {register_id}".format(register_id=register_id)) + + if answer["status"]: + return True + else: + raise RuntimeError(answer["error"]) + def register_status(self, account_id=None): answer = self.send_command(("register-status {account_id}".format(account_id="ALL" if account_id == None else account_id))) accounts = []