diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 840e313..e84514c 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -2014,8 +2014,9 @@ class SidebandCore(): elif "telephone_call_is_connecting" in call: connection.send(self.telephone.call_is_connecting if self.telephone else False) elif "telephone_is_ringing" in call: connection.send(self.telephone.is_ringing if self.telephone else False) elif "telephone_caller_info" in call: connection.send(self.telephone.caller.hash if self.telephone and self.telephone.caller else None) + elif "telephone_active_profile" in call: connection.send(self.telephone.active_profile if self.telephone else None) elif "telephone_set_busy" in call: connection.send(self.telephone.set_busy(call["telephone_set_busy"]) if self.telephone else False) - elif "telephone_dial" in call: connection.send(self.telephone.dial(call["telephone_dial"]) if self.telephone else False) + elif "telephone_dial" in call: connection.send(self.telephone.dial(call["telephone_dial"], profile=call["profile"]) if self.telephone else False) elif "telephone_hangup" in call: connection.send(self.telephone.hangup() if self.telephone else False) elif "telephone_answer" in call: connection.send(self.telephone.answer() if self.telephone else False) elif "telephone_set_speaker" in call: connection.send(self.telephone.set_speaker(call["telephone_set_speaker"]) if self.telephone else False) diff --git a/sbapp/sideband/voice.py b/sbapp/sideband/voice.py index f506da6..1721a43 100644 --- a/sbapp/sideband/voice.py +++ b/sbapp/sideband/voice.py @@ -80,28 +80,25 @@ class ReticulumTelephone(): self.telephone.announce(attached_interface=attached_interface) @property - def is_available(self): - return self.state == self.STATE_AVAILABLE + def is_available(self): return self.state == self.STATE_AVAILABLE @property - def is_in_call(self): - return self.state == self.STATE_IN_CALL + def is_in_call(self): return self.state == self.STATE_IN_CALL @property - def is_ringing(self): - return self.state == self.STATE_RINGING + def is_ringing(self): return self.state == self.STATE_RINGING @property - def call_is_connecting(self): - return self.state == self.STATE_CONNECTING + def call_is_connecting(self): return self.state == self.STATE_CONNECTING @property - def hw_is_idle(self): - return self.hw_state == self.HW_STATE_IDLE + def hw_is_idle(self): return self.hw_state == self.HW_STATE_IDLE @property - def hw_is_dialing(self): - return self.hw_state == self.HW_STATE_DIAL + def hw_is_dialing(self): return self.hw_state == self.HW_STATE_DIAL + + @property + def active_profile(self): return self.telephone.active_profile def start(self): if not self.should_run: @@ -173,7 +170,7 @@ class ReticulumTelephone(): RNS.log(f"An error occurred while updating call log: {e}", RNS.LOG_ERROR) RNS.trace_exception(e) - def dial(self, identity_hash): + def dial(self, identity_hash, profile=None): self.last_dialled_identity_hash = identity_hash destination_hash = RNS.Destination.hash_from_name_and_identity("lxst.telephony", identity_hash) if RNS.Transport.has_path(destination_hash): @@ -181,19 +178,19 @@ class ReticulumTelephone(): cs = "" if call_hops == 1 else "s" RNS.log(f"Connecting call over {call_hops} hop{cs}...", RNS.LOG_DEBUG) identity = RNS.Identity.recall(destination_hash) - self.call(identity) + self.call(identity, profile=profile) else: return "no_path" def redial(self, args=None): if self.last_dialled_identity_hash: self.dial(self.last_dialled_identity_hash) - def call(self, remote_identity): + def call(self, remote_identity, profile=None): RNS.log(f"Calling {RNS.prettyhexrep(remote_identity.hash)}...", RNS.LOG_DEBUG) self.state = self.STATE_CONNECTING self.caller = remote_identity self.direction = "to" - self.telephone.call(self.caller) + self.telephone.call(self.caller, profile=profile) def ringing(self, remote_identity): if self.hw_state == self.HW_STATE_SLEEP: self.hw_state = self.HW_STATE_IDLE @@ -270,8 +267,11 @@ class ReticulumTelephoneProxy(): @property def caller(self): return CallerProxy(hash=self.owner.service_rpc_request({"telephone_caller_info": True })) + @property + def active_profile(self): return self.owner.service_rpc_request({"telephone_active_profile": True }) + def set_busy(self, busy): return self.owner.service_rpc_request({"telephone_set_busy": busy }) - def dial(self, dial_target): return self.owner.service_rpc_request({"telephone_dial": dial_target }) + def dial(self, dial_target, profile=None): return self.owner.service_rpc_request({"telephone_dial": dial_target, "profile": profile }) def hangup(self): return self.owner.service_rpc_request({"telephone_hangup": True }) def answer(self): return self.owner.service_rpc_request({"telephone_answer": True }) def set_speaker(self, speaker): return self.owner.service_rpc_request({"telephone_set_speaker": speaker }) diff --git a/sbapp/ui/voice.py b/sbapp/ui/voice.py index f739285..80e05aa 100644 --- a/sbapp/ui/voice.py +++ b/sbapp/ui/voice.py @@ -35,6 +35,8 @@ if RNS.vendor.platformutils.get_platform() == "android": else: from .helpers import multilingual_markup +from LXST.Primitives.Telephony import Telephone, Profiles + class Voice(): def __init__(self, app): self.app = app @@ -51,6 +53,7 @@ class Voice(): self.listed_output_devices = [] self.listed_input_devices = [] self.listed_ringer_devices = [] + self.call_profile = Profiles.DEFAULT_PROFILE if not self.app.root.ids.screen_manager.has_screen("voice_screen"): self.screen = Builder.load_string(layout_voice_screen) @@ -70,6 +73,7 @@ class Voice(): db = self.screen.ids.dial_button rb = self.screen.ids.reject_button ih = self.screen.ids.identity_hash + pb = self.screen.ids.call_profile_button if self.app.sideband.voice_running: telephone = self.app.sideband.telephone if self.path_requesting: @@ -81,29 +85,39 @@ class Voice(): if telephone.is_available: ih.disabled = False rb.disabled = True + pb.disabled = False self.target_input_action(ih) else: ih.disabled = True rb.disabled = True + pb.disabled = True if telephone.is_in_call or telephone.call_is_connecting: ih.disabled = True rb.disabled = True db.disabled = False + pb.disabled = True db.text = "Hang up" db.icon = "phone-hangup" + if telephone.active_profile: self.call_profile = telephone.active_profile elif telephone.is_ringing: ih.disabled = True rb.disabled = False db.disabled = False + pb.disabled = True db.text = "Answer" db.icon = "phone-ring" if telephone.caller: ih.text = RNS.hexrep(telephone.caller.hash, delimit=False) + if telephone.active_profile: self.call_profile = telephone.active_profile else: db.disabled = True; db.text = "Voice calls disabled" ih.disabled = True + rb.disabled = True + pb.disabled = True + + pb.text = Profiles.profile_abbrevation(self.call_profile) if time.time() > self.last_log_update+3: self.update_call_log() @@ -151,7 +165,7 @@ class Voice(): self.app.sideband.telephone.set_busy(False) if RNS.Transport.has_path(self.path_requesting): RNS.log(f"Calling {RNS.prettyhexrep(self.dial_target)}...", RNS.LOG_DEBUG) - self.app.sideband.telephone.dial(self.dial_target) + self.app.sideband.telephone.dial(self.dial_target, profile=self.call_profile) Clock.schedule_once(self.update_call_status, 0.1) else: @@ -164,6 +178,12 @@ class Voice(): def _path_request_failed(self, dt): toast("Path request timed out") + def call_profile_action(self, sender=None): + pb = self.screen.ids.call_profile_button + self.call_profile = Profiles.next_profile(self.call_profile) + pb.text = Profiles.profile_abbrevation(self.call_profile) + toast(f"Call Profile: {Profiles.profile_name(self.call_profile)}") + def clear_log_action(self, sender=None): self.app.sideband.telephone.clear_call_log() self.update_call_log() @@ -197,7 +217,7 @@ class Voice(): else: RNS.log(f"Calling {RNS.prettyhexrep(self.dial_target)}...", RNS.LOG_DEBUG) - self.app.sideband.telephone.dial(self.dial_target) + self.app.sideband.telephone.dial(self.dial_target, profile=self.call_profile) self.update_call_status() elif self.app.sideband.telephone.is_in_call or self.app.sideband.telephone.call_is_connecting: @@ -246,6 +266,8 @@ class Voice(): self.voice_settings_screen.ids.voice_low_latency.active = self.app.sideband.config["voice_low_latency"] self.voice_settings_screen.ids.voice_low_latency.bind(active=self.settings_save_action) + if not RNS.vendor.platformutils.is_android(): self.voice_settings_screen.ids.voice_low_latency.disabled = True + bp = 6; ml = 38; fs = 16; ics = 14 self.update_devices() @@ -471,7 +493,7 @@ MDScreen: orientation: "vertical" size_hint_y: None height: self.minimum_height - padding: [dp(28), dp(32), dp(28), dp(16)] + padding: [dp(28), dp(12), dp(28), dp(16)] MDBoxLayout: orientation: "vertical" @@ -496,16 +518,34 @@ MDScreen: height: self.minimum_height padding: [dp(0), dp(35), dp(0), dp(14)] - MDRectangleFlatIconButton: - id: dial_button - icon: "phone-outgoing" - text: "Call" - padding: [dp(0), dp(14), dp(0), dp(14)] - icon_size: dp(24) - font_size: dp(16) - size_hint: [1.0, None] - on_release: root.delegate.dial_action(self) - disabled: True + MDBoxLayout: + orientation: "horizontal" + spacing: "24dp" + size_hint_y: None + height: self.minimum_height + padding: [dp(0), dp(0), dp(0), dp(0)] + + MDRectangleFlatIconButton: + id: call_profile_button + icon: "account-voice" + text: "HQ" + padding: [dp(0), dp(14), dp(0), dp(14)] + icon_size: dp(24) + font_size: dp(16) + size_hint: [1.0, None] + on_release: root.delegate.call_profile_action(self) + disabled: False + + MDRectangleFlatIconButton: + id: dial_button + icon: "phone-outgoing" + text: "Call" + padding: [dp(0), dp(14), dp(0), dp(14)] + icon_size: dp(24) + font_size: dp(16) + size_hint: [2.0, None] + on_release: root.delegate.dial_action(self) + disabled: True MDRectangleFlatIconButton: id: reject_button