From a4ecfb12b9381667719f687f2a44af832d9c80a9 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 7 Oct 2023 12:59:59 +0200 Subject: [PATCH] Added ability to export RPC keys for use with other instances, primarily on Termux/Android. --- sbapp/main.py | 23 +++++++++++++++++++++++ sbapp/ui/layouts.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/sbapp/main.py b/sbapp/main.py index 9f0664b..77fefd5 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -1680,6 +1680,29 @@ class SidebandApp(MDApp): def close_connectivity_action(self, sender=None): self.open_conversations(direction="right") + + def rpc_copy_action(self, sender=None): + c_yes_button = MDRectangleFlatButton(text="Yes",font_size=dp(18), theme_text_color="Custom", line_color=self.color_reject, text_color=self.color_reject) + c_no_button = MDRectangleFlatButton(text="No, go back",font_size=dp(18)) + c_dialog = MDDialog(text="[b]Caution![/b]\n\nA configuration line containing your Reticulum RPC key will be copied to the system clipboard.\n\nWhile the key can only be used by other programs running locally on this system, it is still recommended to take care in not exposing it to unwanted programs.\n\nAre you sure that you wish to proceed?", buttons=[ c_no_button, c_yes_button ]) + def c_dl_no(s): + c_dialog.dismiss() + def c_dl_yes(s): + c_dialog.dismiss() + yes_button = MDRectangleFlatButton(text="OK") + dialog = MDDialog(text="The RPC configuration was copied to the system clipboard. Paste in into the [b][reticulum][/b] section of the relevant Reticulum configuration file to allow access to this instance.", buttons=[ yes_button ]) + def dl_yes(s): + dialog.dismiss() + yes_button.bind(on_release=dl_yes) + + rpc_string = "rpc_key = "+RNS.hexrep(self.sideband.reticulum.rpc_key, delimit=False) + Clipboard.copy(rpc_string) + dialog.open() + + c_yes_button.bind(on_release=c_dl_yes) + c_no_button.bind(on_release=c_dl_no) + + c_dialog.open() ### Repository screen ###################################### diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py index 819a0a1..91f5691 100644 --- a/sbapp/ui/layouts.py +++ b/sbapp/ui/layouts.py @@ -523,6 +523,35 @@ MDNavigationLayout: # font_size: dp(24) # # disabled: True + MDLabel: + text: "Shared Instance Access\\n" + font_style: "H6" + + MDLabel: + id: connectivity_shared_access + markup: True + text: "The Reticulum instance launched by Sideband will be available for other programs on this system. By default, this grants connectivity to other local Reticulum-based programs, but no access to management, interface status and path information.\\n\\nIf you want to allow full functionality and ability to manage the running instance, you will need to configure other programs to use the correct RPC key for this instance.\\n\\nThis can be very useful for using other tools related to Reticulum, for example via command-line programs running in Termux. To do this, use the button below to copy the RPC key configuration line, and paste it into the Reticulum configuration file within the Termux environment, or other program.\\n\\n" + size_hint_y: None + text_size: self.width, None + height: self.texture_size[1] + + MDBoxLayout: + id: connectivity_serial_fields + orientation: "vertical" + size_hint_y: None + height: self.minimum_height + padding: [0, 0, 0, dp(32)] + + MDRectangleFlatIconButton: + id: rpc_keys_copy + icon: "file-key" + text: "Copy RPC Config To Clipboard" + 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.ids.screen_manager.app.rpc_copy_action(self) + MDBoxLayout: orientation: "horizontal" padding: [0,0,dp(24),0]