2023-10-26 03:53:42 -06:00
__debug_build__ = True
2023-07-09 18:49:58 -06:00
__disable_shaders__ = False
2023-10-22 15:13:51 -06:00
__version__ = " 0.7.0 "
2022-10-03 10:29:54 -06:00
__variant__ = " beta "
import sys
import argparse
parser = argparse . ArgumentParser ( description = " Reticulum Network Stack Daemon " )
parser . add_argument ( " -v " , " --verbose " , action = ' store_true ' , default = False , help = " increase logging verbosity " )
parser . add_argument ( " --version " , action = " version " , version = " sideband {version} " . format ( version = __version__ ) )
args = parser . parse_args ( )
sys . argv = [ sys . argv [ 0 ] ]
2022-04-07 13:03:53 -06:00
import RNS
import LXMF
import time
2022-07-13 02:53:07 -06:00
import os
2022-09-16 10:25:35 -06:00
import plyer
2022-09-17 14:55:27 -06:00
import base64
2022-10-01 03:18:14 -06:00
import threading
2022-10-13 10:37:59 -06:00
import RNS . vendor . umsgpack as msgpack
2022-04-07 13:03:53 -06:00
2022-07-06 04:19:05 -06:00
from kivy . logger import Logger , LOG_LEVELS
2022-10-07 09:22:03 -06:00
if __debug_build__ or args . verbose :
2022-10-03 10:29:54 -06:00
Logger . setLevel ( LOG_LEVELS [ " debug " ] )
else :
Logger . setLevel ( LOG_LEVELS [ " error " ] )
2022-04-07 13:03:53 -06:00
2022-07-13 02:53:07 -06:00
if RNS . vendor . platformutils . get_platform ( ) != " android " :
local = os . path . dirname ( __file__ )
sys . path . append ( local )
2023-10-19 18:41:05 -06:00
from typing import Union
2022-04-07 13:03:53 -06:00
from kivymd . app import MDApp
2023-10-19 18:41:05 -06:00
from kivymd . icon_definitions import md_icons
2022-04-07 13:03:53 -06:00
from kivy . core . window import Window
2022-09-17 14:55:27 -06:00
from kivy . core . clipboard import Clipboard
2022-07-06 08:08:53 -06:00
from kivy . base import EventLoop
2022-04-07 13:03:53 -06:00
from kivy . clock import Clock
from kivy . lang . builder import Builder
2022-10-07 09:22:03 -06:00
from kivy . effects . scroll import ScrollEffect
from kivy . uix . screenmanager import ScreenManager
from kivy . uix . screenmanager import FadeTransition , NoTransition
2023-10-19 18:41:05 -06:00
from kivymd . uix . list import OneLineIconListItem
from kivy . properties import StringProperty
from kivymd . uix . pickers import MDColorPicker
2023-10-21 17:12:55 -06:00
from kivymd . uix . button import BaseButton , MDIconButton
2023-10-25 18:28:41 -06:00
from kivymd . uix . filemanager import MDFileManager
from kivymd . toast import toast
2023-10-20 15:38:28 -06:00
from sideband . sense import Telemeter
2023-10-21 17:12:55 -06:00
from mapview import CustomMapMarker
2023-10-25 18:28:41 -06:00
from mapview . mbtsource import MBTilesMapSource
from mapview . source import MapSource
2022-04-07 13:03:53 -06:00
2022-07-07 14:16:10 -06:00
if RNS . vendor . platformutils . get_platform ( ) == " android " :
from sideband . core import SidebandCore
2023-10-22 07:49:00 -06:00
from ui . layouts import *
2022-07-07 14:16:10 -06:00
from ui . conversations import Conversations , MsgSync , NewConv
2023-10-22 17:26:44 -06:00
from ui . objectdetails import ObjectDetails
2022-07-07 14:16:10 -06:00
from ui . announces import Announces
2023-10-22 10:08:28 -06:00
from ui . messages import Messages , ts_format , messages_screen_kv
2022-07-07 14:16:10 -06:00
from ui . helpers import ContentNavigationDrawer , DrawerList , IconListItem
2022-09-17 14:55:27 -06:00
from jnius import cast
from jnius import autoclass
from android import mActivity
2022-09-16 10:25:35 -06:00
from android . permissions import request_permissions , check_permission
2023-10-25 18:28:41 -06:00
from android . storage import primary_external_storage_path , secondary_external_storage_path
2022-09-16 10:25:35 -06:00
2022-10-02 16:47:27 -06:00
from kivymd . utils . set_bars_colors import set_bars_colors
2022-10-20 07:36:29 -06:00
android_api_version = autoclass ( ' android.os.Build$VERSION ' ) . SDK_INT
2022-10-02 16:47:27 -06:00
2022-07-07 14:16:10 -06:00
else :
from . sideband . core import SidebandCore
2023-10-22 07:49:00 -06:00
from . ui . layouts import *
2022-07-07 14:16:10 -06:00
from . ui . conversations import Conversations , MsgSync , NewConv
from . ui . announces import Announces
2023-10-22 17:26:44 -06:00
from . ui . objectdetails import ObjectDetails
2023-10-22 10:08:28 -06:00
from . ui . messages import Messages , ts_format , messages_screen_kv
2022-07-07 14:16:10 -06:00
from . ui . helpers import ContentNavigationDrawer , DrawerList , IconListItem
2022-04-07 13:03:53 -06:00
2022-11-23 02:41:45 -07:00
from kivy . config import Config
Config . set ( ' input ' , ' mouse ' , ' mouse,disable_multitouch ' )
2022-10-08 14:47:08 -06:00
from kivy . metrics import dp , sp
2022-10-13 15:36:41 -06:00
from kivymd . uix . button import MDRectangleFlatButton
2022-04-07 13:03:53 -06:00
from kivymd . uix . dialog import MDDialog
2022-10-08 14:47:08 -06:00
from kivymd . color_definitions import colors
2022-04-07 13:03:53 -06:00
2022-10-02 14:00:15 -06:00
dark_theme_text_color = " ddd "
2022-07-06 11:18:26 -06:00
if RNS . vendor . platformutils . get_platform ( ) == " android " :
from jnius import autoclass
from android . runnable import run_on_ui_thread
2022-04-07 13:03:53 -06:00
class SidebandApp ( MDApp ) :
2022-09-17 09:12:25 -06:00
STARTING = 0x00
ACTIVE = 0x01
PAUSED = 0x02
STOPPING = 0x03
2022-10-01 03:18:14 -06:00
PKGNAME = " io.unsigned.sideband "
2022-12-22 13:36:37 -07:00
SERVICE_TIMEOUT = 30
2022-12-16 15:57:07 -07:00
2023-10-07 08:54:38 -06:00
EINK_BG_STR = " 1,0,0,1 "
EINK_BG_ARR = [ 1 , 0 , 0 , 1 ]
2022-04-07 13:03:53 -06:00
def __init__ ( self , * * kwargs ) :
super ( ) . __init__ ( * * kwargs )
self . title = " Sideband "
2022-09-17 09:12:25 -06:00
self . app_state = SidebandApp . STARTING
2022-10-01 03:18:14 -06:00
self . android_service = None
2022-10-03 07:15:59 -06:00
self . app_dir = plyer . storagepath . get_application_dir ( )
2022-10-08 10:01:33 -06:00
self . shaders_disabled = __disable_shaders__
2022-04-07 13:03:53 -06:00
2022-10-01 03:18:14 -06:00
if RNS . vendor . platformutils . get_platform ( ) == " android " :
2022-10-07 09:22:03 -06:00
self . sideband = SidebandCore ( self , is_client = True , android_app_dir = self . app_dir , verbose = __debug_build__ )
2022-10-01 03:18:14 -06:00
else :
2022-10-07 09:22:03 -06:00
self . sideband = SidebandCore ( self , is_client = False , verbose = ( args . verbose or __debug_build__ ) )
2022-09-14 13:34:21 -06:00
2022-10-08 10:01:33 -06:00
self . set_ui_theme ( )
2022-04-07 13:03:53 -06:00
2022-10-02 06:03:56 -06:00
self . conversations_view = None
2023-10-22 07:49:00 -06:00
self . messages_view = None
self . map_screen = None
2023-10-22 17:26:44 -06:00
self . object_details_screen = None
2022-04-07 13:03:53 -06:00
self . sync_dialog = None
2022-10-06 09:12:42 -06:00
self . settings_ready = False
2023-10-19 18:41:05 -06:00
self . telemetry_ready = False
2022-10-06 09:12:42 -06:00
self . connectivity_ready = False
2022-10-13 10:37:59 -06:00
self . hardware_ready = False
2023-09-20 12:12:47 -06:00
self . repository_ready = False
2022-10-13 10:37:59 -06:00
self . hardware_rnode_ready = False
self . hardware_modem_ready = False
self . hardware_serial_ready = False
2022-04-07 13:03:53 -06:00
2022-12-15 09:01:10 -07:00
self . final_load_completed = False
2022-12-16 15:57:07 -07:00
self . service_last_available = 0
2022-12-15 09:01:10 -07:00
2022-04-07 13:03:53 -06:00
Window . softinput_mode = " below_target "
2022-09-16 10:25:35 -06:00
self . icon = self . sideband . asset_dir + " /icon.png "
self . notification_icon = self . sideband . asset_dir + " /notification_icon.png "
2022-04-07 13:03:53 -06:00
2022-11-03 15:55:35 -06:00
self . connectivity_updater = None
2023-10-20 15:38:28 -06:00
self . last_map_update = 0
self . last_telemetry_received = 0
2022-11-03 15:55:35 -06:00
2022-10-15 02:06:42 -06:00
#################################################
# Application Startup #
#################################################
2022-10-11 09:49:12 -06:00
def update_loading_text ( self ) :
if self . sideband :
loadingstate = self . sideband . getstate ( " init.loadingstate " )
if loadingstate :
self . root . ids . connecting_status . text = loadingstate
def update_init_status ( self , dt ) :
self . update_loading_text ( )
if not RNS . vendor . platformutils . is_android ( ) or self . sideband . service_available ( ) :
2022-12-16 15:57:07 -07:00
self . service_last_available = time . time ( )
2022-10-11 09:49:12 -06:00
self . start_final ( )
self . loading_updater . cancel ( )
2022-09-14 13:34:21 -06:00
def start_core ( self , dt ) :
2022-10-12 08:33:05 -06:00
self . loading_updater = Clock . schedule_interval ( self . update_init_status , 0.1 )
2022-10-11 09:49:12 -06:00
2022-10-02 16:47:27 -06:00
self . check_permissions ( )
2022-11-02 15:31:46 -06:00
self . check_bluetooth_permissions ( )
2022-10-01 03:18:14 -06:00
self . start_service ( )
2022-11-23 10:57:53 -07:00
Clock . schedule_interval ( self . jobs , 1.5 )
2022-09-14 13:34:21 -06:00
2022-09-16 10:25:35 -06:00
def dismiss_splash ( dt ) :
from android import loadingscreen
loadingscreen . hide_loading_screen ( )
if RNS . vendor . platformutils . get_platform ( ) == " android " :
Clock . schedule_once ( dismiss_splash , 0 )
2022-10-11 09:49:12 -06:00
self . set_bars_colors ( )
2023-10-22 13:04:28 -06:00
def sjob ( dt ) :
self . sideband . setstate ( " app.loaded " , True )
self . sideband . setstate ( " app.running " , True )
self . sideband . setstate ( " app.foreground " , True )
Clock . schedule_once ( sjob , 6.5 )
2022-09-20 09:29:41 -06:00
2022-10-01 03:18:14 -06:00
def start_service ( self ) :
2022-10-20 07:36:29 -06:00
if RNS . vendor . platformutils . is_android ( ) :
RNS . log ( " Running on Android API level " + str ( android_api_version ) )
2022-10-01 17:31:47 -06:00
RNS . log ( " Launching platform-specific service for RNS and LXMF " )
2022-09-20 09:29:41 -06:00
if RNS . vendor . platformutils . get_platform ( ) == " android " :
2022-10-01 03:18:14 -06:00
self . android_service = autoclass ( ' io.unsigned.sideband.ServiceSidebandservice ' )
mActivity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
argument = self . app_dir
self . android_service . start ( mActivity , argument )
2022-10-11 09:49:12 -06:00
def start_final ( self ) :
# Start local core instance
self . sideband . start ( )
2022-10-01 17:31:47 -06:00
2022-10-11 09:49:12 -06:00
# Pre-load announce stream widgets
self . update_loading_text ( )
self . init_announces_view ( )
self . announces_view . update ( )
2023-10-22 12:16:41 -06:00
self . telemetry_init ( )
self . settings_init ( )
self . connectivity_init ( )
2023-10-25 10:49:30 -06:00
self . object_details_screen = ObjectDetails ( self )
2022-10-01 03:18:14 -06:00
2022-10-11 09:49:12 -06:00
# Wait a little extra for user to react to permissions prompt
# if RNS.vendor.platformutils.get_platform() == "android":
# if self.sideband.first_run:
# time.sleep(6)
2022-10-01 03:18:14 -06:00
2022-10-11 09:49:12 -06:00
if self . sideband . first_run :
self . guide_action ( )
def fp ( delta_time ) :
self . request_permissions ( )
Clock . schedule_once ( fp , 3 )
2022-10-01 03:18:14 -06:00
else :
2022-10-11 09:49:12 -06:00
self . open_conversations ( )
2022-09-17 08:00:55 -06:00
2023-10-22 10:08:28 -06:00
if not self . root . ids . screen_manager . has_screen ( " messages_screen " ) :
self . messages_screen = Builder . load_string ( messages_screen_kv )
self . messages_screen . app = self
self . root . ids . screen_manager . add_widget ( self . messages_screen )
2022-10-11 09:49:12 -06:00
self . app_state = SidebandApp . ACTIVE
self . loading_updater . cancel ( )
2022-12-15 09:01:10 -07:00
self . final_load_completed = True
2022-10-06 08:07:03 -06:00
2022-10-29 08:37:40 -06:00
def check_errors ( dt ) :
if self . sideband . getpersistent ( " startup.errors.rnode " ) != None :
description = self . sideband . getpersistent ( " startup.errors.rnode " ) [ " description " ]
self . sideband . setpersistent ( " startup.errors.rnode " , None )
yes_button = MDRectangleFlatButton (
text = " OK " ,
font_size = dp ( 18 ) ,
)
self . hw_error_dialog = MDDialog (
title = " Hardware Error " ,
text = " When starting a connected RNode, Reticulum reported the following error: \n \n [i] " + description + " [/i] " ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
self . hw_error_dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
self . hw_error_dialog . open ( )
Clock . schedule_once ( check_errors , 1.5 )
2022-09-17 08:00:55 -06:00
2022-04-07 13:03:53 -06:00
#################################################
# General helpers #
#################################################
2022-10-08 10:01:33 -06:00
def set_ui_theme ( self ) :
2022-10-02 09:17:55 -06:00
self . theme_cls . material_style = " M3 "
self . theme_cls . widget_style = " android "
2022-10-02 14:00:15 -06:00
self . theme_cls . primary_palette = " BlueGray "
self . theme_cls . accent_palette = " Orange "
2022-10-08 10:01:33 -06:00
2022-10-02 06:03:56 -06:00
if self . sideband . config [ " dark_ui " ] :
self . theme_cls . theme_style = " Dark "
else :
self . theme_cls . theme_style = " Light "
2022-10-08 14:47:08 -06:00
self . update_ui_colors ( )
def update_ui_colors ( self ) :
if self . sideband . config [ " dark_ui " ] :
self . color_reject = colors [ " DeepOrange " ] [ " 900 " ]
self . color_accept = colors [ " LightGreen " ] [ " 700 " ]
else :
self . color_reject = colors [ " DeepOrange " ] [ " 800 " ]
self . color_accept = colors [ " LightGreen " ] [ " 700 " ]
2023-10-07 08:54:38 -06:00
self . apply_eink_mods ( )
2022-10-08 14:47:08 -06:00
2022-10-08 10:01:33 -06:00
def update_ui_theme ( self ) :
if self . sideband . config [ " dark_ui " ] :
self . theme_cls . theme_style = " Dark "
else :
self . theme_cls . theme_style = " Light "
2023-10-07 08:54:38 -06:00
self . apply_eink_mods ( )
2022-10-08 10:01:33 -06:00
2022-10-08 14:47:08 -06:00
self . update_ui_colors ( )
2023-10-07 08:54:38 -06:00
def apply_eink_mods ( self ) :
if self . sideband . config [ " eink_mode " ] :
if self . root != None :
self . root . md_bg_color = self . theme_cls . bg_light
else :
if self . root != None :
self . root . md_bg_color = self . theme_cls . bg_darkest
2022-10-08 10:01:33 -06:00
2022-10-02 16:47:27 -06:00
def set_bars_colors ( self ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
set_bars_colors (
self . theme_cls . primary_color , # status bar color
[ 0 , 0 , 0 , 0 ] , # navigation bar color
" Light " , # icons color of status bar
)
2022-10-13 15:36:41 -06:00
def close_any_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2022-09-17 14:55:27 -06:00
def share_text ( self , text ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
Intent = autoclass ( ' android.content.Intent ' )
JString = autoclass ( ' java.lang.String ' )
shareIntent = Intent ( )
shareIntent . setAction ( Intent . ACTION_SEND )
shareIntent . setType ( " text/plain " )
shareIntent . putExtra ( Intent . EXTRA_TEXT , JString ( text ) )
mActivity . startActivity ( shareIntent )
2022-11-22 11:47:13 -07:00
def share_image ( self , image , filename ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
save_path = self . sideband . exports_dir
file_path = save_path + " / " + filename
try :
if not os . path . isdir ( save_path ) :
RNS . log ( " Creating directory: " + str ( save_path ) )
os . makedirs ( save_path )
Intent = autoclass ( " android.content.Intent " )
Uri = autoclass ( " android.net.Uri " )
File = autoclass ( " java.io.File " )
2023-02-04 12:56:10 -07:00
FileProvider = autoclass ( " androidx.core.content.FileProvider " )
2022-11-22 11:47:13 -07:00
image . save ( file_path )
i_file = File ( file_path )
image_uri = FileProvider . getUriForFile ( mActivity , " io.unsigned.sideband.provider " , i_file )
shareIntent = Intent ( )
shareIntent . setAction ( Intent . ACTION_SEND )
shareIntent . setType ( " image/png " )
shareIntent . putExtra ( Intent . EXTRA_STREAM , cast ( ' android.os.Parcelable ' , image_uri ) )
mActivity . startActivity ( shareIntent )
except Exception as e :
ok_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
dialog = MDDialog (
title = " Export Error " ,
text = " The QR-code could not be exported and shared: \n \n " + str ( e ) ,
buttons = [ ok_button ] ,
)
def dl_ok ( s ) :
dialog . dismiss ( )
ok_button . bind ( on_release = dl_ok )
dialog . open ( )
2022-09-17 09:12:25 -06:00
def on_pause ( self ) :
2022-10-19 14:59:42 -06:00
if self . sideband :
if self . sideband . getstate ( " flag.focusfix_pause " ) :
self . sideband . setstate ( " flag.focusfix_pause " , False )
return True
else :
RNS . log ( " App pausing... " , RNS . LOG_DEBUG )
self . sideband . setstate ( " app.running " , True )
self . sideband . setstate ( " app.foreground " , False )
self . app_state = SidebandApp . PAUSED
self . sideband . should_persist_data ( )
if self . conversations_view != None :
2023-10-22 09:44:44 -06:00
self . conversations_view . ids . conversations_scrollview . effect_cls = ScrollEffect
self . conversations_view . ids . conversations_scrollview . scroll = 1
2022-10-19 14:59:42 -06:00
RNS . log ( " App paused " , RNS . LOG_DEBUG )
return True
else :
return True
2022-09-17 09:12:25 -06:00
def on_resume ( self ) :
2022-10-19 14:59:42 -06:00
if self . sideband :
if self . sideband . getstate ( " flag.focusfix_resume " ) :
self . sideband . setstate ( " flag.focusfix_resume " , False )
return True
else :
RNS . log ( " App resuming... " , RNS . LOG_DEBUG )
self . sideband . setstate ( " app.running " , True )
self . sideband . setstate ( " app.foreground " , True )
self . sideband . setstate ( " wants.clear_notifications " , True )
self . app_state = SidebandApp . ACTIVE
if self . conversations_view != None :
2023-10-22 09:44:44 -06:00
self . conversations_view . ids . conversations_scrollview . effect_cls = ScrollEffect
self . conversations_view . ids . conversations_scrollview . scroll = 1
2022-10-19 14:59:42 -06:00
else :
RNS . log ( " Conversations view did not exist " , RNS . LOG_DEBUG )
2022-10-07 09:22:03 -06:00
2022-10-19 14:59:42 -06:00
RNS . log ( " App resumed " , RNS . LOG_DEBUG )
2022-09-17 09:12:25 -06:00
def on_stop ( self ) :
2022-10-07 09:22:03 -06:00
RNS . log ( " App stopping... " , RNS . LOG_DEBUG )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.running " , False )
self . sideband . setstate ( " app.foreground " , False )
2022-09-17 09:12:25 -06:00
self . app_state = SidebandApp . STOPPING
2022-10-07 09:22:03 -06:00
RNS . log ( " App stopped " , RNS . LOG_DEBUG )
2022-09-17 09:12:25 -06:00
def is_in_foreground ( self ) :
if self . app_state == SidebandApp . ACTIVE :
return True
else :
return False
2022-11-02 15:31:46 -06:00
def check_bluetooth_permissions ( self ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
mActivity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
Context = autoclass ( ' android.content.Context ' )
2022-11-23 12:42:56 -07:00
if android_api_version > 30 :
bt_permission_name = " android.permission.BLUETOOTH_CONNECT "
else :
bt_permission_name = " android.permission.BLUETOOTH "
if check_permission ( bt_permission_name ) :
2022-11-02 15:31:46 -06:00
RNS . log ( " Have bluetooth connect permissions " , RNS . LOG_DEBUG )
self . sideband . setpersistent ( " permissions.bluetooth " , True )
else :
RNS . log ( " Do not have bluetooth connect permissions " )
self . sideband . setpersistent ( " permissions.bluetooth " , False )
else :
self . sideband . setpersistent ( " permissions.bluetooth " , True )
2022-10-01 17:14:29 -06:00
def check_permissions ( self ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
2022-10-02 18:28:59 -06:00
mActivity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
Context = autoclass ( ' android.content.Context ' )
NotificationManager = autoclass ( ' android.app.NotificationManager ' )
notification_service = cast ( NotificationManager , mActivity . getSystemService ( Context . NOTIFICATION_SERVICE ) )
if notification_service . areNotificationsEnabled ( ) :
2022-10-01 17:14:29 -06:00
self . sideband . setpersistent ( " permissions.notifications " , True )
2022-09-16 10:25:35 -06:00
else :
2022-10-02 18:28:59 -06:00
if check_permission ( " android.permission.POST_NOTIFICATIONS " ) :
RNS . log ( " Have notification permissions " , RNS . LOG_DEBUG )
self . sideband . setpersistent ( " permissions.notifications " , True )
else :
RNS . log ( " Do not have notification permissions " )
self . sideband . setpersistent ( " permissions.notifications " , False )
2022-10-01 17:14:29 -06:00
else :
self . sideband . setpersistent ( " permissions.notifications " , True )
2022-09-16 10:25:35 -06:00
2022-10-01 17:14:29 -06:00
def request_permissions ( self ) :
self . request_notifications_permission ( )
def request_notifications_permission ( self ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
if not check_permission ( " android.permission.POST_NOTIFICATIONS " ) :
2022-10-02 18:28:59 -06:00
RNS . log ( " Requesting notification permission " , RNS . LOG_DEBUG )
2022-10-01 17:14:29 -06:00
request_permissions ( [ " android.permission.POST_NOTIFICATIONS " ] )
self . check_permissions ( )
2022-09-16 10:25:35 -06:00
2022-11-22 11:47:13 -07:00
def check_storage_permission ( self ) :
storage_permissions_ok = False
if android_api_version < 30 :
2023-10-25 18:28:41 -06:00
if check_permission ( " android.permission.WRITE_EXTERNAL_STORAGE " ) and check_permission ( " android.permission.READ_EXTERNAL_STORAGE " ) :
2022-11-22 11:47:13 -07:00
storage_permissions_ok = True
else :
self . request_storage_permission ( )
else :
Environment = autoclass ( ' android.os.Environment ' )
if Environment . isExternalStorageManager ( ) :
storage_permissions_ok = True
else :
ok_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
dialog = MDDialog (
title = " Storage Permission " ,
2023-10-25 18:28:41 -06:00
text = " Sideband needs external storage permission to to read offline map files. \n \n On this Android version, the Manage All Files permission is needed, since normal external storage permission is no longer supported. \n \n Sideband will only ever read and write to files you select, and does not read any other data from your system. " ,
2022-11-22 11:47:13 -07:00
buttons = [ ok_button ] ,
)
def dl_ok ( s ) :
dialog . dismiss ( )
self . request_storage_permission ( )
ok_button . bind ( on_release = dl_ok )
dialog . open ( )
return storage_permissions_ok
def request_storage_permission ( self ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
if android_api_version < 30 :
if not check_permission ( " android.permission.WRITE_EXTERNAL_STORAGE " ) :
RNS . log ( " Requesting storage write permission " , RNS . LOG_DEBUG )
request_permissions ( [ " android.permission.WRITE_EXTERNAL_STORAGE " ] )
if not check_permission ( " android.permission.READ_EXTERNAL_STORAGE " ) :
RNS . log ( " Requesting storage read permission " , RNS . LOG_DEBUG )
request_permissions ( [ " android.permission.READ_EXTERNAL_STORAGE " ] )
else :
Intent = autoclass ( ' android.content.Intent ' )
Settings = autoclass ( ' android.provider.Settings ' )
pIntent = Intent ( )
pIntent . setAction ( Settings . ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION )
mActivity . startActivity ( pIntent )
2022-11-02 15:31:46 -06:00
def request_bluetooth_permissions ( self ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
if not check_permission ( " android.permission.BLUETOOTH_CONNECT " ) :
RNS . log ( " Requesting bluetooth permission " , RNS . LOG_DEBUG )
request_permissions ( [ " android.permission.BLUETOOTH_CONNECT " ] )
self . check_bluetooth_permissions ( )
2022-11-22 06:25:56 -07:00
def on_new_intent ( self , intent ) :
RNS . log ( " Received intent " , RNS . LOG_DEBUG )
intent_action = intent . getAction ( )
action = None
data = None
if intent_action == " android.intent.action.WEB_SEARCH " :
SearchManager = autoclass ( ' android.app.SearchManager ' )
data = intent . getStringExtra ( SearchManager . QUERY )
if data . lower ( ) . startswith ( LXMF . LXMessage . URI_SCHEMA ) :
action = " lxm_uri "
if intent_action == " android.intent.action.VIEW " :
data = intent . getData ( ) . toString ( )
if data . lower ( ) . startswith ( LXMF . LXMessage . URI_SCHEMA ) :
action = " lxm_uri "
if action != None :
self . handle_action ( action , data )
def handle_action ( self , action , data ) :
if action == " lxm_uri " :
self . ingest_lxm_uri ( data )
def ingest_lxm_uri ( self , lxm_uri ) :
RNS . log ( " Ingesting LXMF paper message from URI: " + str ( lxm_uri ) , RNS . LOG_DEBUG )
self . sideband . lxm_ingest_uri ( lxm_uri )
2022-04-07 13:03:53 -06:00
def build ( self ) :
FONT_PATH = self . sideband . asset_dir + " /fonts "
2022-10-03 14:36:44 -06:00
if RNS . vendor . platformutils . is_darwin ( ) :
self . icon = self . sideband . asset_dir + " /icon_macos_formed.png "
else :
self . icon = self . sideband . asset_dir + " /icon.png "
2022-10-06 08:07:03 -06:00
self . announces_view = None
2022-10-25 07:59:19 -06:00
if RNS . vendor . platformutils . is_android ( ) :
ActivityInfo = autoclass ( ' android.content.pm.ActivityInfo ' )
activity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
activity . setRequestedOrientation ( ActivityInfo . SCREEN_ORIENTATION_UNSPECIFIED )
2022-10-19 15:14:57 -06:00
2022-11-22 06:25:56 -07:00
from android import activity as a_activity
a_activity . bind ( on_new_intent = self . on_new_intent )
2023-10-07 08:54:38 -06:00
if self . sideband . config [ " eink_mode " ] == True :
screen = Builder . load_string ( root_layout . replace ( " app.theme_cls.bg_darkest " , " app.theme_cls.bg_light " ) )
else :
screen = Builder . load_string ( root_layout )
2022-04-07 13:03:53 -06:00
2023-10-22 07:49:00 -06:00
self . nav_drawer = screen . ids . nav_drawer
2022-04-07 13:03:53 -06:00
return screen
2023-10-22 12:16:41 -06:00
def _state_jobs ( self ) :
props = [ ]
2022-04-07 13:03:53 -06:00
def jobs ( self , delta_time ) :
2022-12-15 09:01:10 -07:00
if self . final_load_completed :
2022-12-16 15:57:07 -07:00
if RNS . vendor . platformutils . is_android ( ) and not self . sideband . service_available ( ) :
if time . time ( ) - self . service_last_available > SidebandApp . SERVICE_TIMEOUT :
if self . app_state == SidebandApp . ACTIVE :
info_text = " The Reticulum and LXMF service seem to have disappeared, and Sideband is no longer connected. This should not happen, and probably indicates a bug in the background service. Please restart Sideband to regain connectivity. "
ok_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
dialog = MDDialog (
title = " Error " ,
text = info_text ,
buttons = [ ok_button ] ,
# elevation=0,
)
def dl_ok ( s ) :
dialog . dismiss ( )
2023-10-07 08:54:38 -06:00
self . quit_action ( s )
2022-12-16 15:57:07 -07:00
ok_button . bind ( on_release = dl_ok )
self . final_load_completed = False
dialog . open ( )
else :
2023-10-07 08:54:38 -06:00
self . quit_action ( s )
2022-12-15 09:01:10 -07:00
2022-12-16 15:57:07 -07:00
else :
self . service_last_available = time . time ( )
2022-12-15 09:01:10 -07:00
2022-04-07 13:03:53 -06:00
if self . root . ids . screen_manager . current == " messages_screen " :
self . messages_view . update ( )
2023-10-22 10:08:28 -06:00
if not self . messages_view . ids . messages_scrollview . dest_known :
2022-04-07 13:03:53 -06:00
self . message_area_detect ( )
elif self . root . ids . screen_manager . current == " conversations_screen " :
2022-11-23 10:57:53 -07:00
if self . sideband . getstate ( " app.flags.unread_conversations " , allow_cache = True ) :
2022-04-07 13:03:53 -06:00
if self . conversations_view != None :
self . conversations_view . update ( )
2022-11-23 10:57:53 -07:00
if self . sideband . getstate ( " app.flags.lxmf_sync_dialog_open " , allow_cache = True ) and self . sync_dialog != None :
2022-04-07 13:03:53 -06:00
self . sync_dialog . ids . sync_progress . value = self . sideband . get_sync_progress ( ) * 100
self . sync_dialog . ids . sync_status . text = self . sideband . get_sync_status ( )
2022-10-08 14:47:08 -06:00
state = self . sideband . message_router . propagation_transfer_state
if state > LXMF . LXMRouter . PR_IDLE and state < LXMF . LXMRouter . PR_COMPLETE :
self . widget_hide ( self . sync_dialog . stop_button , False )
else :
self . widget_hide ( self . sync_dialog . stop_button , True )
2022-04-07 13:03:53 -06:00
elif self . root . ids . screen_manager . current == " announces_screen " :
2022-11-23 10:57:53 -07:00
if self . sideband . getstate ( " app.flags.new_announces " , allow_cache = True ) :
2022-04-07 13:03:53 -06:00
if self . announces_view != None :
self . announces_view . update ( )
2023-10-20 15:38:28 -06:00
elif self . root . ids . screen_manager . current == " map_screen " :
2023-10-22 07:49:00 -06:00
if self . map_screen and hasattr ( self . map_screen . ids . map_layout , " map " ) and self . map_screen . ids . map_layout . map != None :
self . sideband . config [ " map_lat " ] = self . map_screen . ids . map_layout . map . lat
self . sideband . config [ " map_lon " ] = self . map_screen . ids . map_layout . map . lon
self . sideband . config [ " map_zoom " ] = self . map_screen . ids . map_layout . map . zoom
2023-10-20 15:38:28 -06:00
self . last_telemetry_received = self . sideband . getstate ( " app.flags.last_telemetry " , allow_cache = True ) or 0
if self . last_telemetry_received > self . last_map_update :
self . map_update_markers ( )
2022-11-23 10:57:53 -07:00
if self . sideband . getstate ( " app.flags.new_conversations " , allow_cache = True ) :
2022-10-06 08:40:30 -06:00
if self . conversations_view != None :
self . conversations_view . update ( )
2022-11-23 10:57:53 -07:00
if self . sideband . getstate ( " wants.viewupdate.conversations " , allow_cache = True ) :
2022-10-12 08:33:05 -06:00
if self . conversations_view != None :
self . conversations_view . update ( )
2022-11-23 10:57:53 -07:00
if self . sideband . getstate ( " lxm_uri_ingest.result " , allow_cache = True ) :
info_text = self . sideband . getstate ( " lxm_uri_ingest.result " , allow_cache = True )
2022-11-22 06:25:56 -07:00
self . sideband . setstate ( " lxm_uri_ingest.result " , False )
ok_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
dialog = MDDialog (
title = " Message Scan " ,
text = info_text ,
buttons = [ ok_button ] ,
# elevation=0,
)
def dl_ok ( s ) :
dialog . dismiss ( )
ok_button . bind ( on_release = dl_ok )
dialog . open ( )
2022-12-15 09:01:10 -07:00
if self . sideband . getstate ( " hardware_operation.error " , allow_cache = True ) :
info_text = self . sideband . getstate ( " hardware_operation.error " , allow_cache = True )
self . sideband . setstate ( " hardware_operation.error " , False )
ok_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
dialog = MDDialog (
title = " Error " ,
text = info_text ,
buttons = [ ok_button ] ,
# elevation=0,
)
def dl_ok ( s ) :
dialog . dismiss ( )
ok_button . bind ( on_release = dl_ok )
dialog . open ( )
2022-10-06 08:53:12 -06:00
def on_start ( self ) :
2022-07-06 08:08:53 -06:00
self . last_exit_event = time . time ( )
2022-10-06 08:53:12 -06:00
self . root . ids . screen_manager . transition . duration = 0.25
self . root . ids . screen_manager . transition . bind ( on_complete = self . screen_transition_complete )
2022-07-06 08:08:53 -06:00
EventLoop . window . bind ( on_keyboard = self . keyboard_event )
EventLoop . window . bind ( on_key_down = self . keydown_event )
2022-07-06 11:18:26 -06:00
# This incredibly hacky hack circumvents a bug in SDL2
# that prevents focus from being correctly released from
# the software keyboard on Android. Without this the back
# button/gesture does not work after the soft-keyboard has
# appeared for the first time.
2022-10-19 14:59:42 -06:00
if RNS . vendor . platformutils . is_android ( ) :
2022-07-06 11:18:26 -06:00
BIND_CLASSES = [ " kivymd.uix.textfield.textfield.MDTextField " , ]
for e in self . root . ids :
te = self . root . ids [ e ]
ts = str ( te ) . split ( " " ) [ 0 ] . replace ( " < " , " " )
if ts in BIND_CLASSES :
te . bind ( focus = self . android_focus_fix )
2022-07-06 08:08:53 -06:00
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . app = self
self . root . ids . app_version_info . text = " Sideband v " + __version__ + " " + __variant__
2022-10-08 10:41:59 -06:00
self . root . ids . nav_scrollview . effect_cls = ScrollEffect
2023-10-22 13:04:28 -06:00
Clock . schedule_once ( self . start_core , 0.25 )
2022-07-06 11:18:26 -06:00
# Part of the focus hack fix
def android_focus_fix ( self , sender , val ) :
if not val :
@run_on_ui_thread
def fix_back_button ( ) :
2022-10-19 14:59:42 -06:00
self . sideband . setstate ( " flag.focusfix_pause " , True )
self . sideband . setstate ( " flag.focusfix_resume " , True )
2022-07-06 11:18:26 -06:00
activity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
activity . onWindowFocusChanged ( False )
activity . onWindowFocusChanged ( True )
fix_back_button ( )
2022-07-06 08:08:53 -06:00
def keydown_event ( self , instance , keyboard , keycode , text , modifiers ) :
2022-10-11 09:49:12 -06:00
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " q " ) :
2022-07-06 08:08:53 -06:00
self . quit_action ( self )
2022-10-11 09:49:12 -06:00
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " w " ) :
if self . root . ids . screen_manager . current == " conversations_screen " :
self . quit_action ( self )
2023-10-23 17:14:59 -06:00
elif self . root . ids . screen_manager . current == " object_details_screen " :
self . object_details_screen . close_action ( )
2022-10-11 09:49:12 -06:00
else :
2023-10-19 18:41:05 -06:00
self . open_conversations ( direction = " right " )
2022-07-06 09:02:29 -06:00
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " s " or text == " d " ) :
if self . root . ids . screen_manager . current == " messages_screen " :
self . message_send_action ( )
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " l " ) :
self . announces_action ( self )
2023-10-20 15:38:28 -06:00
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " m " ) :
self . map_action ( self )
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " t " ) :
self . telemetry_action ( self )
2022-10-06 09:12:42 -06:00
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " r " ) :
self . conversations_action ( self )
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " g " ) :
self . guide_action ( self )
2022-07-06 09:02:29 -06:00
if len ( modifiers ) > 0 and modifiers [ 0 ] == ' ctrl ' and ( text == " n " ) :
if self . root . ids . screen_manager . current == " conversations_screen " :
if not hasattr ( self , " dialog_open " ) or not self . dialog_open :
self . new_conversation_action ( self )
2022-07-06 08:08:53 -06:00
def keyboard_event ( self , window , key , * largs ) :
# Handle escape/back
if key == 27 :
if self . root . ids . screen_manager . current == " conversations_screen " :
if time . time ( ) - self . last_exit_event < 2 :
self . quit_action ( self )
else :
self . last_exit_event = time . time ( )
else :
2022-11-03 16:00:34 -06:00
if self . root . ids . screen_manager . current == " hardware_rnode_screen " :
self . close_sub_hardware_action ( )
elif self . root . ids . screen_manager . current == " hardware_modem_screen " :
self . close_sub_hardware_action ( )
elif self . root . ids . screen_manager . current == " hardware_serial_screen " :
self . close_sub_hardware_action ( )
2023-10-23 17:14:59 -06:00
if self . root . ids . screen_manager . current == " object_details_screen " :
self . object_details_screen . close_action ( )
2022-11-03 16:00:34 -06:00
else :
self . open_conversations ( direction = " right " )
2022-07-06 08:08:53 -06:00
return True
2022-04-07 13:03:53 -06:00
def widget_hide ( self , w , hide = True ) :
if hasattr ( w , " saved_attrs " ) :
if not hide :
w . height , w . size_hint_y , w . opacity , w . disabled = w . saved_attrs
del w . saved_attrs
elif hide :
w . saved_attrs = w . height , w . size_hint_y , w . opacity , w . disabled
w . height , w . size_hint_y , w . opacity , w . disabled = 0 , None , 0 , True
def quit_action ( self , sender ) :
2022-09-17 09:21:16 -06:00
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . should_persist_data ( )
2023-10-22 07:49:00 -06:00
if not self . root . ids . screen_manager . has_screen ( " exit_screen " ) :
self . exit_screen = Builder . load_string ( layout_exit_screen )
self . root . ids . screen_manager . add_widget ( self . exit_screen )
2022-10-07 09:22:03 -06:00
self . root . ids . screen_manager . transition = NoTransition ( )
self . root . ids . screen_manager . current = " exit_screen "
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.running " , False )
self . sideband . setstate ( " app.foreground " , False )
2022-09-17 09:21:16 -06:00
def final_exit ( dt ) :
2022-10-01 18:26:58 -06:00
RNS . log ( " Stopping service... " )
self . sideband . setstate ( " wants.service_stop " , True )
while self . sideband . service_available ( ) :
time . sleep ( 0.2 )
RNS . log ( " Service stopped " )
2022-10-19 09:53:26 -06:00
if RNS . vendor . platformutils . is_android ( ) :
RNS . log ( " Finishing activity " )
activity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
activity . finishAndRemoveTask ( )
else :
RNS . exit ( )
MDApp . get_running_app ( ) . stop ( )
Window . close ( )
2022-09-17 09:21:16 -06:00
2022-11-23 10:57:53 -07:00
Clock . schedule_once ( final_exit , 0.85 )
2022-04-07 13:03:53 -06:00
def announce_now_action ( self , sender = None ) :
self . sideband . lxmf_announce ( )
2022-10-13 14:12:39 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-09 08:48:09 -06:00
2022-04-07 13:03:53 -06:00
dialog = MDDialog (
2022-10-09 08:48:09 -06:00
title = " Announce Sent " ,
text = " Your LXMF address has been announced on all available interfaces " ,
2022-04-07 13:03:53 -06:00
buttons = [ yes_button ] ,
2022-10-02 16:47:27 -06:00
# elevation=0,
2022-04-07 13:03:53 -06:00
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
#################################################
# Screens #
#################################################
### Messages (conversation) screen
######################################
def conversation_from_announce_action ( self , context_dest ) :
if self . sideband . has_conversation ( context_dest ) :
pass
else :
self . sideband . create_conversation ( context_dest )
2022-10-06 08:40:30 -06:00
self . sideband . setstate ( " app.flags.new_conversations " , True )
2022-04-07 13:03:53 -06:00
self . open_conversation ( context_dest )
def conversation_action ( self , sender ) :
2022-10-13 15:04:30 -06:00
def cb ( dt ) :
self . open_conversation ( sender . sb_uid )
2022-11-23 02:38:56 -07:00
def cbu ( dt ) :
self . conversations_view . update ( )
2022-10-13 15:04:30 -06:00
Clock . schedule_once ( cb , 0.15 )
2022-11-23 02:38:56 -07:00
Clock . schedule_once ( cbu , 0.15 + 0.25 )
2022-04-07 13:03:53 -06:00
2023-10-23 17:14:59 -06:00
def open_conversation ( self , context_dest , direction = " left " ) :
2022-11-22 06:25:56 -07:00
self . outbound_mode_paper = False
2022-04-07 13:03:53 -06:00
if self . sideband . config [ " propagation_by_default " ] :
self . outbound_mode_propagation = True
else :
self . outbound_mode_propagation = False
2023-10-23 17:14:59 -06:00
self . root . ids . screen_manager . transition . direction = direction
2022-04-07 13:03:53 -06:00
self . messages_view = Messages ( self , context_dest )
2023-10-22 10:08:28 -06:00
self . messages_view . ids . messages_scrollview . effect_cls = ScrollEffect
for child in self . messages_view . ids . messages_scrollview . children :
self . messages_view . ids . messages_scrollview . remove_widget ( child )
2022-04-07 13:03:53 -06:00
list_widget = self . messages_view . get_widget ( )
2023-10-22 10:08:28 -06:00
self . messages_view . ids . messages_scrollview . add_widget ( list_widget )
self . messages_view . ids . messages_scrollview . scroll_y = 0.0
2022-10-08 10:01:33 -06:00
2023-10-22 10:08:28 -06:00
self . messages_view . ids . messages_toolbar . title = self . sideband . peer_display_name ( context_dest )
self . messages_view . ids . messages_scrollview . active_conversation = context_dest
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.active_conversation " , context_dest )
2022-04-07 13:03:53 -06:00
2023-10-22 10:08:28 -06:00
self . messages_view . ids . nokeys_text . text = " "
2022-04-07 13:03:53 -06:00
self . message_area_detect ( )
self . update_message_widgets ( )
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_text . disabled = False
2022-10-08 10:13:24 -06:00
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . current = " messages_screen "
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-04-07 13:03:53 -06:00
self . sideband . read_conversation ( context_dest )
2022-10-06 08:40:30 -06:00
self . sideband . setstate ( " app.flags.unread_conversations " , True )
2022-04-07 13:03:53 -06:00
2022-11-23 11:15:24 -07:00
def scb ( dt ) :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . messages_scrollview . scroll_y = 0.0
2022-11-23 11:15:24 -07:00
Clock . schedule_once ( scb , 0.33 )
2022-04-07 13:03:53 -06:00
def close_messages_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
def message_send_action ( self , sender = None ) :
2023-10-22 10:08:28 -06:00
if self . messages_view . ids . message_text . text == " " :
2022-10-08 12:03:01 -06:00
return
2022-10-08 13:12:36 -06:00
2022-10-08 10:13:24 -06:00
def cb ( dt ) :
self . message_send_dispatch ( sender )
Clock . schedule_once ( cb , 0.20 )
def message_send_dispatch ( self , sender = None ) :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_send_button . disabled = True
2022-04-07 13:03:53 -06:00
if self . root . ids . screen_manager . current == " messages_screen " :
if self . outbound_mode_propagation and self . sideband . message_router . get_outbound_propagation_node ( ) == None :
self . messages_view . send_error_dialog = MDDialog (
2022-10-13 14:12:39 -06:00
title = " Error " ,
text = " Propagated delivery was requested, but no active LXMF propagation nodes were found. Cannot send message. \n \n Wait for a Propagation Node to announce on the network, or manually specify one in the settings. " ,
2022-04-07 13:03:53 -06:00
buttons = [
2022-10-13 14:12:39 -06:00
MDRectangleFlatButton (
2022-04-07 13:03:53 -06:00
text = " OK " ,
2022-10-13 14:12:39 -06:00
font_size = dp ( 18 ) ,
2022-04-07 13:03:53 -06:00
on_release = self . messages_view . close_send_error_dialog
)
] ,
2022-10-02 16:56:39 -06:00
# elevation=0,
2022-04-07 13:03:53 -06:00
)
self . messages_view . send_error_dialog . open ( )
else :
2023-10-22 10:08:28 -06:00
msg_content = self . messages_view . ids . message_text . text
context_dest = self . messages_view . ids . messages_scrollview . active_conversation
2022-11-22 06:25:56 -07:00
if self . outbound_mode_paper :
if self . sideband . paper_message ( msg_content , context_dest ) :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_text . text = " "
self . messages_view . ids . messages_scrollview . scroll_y = 0
2022-11-22 06:25:56 -07:00
self . jobs ( 0 )
elif self . sideband . send_message ( msg_content , context_dest , self . outbound_mode_propagation ) :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_text . text = " "
self . messages_view . ids . messages_scrollview . scroll_y = 0
2022-04-07 13:03:53 -06:00
self . jobs ( 0 )
2022-11-22 06:25:56 -07:00
2022-04-07 13:03:53 -06:00
else :
self . messages_view . send_error_dialog = MDDialog (
2022-10-13 14:12:39 -06:00
title = " Error " ,
text = " Could not send the message " ,
2022-04-07 13:03:53 -06:00
buttons = [
2022-10-13 14:12:39 -06:00
MDRectangleFlatButton (
2022-04-07 13:03:53 -06:00
text = " OK " ,
2022-10-13 14:12:39 -06:00
font_size = dp ( 18 ) ,
2022-04-07 13:03:53 -06:00
on_release = self . messages_view . close_send_error_dialog
)
] ,
)
self . messages_view . send_error_dialog . open ( )
2022-10-08 10:13:24 -06:00
def cb ( dt ) :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_send_button . disabled = False
2022-10-08 10:13:24 -06:00
Clock . schedule_once ( cb , 0.5 )
2023-10-21 17:12:55 -06:00
def peer_show_location_action ( self , sender ) :
if self . root . ids . screen_manager . current == " messages_screen " :
2023-10-22 10:08:28 -06:00
context_dest = self . messages_view . ids . messages_scrollview . active_conversation
2023-10-21 17:12:55 -06:00
self . map_show_peer_location ( context_dest )
2023-10-23 17:14:59 -06:00
def peer_show_telemetry_action ( self , sender ) :
if self . root . ids . screen_manager . current == " messages_screen " :
self . object_details_action ( self . messages_view , from_conv = True )
2022-04-07 13:03:53 -06:00
def message_propagation_action ( self , sender ) :
2022-11-22 06:25:56 -07:00
if self . outbound_mode_paper :
self . outbound_mode_paper = False
2022-04-07 13:03:53 -06:00
self . outbound_mode_propagation = False
else :
2022-11-22 06:25:56 -07:00
if self . outbound_mode_propagation :
self . outbound_mode_paper = True
self . outbound_mode_propagation = False
else :
self . outbound_mode_propagation = True
self . outbound_mode_paper = False
2022-04-07 13:03:53 -06:00
self . update_message_widgets ( )
def update_message_widgets ( self ) :
2023-10-22 10:08:28 -06:00
toolbar_items = self . messages_view . ids . messages_toolbar . ids . right_actions . children
2022-04-07 13:03:53 -06:00
mode_item = toolbar_items [ 1 ]
2022-11-22 06:25:56 -07:00
if self . outbound_mode_paper :
mode_item . icon = " qrcode "
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_text . hint_text = " Paper message "
2022-04-07 13:03:53 -06:00
else :
2022-11-22 06:25:56 -07:00
if not self . outbound_mode_propagation :
mode_item . icon = " lan-connect "
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_text . hint_text = " Message for direct delivery "
2022-11-22 06:25:56 -07:00
else :
mode_item . icon = " upload-network "
2023-10-22 10:08:28 -06:00
self . messages_view . ids . message_text . hint_text = " Message for propagation "
2022-11-22 06:25:56 -07:00
# self.root.ids.message_text.hint_text = "Write message for delivery via propagation nodes"
2022-04-07 13:03:53 -06:00
def key_query_action ( self , sender ) :
2023-10-22 10:08:28 -06:00
context_dest = self . messages_view . ids . messages_scrollview . active_conversation
2022-04-07 13:03:53 -06:00
if self . sideband . request_key ( context_dest ) :
keys_str = " Public key information for " + RNS . prettyhexrep ( context_dest ) + " was requested from the network. Waiting for request to be answered. "
2023-10-22 10:08:28 -06:00
self . messages_view . ids . nokeys_text . text = keys_str
2022-04-07 13:03:53 -06:00
else :
keys_str = " Could not send request. Check your connectivity and addresses. "
2023-10-22 10:08:28 -06:00
self . messages_view . ids . nokeys_text . text = keys_str
2022-04-07 13:03:53 -06:00
def message_area_detect ( self ) :
2023-10-22 10:08:28 -06:00
context_dest = self . messages_view . ids . messages_scrollview . active_conversation
2022-04-07 13:03:53 -06:00
if self . sideband . is_known ( context_dest ) :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . messages_scrollview . dest_known = True
self . widget_hide ( self . messages_view . ids . message_input_part , False )
self . widget_hide ( self . messages_view . ids . no_keys_part , True )
2022-04-07 13:03:53 -06:00
else :
2023-10-22 10:08:28 -06:00
self . messages_view . ids . messages_scrollview . dest_known = False
if self . messages_view . ids . nokeys_text . text == " " :
2022-04-07 13:03:53 -06:00
keys_str = " The crytographic keys for the destination address are unknown at this time. You can wait for an announce to arrive, or query the network for the necessary keys. "
2023-10-22 10:08:28 -06:00
self . messages_view . ids . nokeys_text . text = keys_str
self . widget_hide ( self . messages_view . ids . message_input_part , True )
self . widget_hide ( self . messages_view . ids . no_keys_part , False )
2022-04-07 13:03:53 -06:00
### Conversations screen
######################################
def conversations_action ( self , sender = None ) :
self . open_conversations ( )
def open_conversations ( self , direction = " left " ) :
self . root . ids . screen_manager . transition . direction = direction
self . root . ids . nav_drawer . set_state ( " closed " )
2022-10-06 08:40:30 -06:00
if not self . conversations_view :
self . conversations_view = Conversations ( self )
2022-04-07 13:03:53 -06:00
2023-10-22 07:49:00 -06:00
for child in self . conversations_view . ids . conversations_scrollview . children :
self . conversations_view . ids . conversations_scrollview . remove_widget ( child )
2022-04-07 13:03:53 -06:00
2023-10-22 07:49:00 -06:00
self . conversations_view . ids . conversations_scrollview . effect_cls = ScrollEffect
self . conversations_view . ids . conversations_scrollview . add_widget ( self . conversations_view . get_widget ( ) )
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . current = " conversations_screen "
2023-10-22 07:49:00 -06:00
if self . messages_view :
self . messages_view . ids . messages_scrollview . active_conversation = None
2022-10-19 10:59:04 -06:00
def cb ( dt ) :
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
self . sideband . setstate ( " wants.clear_notifications " , True )
Clock . schedule_once ( cb , 0.10 )
2022-04-07 13:03:53 -06:00
2022-11-03 15:55:35 -06:00
def get_connectivity_text ( self ) :
2022-07-06 08:08:53 -06:00
connectivity_status = " "
if RNS . vendor . platformutils . get_platform ( ) == " android " :
2022-10-02 12:43:56 -06:00
connectivity_status = self . sideband . getstate ( " service.connectivity_status " )
2022-07-06 08:08:53 -06:00
else :
if self . sideband . reticulum . is_connected_to_shared_instance :
2022-11-23 02:38:56 -07:00
connectivity_status = " Sideband is connected via a shared Reticulum instance running on this system. Use the rnstatus utility to obtain full connectivity info. "
2022-07-06 08:08:53 -06:00
else :
2022-11-23 02:38:56 -07:00
connectivity_status = " Sideband is currently running a standalone or master Reticulum instance on this system. Use the rnstatus utility to obtain full connectivity info. "
2022-07-06 08:08:53 -06:00
2022-11-03 15:55:35 -06:00
return connectivity_status
def connectivity_status ( self , sender ) :
hs = dp ( 22 )
2022-10-13 15:36:41 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-07-06 08:08:53 -06:00
dialog = MDDialog (
2022-11-23 02:38:56 -07:00
title = " Connectivity Status " ,
2022-11-03 15:55:35 -06:00
text = self . get_connectivity_text ( ) ,
2022-07-06 08:08:53 -06:00
buttons = [ yes_button ] ,
2022-10-02 16:56:39 -06:00
# elevation=0,
2022-07-06 08:08:53 -06:00
)
2022-11-03 15:55:35 -06:00
def cs_updater ( dt ) :
dialog . text = self . get_connectivity_text ( )
2022-07-06 08:08:53 -06:00
def dl_yes ( s ) :
2022-11-03 15:55:35 -06:00
self . connectivity_updater . cancel ( )
2022-07-06 08:08:53 -06:00
dialog . dismiss ( )
2022-11-23 10:57:53 -07:00
if self . connectivity_updater != None :
self . connectivity_updater . cancel ( )
2022-11-03 15:55:35 -06:00
2022-07-06 08:08:53 -06:00
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
2022-11-23 10:57:53 -07:00
2022-11-03 15:55:35 -06:00
if self . connectivity_updater != None :
self . connectivity_updater . cancel ( )
2022-11-23 10:57:53 -07:00
self . connectivity_updater = Clock . schedule_interval ( cs_updater , 2.0 )
2022-11-03 15:55:35 -06:00
2022-11-22 06:25:56 -07:00
def ingest_lxm_action ( self , sender ) :
def cb ( dt ) :
self . open_ingest_lxm_dialog ( sender )
Clock . schedule_once ( cb , 0.15 )
def open_ingest_lxm_dialog ( self , sender = None ) :
try :
cancel_button = MDRectangleFlatButton ( text = " Cancel " , font_size = dp ( 18 ) )
ingest_button = MDRectangleFlatButton ( text = " Read LXM " , font_size = dp ( 18 ) , theme_text_color = " Custom " , line_color = self . color_accept , text_color = self . color_accept )
dialog = MDDialog (
title = " Ingest Paper Message " ,
text = " You can read LXMF paper messages into this program by scanning a QR-code containing the message with your device camera or QR-scanner app, and then opening the resulting link in Sideband. \n \n Alternatively, you can copy an [b]lxm://[/b] link from any source to your clipboard, and ingest it using the [i]Read LXM[/i] button below. " ,
buttons = [ ingest_button , cancel_button ] ,
)
def dl_yes ( s ) :
try :
lxm_uri = Clipboard . paste ( )
if not lxm_uri . lower ( ) . startswith ( LXMF . LXMessage . URI_SCHEMA + " :// " ) :
lxm_uri = LXMF . LXMessage . URI_SCHEMA + " :// " + lxm_uri
self . ingest_lxm_uri ( lxm_uri )
dialog . dismiss ( )
except Exception as e :
response = " Error ingesting message from URI: " + str ( e )
RNS . log ( response , RNS . LOG_ERROR )
self . sideband . setstate ( " lxm_uri_ingest.result " , response )
dialog . dismiss ( )
def dl_no ( s ) :
dialog . dismiss ( )
def dl_ds ( s ) :
self . dialog_open = False
ingest_button . bind ( on_release = dl_yes )
cancel_button . bind ( on_release = dl_no )
2022-11-03 15:55:35 -06:00
2022-11-22 06:25:56 -07:00
dialog . bind ( on_dismiss = dl_ds )
dialog . open ( )
self . dialog_open = True
except Exception as e :
RNS . log ( " Error while creating ingest LXM dialog: " + str ( e ) , RNS . LOG_ERROR )
2022-07-06 08:08:53 -06:00
2022-04-07 13:03:53 -06:00
def lxmf_sync_action ( self , sender ) :
2022-10-13 15:04:30 -06:00
def cb ( dt ) :
self . lxmf_sync_request ( sender )
Clock . schedule_once ( cb , 0.15 )
def lxmf_sync_request ( self , sender ) :
2022-04-07 13:03:53 -06:00
if self . sideband . message_router . get_outbound_propagation_node ( ) == None :
2022-10-13 15:36:41 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-04-07 13:03:53 -06:00
dialog = MDDialog (
2022-10-19 09:53:26 -06:00
title = " Can ' t Sync " ,
2022-04-07 13:03:53 -06:00
text = " No active LXMF propagation nodes were found. Cannot fetch messages. Wait for a Propagation Node to announce on the network, or manually specify one in the settings. " ,
buttons = [ yes_button ] ,
2022-10-02 16:56:39 -06:00
# elevation=0,
2022-04-07 13:03:53 -06:00
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
else :
if self . sideband . config [ " lxmf_sync_limit " ] :
sl = self . sideband . config [ " lxmf_sync_max " ]
else :
sl = None
2022-10-08 14:47:08 -06:00
self . sideband . setpersistent ( " lxmf.lastsync " , time . time ( ) )
self . sideband . setpersistent ( " lxmf.syncretrying " , False )
2022-04-07 13:03:53 -06:00
self . sideband . request_lxmf_sync ( limit = sl )
2022-10-13 14:12:39 -06:00
close_button = MDRectangleFlatButton ( text = " Close " , font_size = dp ( 18 ) )
stop_button = MDRectangleFlatButton ( text = " Stop " , font_size = dp ( 18 ) , theme_text_color = " Custom " , line_color = self . color_reject , text_color = self . color_reject )
2022-04-07 13:03:53 -06:00
dialog_content = MsgSync ( )
dialog = MDDialog (
title = " LXMF Sync via " + RNS . prettyhexrep ( self . sideband . message_router . get_outbound_propagation_node ( ) ) ,
type = " custom " ,
content_cls = dialog_content ,
2022-10-08 14:47:08 -06:00
buttons = [ stop_button , close_button ] ,
2022-10-02 16:56:39 -06:00
# elevation=0,
2022-04-07 13:03:53 -06:00
)
dialog . d_content = dialog_content
def dl_close ( s ) :
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.flags.lxmf_sync_dialog_open " , False )
2022-04-07 13:03:53 -06:00
dialog . dismiss ( )
2022-10-08 14:47:08 -06:00
# self.sideband.cancel_lxmf_sync()
def dl_stop ( s ) :
# self.sideband.setstate("app.flags.lxmf_sync_dialog_open", False)
# dialog.dismiss()
2022-04-07 13:03:53 -06:00
self . sideband . cancel_lxmf_sync ( )
2022-10-08 14:47:08 -06:00
def cb ( dt ) :
self . widget_hide ( self . sync_dialog . stop_button , True )
Clock . schedule_once ( cb , 0.25 )
2022-04-07 13:03:53 -06:00
close_button . bind ( on_release = dl_close )
2022-10-08 14:47:08 -06:00
stop_button . bind ( on_release = dl_stop )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.flags.lxmf_sync_dialog_open " , True )
2022-04-07 13:03:53 -06:00
self . sync_dialog = dialog_content
2022-10-08 14:47:08 -06:00
self . sync_dialog . stop_button = stop_button
2022-04-07 13:03:53 -06:00
dialog . open ( )
dialog_content . ids . sync_progress . value = self . sideband . get_sync_progress ( ) * 100
dialog_content . ids . sync_status . text = self . sideband . get_sync_status ( )
def new_conversation_action ( self , sender = None ) :
2022-10-13 15:04:30 -06:00
def cb ( dt ) :
self . new_conversation_request ( sender )
Clock . schedule_once ( cb , 0.15 )
def new_conversation_request ( self , sender = None ) :
2022-04-07 13:03:53 -06:00
try :
2022-10-13 14:12:39 -06:00
cancel_button = MDRectangleFlatButton ( text = " Cancel " , font_size = dp ( 18 ) )
create_button = MDRectangleFlatButton ( text = " Create " , font_size = dp ( 18 ) , theme_text_color = " Custom " , line_color = self . color_accept , text_color = self . color_accept )
2022-10-08 16:52:36 -06:00
2022-04-07 13:03:53 -06:00
dialog_content = NewConv ( )
dialog = MDDialog (
title = " New Conversation " ,
type = " custom " ,
content_cls = dialog_content ,
2022-10-08 16:52:36 -06:00
buttons = [ create_button , cancel_button ] ,
2022-10-02 16:56:39 -06:00
# elevation=0,
2022-04-07 13:03:53 -06:00
)
dialog . d_content = dialog_content
def dl_yes ( s ) :
new_result = False
try :
n_address = dialog . d_content . ids [ " n_address_field " ] . text
n_name = dialog . d_content . ids [ " n_name_field " ] . text
n_trusted = dialog . d_content . ids [ " n_trusted " ] . active
new_result = self . sideband . new_conversation ( n_address , n_name , n_trusted )
except Exception as e :
RNS . log ( " Error while creating conversation: " + str ( e ) , RNS . LOG_ERROR )
if new_result :
dialog . d_content . ids [ " n_address_field " ] . error = False
dialog . dismiss ( )
2022-10-08 16:52:36 -06:00
if self . conversations_view != None :
self . conversations_view . update ( )
2022-04-07 13:03:53 -06:00
else :
dialog . d_content . ids [ " n_address_field " ] . error = True
# dialog.d_content.ids["n_error_field"].text = "Could not create conversation. Check your input."
def dl_no ( s ) :
dialog . dismiss ( )
2022-07-06 09:02:29 -06:00
def dl_ds ( s ) :
self . dialog_open = False
2022-10-08 16:52:36 -06:00
create_button . bind ( on_release = dl_yes )
cancel_button . bind ( on_release = dl_no )
2022-07-06 09:02:29 -06:00
dialog . bind ( on_dismiss = dl_ds )
2022-04-07 13:03:53 -06:00
dialog . open ( )
2022-07-06 09:02:29 -06:00
self . dialog_open = True
2022-04-07 13:03:53 -06:00
except Exception as e :
RNS . log ( " Error while creating new conversation dialog: " + str ( e ) , RNS . LOG_ERROR )
### Information/version screen
######################################
def information_action ( self , sender = None ) :
2023-10-22 09:14:32 -06:00
if not self . root . ids . screen_manager . has_screen ( " information_screen " ) :
self . information_screen = Builder . load_string ( layout_information_screen )
self . information_screen . app = self
self . root . ids . screen_manager . add_widget ( self . information_screen )
2022-04-07 13:03:53 -06:00
def link_exec ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
def lj ( ) :
import webbrowser
webbrowser . open ( " https://unsigned.io/donate " )
2023-10-23 17:14:59 -06:00
threading . Thread ( target = lj , daemon = True ) . start ( )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . information_screen . ids . information_scrollview . effect_cls = ScrollEffect
self . information_screen . ids . information_logo . icon = self . sideband . asset_dir + " /rns_256.png "
2022-10-19 14:25:20 -06:00
2023-10-20 15:38:28 -06:00
info = " This is Sideband v " + __version__ + " " + __variant__ + " , on RNS v " + RNS . __version__ + " and LXMF v " + LXMF . __version__ + " . \n \n Humbly build using the following open components: \n \n - [b]Reticulum[/b] (MIT License) \n - [b]LXMF[/b] (MIT License) \n - [b]KivyMD[/b] (MIT License) \n - [b]Kivy[/b] (MIT License) \n - [b]Python[/b] (PSF License) " + " \n \n Go to [u][ref=link]https://unsigned.io/donate[/ref][/u] to support the project. \n \n The Sideband app is Copyright (c) 2022 Mark Qvist / unsigned.io \n \n Permission is granted to freely share and distribute binary copies of Sideband v " + __version__ + " " + __variant__ + " , so long as no payment or compensation is charged for said distribution or sharing. \n \n If you were charged or paid anything for this copy of Sideband, please report it to [b]license@unsigned.io[/b]. \n \n THIS IS EXPERIMENTAL SOFTWARE - SIDEBAND COMES WITH ABSOLUTELY NO WARRANTY - USE AT YOUR OWN RISK AND RESPONSIBILITY "
2023-10-22 09:14:32 -06:00
self . information_screen . ids . information_info . text = info
self . information_screen . ids . information_info . bind ( on_ref_press = link_exec )
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " information_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
def close_information_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
### Settings screen
######################################
2022-04-07 13:03:53 -06:00
def settings_action ( self , sender = None ) :
2022-11-23 10:57:53 -07:00
self . settings_init ( )
self . root . ids . screen_manager . transition . direction = " left "
2022-10-06 09:12:42 -06:00
self . root . ids . nav_drawer . set_state ( " closed " )
2022-12-15 09:01:10 -07:00
if self . sideband . active_propagation_node != None :
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_propagation_node_address . text = RNS . hexrep ( self . sideband . active_propagation_node , delimit = False )
2022-11-23 10:57:53 -07:00
self . root . ids . screen_manager . current = " settings_screen "
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-10-06 09:12:42 -06:00
def settings_init ( self , sender = None ) :
if not self . settings_ready :
2023-10-22 09:14:32 -06:00
if not self . root . ids . screen_manager . has_screen ( " settings_screen " ) :
self . settings_screen = Builder . load_string ( layout_settings_screen )
self . settings_screen . app = self
self . root . ids . screen_manager . add_widget ( self . settings_screen )
self . settings_screen . ids . settings_scrollview . effect_cls = ScrollEffect
2022-11-23 03:28:02 -07:00
2022-10-06 09:12:42 -06:00
def save_disp_name ( sender = None , event = None ) :
2022-11-23 03:28:02 -07:00
if not sender . focus :
2023-10-22 09:14:32 -06:00
in_name = self . settings_screen . ids . settings_display_name . text
2022-11-23 03:28:02 -07:00
if in_name == " " :
new_name = " Anonymous Peer "
else :
new_name = in_name
2022-04-07 13:03:53 -06:00
2022-11-23 03:28:02 -07:00
self . sideband . config [ " display_name " ] = new_name
self . sideband . save_configuration ( )
2022-04-07 13:03:53 -06:00
2022-10-06 09:12:42 -06:00
def save_prop_addr ( sender = None , event = None ) :
2022-11-23 03:28:02 -07:00
if not sender . focus :
2023-10-22 09:14:32 -06:00
in_addr = self . settings_screen . ids . settings_propagation_node_address . text
2022-04-07 13:03:53 -06:00
new_addr = None
2022-11-23 03:28:02 -07:00
if in_addr == " " :
2022-04-07 13:03:53 -06:00
new_addr = None
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_propagation_node_address . error = False
2022-10-06 09:12:42 -06:00
else :
2022-11-23 03:28:02 -07:00
if len ( in_addr ) != RNS . Reticulum . TRUNCATED_HASHLENGTH / / 8 * 2 :
2022-10-06 09:12:42 -06:00
new_addr = None
2022-11-23 03:28:02 -07:00
else :
try :
new_addr = bytes . fromhex ( in_addr )
except Exception as e :
new_addr = None
2022-04-07 13:03:53 -06:00
2022-11-23 03:28:02 -07:00
if new_addr == None :
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_propagation_node_address . error = True
2022-11-23 03:28:02 -07:00
else :
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_propagation_node_address . error = False
2022-04-07 13:03:53 -06:00
2022-11-23 03:28:02 -07:00
self . sideband . config [ " lxmf_propagation_node " ] = new_addr
self . sideband . set_active_propagation_node ( self . sideband . config [ " lxmf_propagation_node " ] )
2022-10-02 06:03:56 -06:00
2022-10-06 09:12:42 -06:00
def save_dark_ui ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " dark_ui " ] = self . settings_screen . ids . settings_dark_ui . active
2022-10-06 09:12:42 -06:00
self . sideband . save_configuration ( )
self . update_ui_theme ( )
2022-04-07 13:03:53 -06:00
2023-10-07 08:54:38 -06:00
def save_eink_mode ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " eink_mode " ] = self . settings_screen . ids . settings_eink_mode . active
2023-10-07 08:54:38 -06:00
self . sideband . save_configuration ( )
self . update_ui_theme ( )
2023-10-21 17:12:55 -06:00
def save_advanced_stats ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " advanced_stats " ] = self . settings_screen . ids . settings_advanced_statistics . active
2023-10-21 17:12:55 -06:00
self . sideband . save_configuration ( )
2022-10-08 16:30:58 -06:00
def save_notifications_on ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " notifications_on " ] = self . settings_screen . ids . settings_notifications_on . active
2022-10-08 16:30:58 -06:00
self . sideband . save_configuration ( )
2022-10-06 09:12:42 -06:00
def save_start_announce ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " start_announce " ] = self . settings_screen . ids . settings_start_announce . active
2022-10-06 09:12:42 -06:00
self . sideband . save_configuration ( )
2022-04-07 13:03:53 -06:00
2022-10-06 09:12:42 -06:00
def save_lxmf_delivery_by_default ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " propagation_by_default " ] = self . settings_screen . ids . settings_lxmf_delivery_by_default . active
2022-10-06 09:12:42 -06:00
self . sideband . save_configuration ( )
2022-04-07 13:03:53 -06:00
2023-09-20 12:26:19 -06:00
def save_lxmf_ignore_unknown ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " lxmf_ignore_unknown " ] = self . settings_screen . ids . settings_lxmf_ignore_unknown . active
2023-09-20 12:26:19 -06:00
self . sideband . save_configuration ( )
2022-10-06 09:12:42 -06:00
def save_lxmf_sync_limit ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " lxmf_sync_limit " ] = self . settings_screen . ids . settings_lxmf_sync_limit . active
2022-10-06 09:12:42 -06:00
self . sideband . save_configuration ( )
2022-04-07 13:03:53 -06:00
2022-12-18 18:06:41 -07:00
def save_debug ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " debug " ] = self . settings_screen . ids . settings_debug . active
2022-12-18 18:06:41 -07:00
self . sideband . save_configuration ( )
2022-11-22 06:25:56 -07:00
def save_print_command ( sender = None , event = None ) :
2022-11-23 03:28:02 -07:00
if not sender . focus :
2023-10-22 09:14:32 -06:00
in_cmd = self . settings_screen . ids . settings_print_command . text
2022-11-23 03:28:02 -07:00
if in_cmd == " " :
new_cmd = " lp "
else :
new_cmd = in_cmd
2022-11-22 06:25:56 -07:00
2022-11-23 03:28:02 -07:00
self . sideband . config [ " print_command " ] = new_cmd . strip ( )
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_print_command . text = self . sideband . config [ " print_command " ]
2022-11-23 03:28:02 -07:00
self . sideband . save_configuration ( )
2022-11-22 06:25:56 -07:00
2022-10-08 13:12:36 -06:00
def save_lxmf_periodic_sync ( sender = None , event = None , save = True ) :
2023-10-22 09:14:32 -06:00
if self . settings_screen . ids . settings_lxmf_periodic_sync . active :
self . widget_hide ( self . settings_screen . ids . lxmf_syncslider_container , False )
2022-10-08 13:12:36 -06:00
else :
2023-10-22 09:14:32 -06:00
self . widget_hide ( self . settings_screen . ids . lxmf_syncslider_container , True )
2022-10-08 13:12:36 -06:00
if save :
2023-10-22 09:14:32 -06:00
self . sideband . config [ " lxmf_periodic_sync " ] = self . settings_screen . ids . settings_lxmf_periodic_sync . active
2022-10-08 13:12:36 -06:00
self . sideband . save_configuration ( )
def sync_interval_change ( sender = None , event = None , save = True ) :
2023-10-22 09:14:32 -06:00
interval = ( self . settings_screen . ids . settings_lxmf_sync_interval . value / / 300 ) * 300
2022-10-08 13:12:36 -06:00
interval_text = RNS . prettytime ( interval )
2023-10-22 09:14:32 -06:00
pre = self . settings_screen . ids . settings_lxmf_sync_periodic . text
self . settings_screen . ids . settings_lxmf_sync_periodic . text = " Auto sync every " + interval_text
2022-10-08 16:30:58 -06:00
if save :
self . sideband . config [ " lxmf_sync_interval " ] = interval
self . sideband . save_configuration ( )
2022-10-08 13:12:36 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_lxmf_address . text = RNS . hexrep ( self . sideband . lxmf_destination . hash , delimit = False )
self . settings_screen . ids . settings_identity_hash . text = RNS . hexrep ( self . sideband . lxmf_destination . identity . hash , delimit = False )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_display_name . text = self . sideband . config [ " display_name " ]
self . settings_screen . ids . settings_display_name . bind ( focus = save_disp_name )
2022-04-07 13:03:53 -06:00
2022-11-22 06:25:56 -07:00
if RNS . vendor . platformutils . is_android ( ) :
2023-10-22 17:26:44 -06:00
pass
# self.widget_hide(self.settings_screen.ids.settings_print_command, True)
2022-11-22 06:25:56 -07:00
else :
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_print_command . text = self . sideband . config [ " print_command " ]
self . settings_screen . ids . settings_print_command . bind ( focus = save_print_command )
2022-11-22 06:25:56 -07:00
2022-10-06 09:12:42 -06:00
if self . sideband . config [ " lxmf_propagation_node " ] == None :
prop_node_addr = " "
else :
prop_node_addr = RNS . hexrep ( self . sideband . config [ " lxmf_propagation_node " ] , delimit = False )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_propagation_node_address . text = prop_node_addr
self . settings_screen . ids . settings_propagation_node_address . bind ( focus = save_prop_addr )
2022-10-02 06:03:56 -06:00
2022-10-25 08:23:47 -06:00
if not RNS . vendor . platformutils . is_android ( ) or android_api_version > = 26 :
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_notifications_on . active = self . sideband . config [ " notifications_on " ]
self . settings_screen . ids . settings_notifications_on . bind ( active = save_notifications_on )
2022-10-20 07:36:29 -06:00
else :
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_notifications_on . active = False
self . settings_screen . ids . settings_notifications_on . disabled = True
2022-10-08 16:30:58 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_dark_ui . active = self . sideband . config [ " dark_ui " ]
self . settings_screen . ids . settings_dark_ui . bind ( active = save_dark_ui )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_eink_mode . active = self . sideband . config [ " eink_mode " ]
self . settings_screen . ids . settings_eink_mode . bind ( active = save_eink_mode )
2023-10-07 08:54:38 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_advanced_statistics . active = self . sideband . config [ " advanced_stats " ]
self . settings_screen . ids . settings_advanced_statistics . bind ( active = save_advanced_stats )
2023-10-21 17:12:55 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_start_announce . active = self . sideband . config [ " start_announce " ]
self . settings_screen . ids . settings_start_announce . bind ( active = save_start_announce )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_lxmf_delivery_by_default . active = self . sideband . config [ " propagation_by_default " ]
self . settings_screen . ids . settings_lxmf_delivery_by_default . bind ( active = save_lxmf_delivery_by_default )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_lxmf_ignore_unknown . active = self . sideband . config [ " lxmf_ignore_unknown " ]
self . settings_screen . ids . settings_lxmf_ignore_unknown . bind ( active = save_lxmf_ignore_unknown )
2023-09-20 12:26:19 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_lxmf_periodic_sync . active = self . sideband . config [ " lxmf_periodic_sync " ]
self . settings_screen . ids . settings_lxmf_periodic_sync . bind ( active = save_lxmf_periodic_sync )
2022-10-08 13:12:36 -06:00
save_lxmf_periodic_sync ( save = False )
2022-10-08 16:30:58 -06:00
def sync_interval_change_cb ( sender = None , event = None ) :
sync_interval_change ( sender = sender , event = event , save = False )
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_lxmf_sync_interval . bind ( value = sync_interval_change_cb )
self . settings_screen . ids . settings_lxmf_sync_interval . bind ( on_touch_up = sync_interval_change )
self . settings_screen . ids . settings_lxmf_sync_interval . value = self . sideband . config [ " lxmf_sync_interval " ]
2022-10-08 13:12:36 -06:00
sync_interval_change ( save = False )
2022-10-06 09:12:42 -06:00
if self . sideband . config [ " lxmf_sync_limit " ] == None or self . sideband . config [ " lxmf_sync_limit " ] == False :
sync_limit = False
else :
sync_limit = True
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_lxmf_sync_limit . active = sync_limit
self . settings_screen . ids . settings_lxmf_sync_limit . bind ( active = save_lxmf_sync_limit )
2022-12-18 18:06:41 -07:00
2023-10-22 09:14:32 -06:00
self . settings_screen . ids . settings_debug . active = self . sideband . config [ " debug " ]
self . settings_screen . ids . settings_debug . bind ( active = save_debug )
2022-12-18 18:06:41 -07:00
2022-10-06 09:12:42 -06:00
self . settings_ready = True
2022-04-07 13:03:53 -06:00
def close_settings_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2022-07-06 04:19:05 -06:00
### Connectivity screen
######################################
def connectivity_action ( self , sender = None ) :
2022-10-06 09:12:42 -06:00
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . nav_drawer . set_state ( " closed " )
2022-11-23 10:57:53 -07:00
self . connectivity_init ( )
self . root . ids . screen_manager . current = " connectivity_screen "
2022-10-06 09:12:42 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-07-06 05:07:11 -06:00
2022-10-06 09:12:42 -06:00
def connectivity_init ( self , sender = None ) :
if not self . connectivity_ready :
2023-10-22 09:44:44 -06:00
if not self . root . ids . screen_manager . has_screen ( " connectivity_screen " ) :
self . connectivity_screen = Builder . load_string ( layout_connectivity_screen )
self . connectivity_screen . app = self
self . root . ids . screen_manager . add_widget ( self . connectivity_screen )
self . connectivity_screen . ids . connectivity_scrollview . effect_cls = ScrollEffect
2022-10-06 09:12:42 -06:00
def con_hide_settings ( ) :
2023-10-22 09:44:44 -06:00
self . widget_hide ( self . connectivity_screen . ids . connectivity_use_local )
self . widget_hide ( self . connectivity_screen . ids . connectivity_local_groupid )
self . widget_hide ( self . connectivity_screen . ids . connectivity_local_ifac_netname )
self . widget_hide ( self . connectivity_screen . ids . connectivity_local_ifac_passphrase )
self . widget_hide ( self . connectivity_screen . ids . connectivity_use_tcp )
self . widget_hide ( self . connectivity_screen . ids . connectivity_tcp_host )
self . widget_hide ( self . connectivity_screen . ids . connectivity_tcp_port )
self . widget_hide ( self . connectivity_screen . ids . connectivity_tcp_ifac_netname )
self . widget_hide ( self . connectivity_screen . ids . connectivity_tcp_ifac_passphrase )
self . widget_hide ( self . connectivity_screen . ids . connectivity_use_i2p )
self . widget_hide ( self . connectivity_screen . ids . connectivity_i2p_b32 )
self . widget_hide ( self . connectivity_screen . ids . connectivity_i2p_ifac_netname )
self . widget_hide ( self . connectivity_screen . ids . connectivity_i2p_ifac_passphrase )
self . widget_hide ( self . connectivity_screen . ids . connectivity_tcp_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_local_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_i2p_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_rnode_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_rnode_ifac_netname )
self . widget_hide ( self . connectivity_screen . ids . connectivity_rnode_ifac_passphrase )
self . widget_hide ( self . connectivity_screen . ids . connectivity_use_rnode )
self . widget_hide ( self . connectivity_screen . ids . connectivity_modem_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_use_modem )
self . widget_hide ( self . connectivity_screen . ids . connectivity_modem_fields )
self . widget_hide ( self . connectivity_screen . ids . connectivity_transport_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_enable_transport )
self . widget_hide ( self . connectivity_screen . ids . connectivity_serial_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_use_serial )
self . widget_hide ( self . connectivity_screen . ids . connectivity_serial_fields )
self . widget_hide ( self . connectivity_screen . ids . connectivity_shared_access )
self . widget_hide ( self . connectivity_screen . ids . connectivity_shared_access_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_shared_access_fields )
self . widget_hide ( self . connectivity_screen . ids . connectivity_transport_label )
self . widget_hide ( self . connectivity_screen . ids . connectivity_enable_transport )
self . widget_hide ( self . connectivity_screen . ids . connectivity_transport_info )
self . widget_hide ( self . connectivity_screen . ids . connectivity_transport_fields )
2022-10-06 09:12:42 -06:00
def con_collapse_local ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_local_fields, collapse)
pass
2022-10-06 09:12:42 -06:00
def con_collapse_tcp ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_tcp_fields, collapse)
pass
2022-10-06 09:12:42 -06:00
def con_collapse_i2p ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_i2p_fields, collapse)
pass
2022-10-06 09:12:42 -06:00
def con_collapse_bluetooth ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_bluetooth_fields, collapse)
pass
2022-10-06 09:12:42 -06:00
def con_collapse_rnode ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_rnode_fields, collapse)
pass
2022-10-06 09:12:42 -06:00
def con_collapse_modem ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_modem_fields, collapse)
pass
2022-10-06 09:12:42 -06:00
2022-10-13 11:45:20 -06:00
def con_collapse_serial ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_serial_fields, collapse)
pass
2022-10-13 11:45:20 -06:00
2022-10-18 07:06:25 -06:00
def con_collapse_transport ( collapse = True ) :
2022-11-03 12:52:27 -06:00
# self.widget_hide(self.root.ids.connectivity_transport_fields, collapse)
pass
2022-10-18 07:06:25 -06:00
2022-10-06 09:12:42 -06:00
def save_connectivity ( sender = None , event = None ) :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " connect_transport " ] = self . connectivity_screen . ids . connectivity_enable_transport . active
self . sideband . config [ " connect_local " ] = self . connectivity_screen . ids . connectivity_use_local . active
self . sideband . config [ " connect_local_groupid " ] = self . connectivity_screen . ids . connectivity_local_groupid . text
self . sideband . config [ " connect_local_ifac_netname " ] = self . connectivity_screen . ids . connectivity_local_ifac_netname . text
self . sideband . config [ " connect_local_ifac_passphrase " ] = self . connectivity_screen . ids . connectivity_local_ifac_passphrase . text
self . sideband . config [ " connect_tcp " ] = self . connectivity_screen . ids . connectivity_use_tcp . active
self . sideband . config [ " connect_tcp_host " ] = self . connectivity_screen . ids . connectivity_tcp_host . text
self . sideband . config [ " connect_tcp_port " ] = self . connectivity_screen . ids . connectivity_tcp_port . text
self . sideband . config [ " connect_tcp_ifac_netname " ] = self . connectivity_screen . ids . connectivity_tcp_ifac_netname . text
self . sideband . config [ " connect_tcp_ifac_passphrase " ] = self . connectivity_screen . ids . connectivity_tcp_ifac_passphrase . text
self . sideband . config [ " connect_i2p " ] = self . connectivity_screen . ids . connectivity_use_i2p . active
self . sideband . config [ " connect_i2p_b32 " ] = self . connectivity_screen . ids . connectivity_i2p_b32 . text
self . sideband . config [ " connect_i2p_ifac_netname " ] = self . connectivity_screen . ids . connectivity_i2p_ifac_netname . text
self . sideband . config [ " connect_i2p_ifac_passphrase " ] = self . connectivity_screen . ids . connectivity_i2p_ifac_passphrase . text
self . sideband . config [ " connect_rnode " ] = self . connectivity_screen . ids . connectivity_use_rnode . active
self . sideband . config [ " connect_rnode_ifac_netname " ] = self . connectivity_screen . ids . connectivity_rnode_ifac_netname . text
self . sideband . config [ " connect_rnode_ifac_passphrase " ] = self . connectivity_screen . ids . connectivity_rnode_ifac_passphrase . text
self . sideband . config [ " connect_serial " ] = self . connectivity_screen . ids . connectivity_use_serial . active
self . sideband . config [ " connect_serial_ifac_netname " ] = self . connectivity_screen . ids . connectivity_serial_ifac_netname . text
self . sideband . config [ " connect_serial_ifac_passphrase " ] = self . connectivity_screen . ids . connectivity_serial_ifac_passphrase . text
self . sideband . config [ " connect_modem " ] = self . connectivity_screen . ids . connectivity_use_modem . active
self . sideband . config [ " connect_modem_ifac_netname " ] = self . connectivity_screen . ids . connectivity_modem_ifac_netname . text
self . sideband . config [ " connect_modem_ifac_passphrase " ] = self . connectivity_screen . ids . connectivity_modem_ifac_passphrase . text
self . sideband . config [ " connect_ifmode_local " ] = self . connectivity_screen . ids . connectivity_local_ifmode . text . lower ( )
self . sideband . config [ " connect_ifmode_tcp " ] = self . connectivity_screen . ids . connectivity_tcp_ifmode . text . lower ( )
self . sideband . config [ " connect_ifmode_i2p " ] = self . connectivity_screen . ids . connectivity_i2p_ifmode . text . lower ( )
self . sideband . config [ " connect_ifmode_rnode " ] = self . connectivity_screen . ids . connectivity_rnode_ifmode . text . lower ( )
self . sideband . config [ " connect_ifmode_modem " ] = self . connectivity_screen . ids . connectivity_modem_ifmode . text . lower ( )
self . sideband . config [ " connect_ifmode_serial " ] = self . connectivity_screen . ids . connectivity_serial_ifmode . text . lower ( )
con_collapse_local ( collapse = not self . connectivity_screen . ids . connectivity_use_local . active )
con_collapse_tcp ( collapse = not self . connectivity_screen . ids . connectivity_use_tcp . active )
con_collapse_i2p ( collapse = not self . connectivity_screen . ids . connectivity_use_i2p . active )
con_collapse_rnode ( collapse = not self . connectivity_screen . ids . connectivity_use_rnode . active )
con_collapse_modem ( collapse = not self . connectivity_screen . ids . connectivity_use_modem . active )
con_collapse_serial ( collapse = not self . connectivity_screen . ids . connectivity_use_serial . active )
2022-10-18 07:06:25 -06:00
con_collapse_transport ( collapse = not self . sideband . config [ " connect_transport " ] )
2022-10-02 12:43:56 -06:00
2022-10-06 09:12:42 -06:00
self . sideband . save_configuration ( )
2022-10-02 12:43:56 -06:00
2023-10-22 09:44:44 -06:00
if sender == self . connectivity_screen . ids . connectivity_enable_transport :
2022-10-15 11:30:43 -06:00
if sender . active :
def cb ( dt ) :
yes_button = MDRectangleFlatButton ( text = " Understood " , font_size = dp ( 18 ) , theme_text_color = " Custom " , line_color = self . color_reject , text_color = self . color_reject )
dialog = MDDialog (
title = " Warning! " ,
text = " You have enabled [i]Reticulum Transport[/i] for this device. \n \n For normal operation, and for most users, this is [b]not[/b] necessary, and might even degrade your network performance. \n \n When Transport is enabled, your device will route traffic between all connected interfaces and for all reachable devices on the network. \n \n This should only be done if you intend to keep your device in a fixed position and for it to remain available continously. \n \n If this is not the case, or you don ' t understand any of this, turn off Transport. " ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
Clock . schedule_once ( cb , 0.65 )
2022-10-15 03:11:34 -06:00
def serial_connectivity_save ( sender = None , event = None ) :
if sender . active :
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_use_rnode . unbind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_use_modem . unbind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_use_serial . unbind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_use_rnode . active = False
self . connectivity_screen . ids . connectivity_use_modem . active = False
self . connectivity_screen . ids . connectivity_use_serial . active = False
2022-10-15 03:11:34 -06:00
sender . active = True
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_use_rnode . bind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_use_modem . bind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_use_serial . bind ( active = serial_connectivity_save )
2022-10-15 03:11:34 -06:00
save_connectivity ( sender , event )
2022-10-13 11:45:20 -06:00
def focus_save ( sender = None , event = None ) :
if not sender . focus :
save_connectivity ( sender , event )
2022-10-18 07:06:25 -06:00
def ifmode_validate ( sender = None , event = None ) :
if not sender . focus :
all_valid = True
iftypes = [ " local " , " tcp " , " i2p " , " rnode " , " modem " , " serial " ]
for iftype in iftypes :
element = self . root . ids [ " connectivity_ " + iftype + " _ifmode " ]
modes = [ " full " , " gateway " , " access point " , " roaming " , " boundary " ]
value = element . text . lower ( )
if value in [ " " , " f " ] or value . startswith ( " fu " ) :
value = " full "
elif value in [ " g " , " gw " ] or value . startswith ( " ga " ) :
value = " gateway "
elif value in [ " a " , " ap " , " a p " , " accesspoint " , " access point " , " ac " , " acc " , " acce " , " acces " ] or value . startswith ( " access " ) :
value = " access point "
elif value in [ " r " ] or value . startswith ( " ro " ) :
value = " roaming "
elif value in [ " b " , " edge " ] or value . startswith ( " bo " ) :
value = " boundary "
else :
value = " full "
if value in modes :
element . text = value . capitalize ( )
element . error = False
else :
element . error = True
all_valid = False
if all_valid :
save_connectivity ( sender , event )
2022-10-06 09:12:42 -06:00
if RNS . vendor . platformutils . get_platform ( ) == " android " :
if not self . sideband . getpersistent ( " service.is_controlling_connectivity " ) :
info = " Sideband is connected via a shared Reticulum instance running on this system. \n \n "
info + = " To configure connectivity, edit the relevant configuration file for the instance. "
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_info . text = info
2022-10-06 09:12:42 -06:00
con_hide_settings ( )
else :
info = " By default, Sideband will try to discover and connect to any available Reticulum networks via active WiFi and/or Ethernet interfaces. If any Reticulum Transport Instances are found, Sideband will use these to connect to wider Reticulum networks. You can disable this behaviour if you don ' t want it. \n \n "
info + = " You can also connect to a network via a remote or local Reticulum instance using TCP or I2P. [b]Please Note![/b] Connecting via I2P requires that you already have I2P running on your device, and that the SAM API is enabled. \n \n "
info + = " For changes to connectivity to take effect, you must shut down and restart Sideband. \n "
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_info . text = info
self . connectivity_screen . ids . connectivity_use_local . active = self . sideband . config [ " connect_local " ]
con_collapse_local ( collapse = not self . connectivity_screen . ids . connectivity_use_local . active )
self . connectivity_screen . ids . connectivity_local_groupid . text = self . sideband . config [ " connect_local_groupid " ]
self . connectivity_screen . ids . connectivity_local_ifac_netname . text = self . sideband . config [ " connect_local_ifac_netname " ]
self . connectivity_screen . ids . connectivity_local_ifac_passphrase . text = self . sideband . config [ " connect_local_ifac_passphrase " ]
self . connectivity_screen . ids . connectivity_use_tcp . active = self . sideband . config [ " connect_tcp " ]
con_collapse_tcp ( collapse = not self . connectivity_screen . ids . connectivity_use_tcp . active )
self . connectivity_screen . ids . connectivity_tcp_host . text = self . sideband . config [ " connect_tcp_host " ]
self . connectivity_screen . ids . connectivity_tcp_port . text = self . sideband . config [ " connect_tcp_port " ]
self . connectivity_screen . ids . connectivity_tcp_ifac_netname . text = self . sideband . config [ " connect_tcp_ifac_netname " ]
self . connectivity_screen . ids . connectivity_tcp_ifac_passphrase . text = self . sideband . config [ " connect_tcp_ifac_passphrase " ]
self . connectivity_screen . ids . connectivity_use_i2p . active = self . sideband . config [ " connect_i2p " ]
con_collapse_i2p ( collapse = not self . connectivity_screen . ids . connectivity_use_i2p . active )
self . connectivity_screen . ids . connectivity_i2p_b32 . text = self . sideband . config [ " connect_i2p_b32 " ]
self . connectivity_screen . ids . connectivity_i2p_ifac_netname . text = self . sideband . config [ " connect_i2p_ifac_netname " ]
self . connectivity_screen . ids . connectivity_i2p_ifac_passphrase . text = self . sideband . config [ " connect_i2p_ifac_passphrase " ]
self . connectivity_screen . ids . connectivity_use_rnode . active = self . sideband . config [ " connect_rnode " ]
con_collapse_rnode ( collapse = not self . connectivity_screen . ids . connectivity_use_rnode . active )
self . connectivity_screen . ids . connectivity_rnode_ifac_netname . text = self . sideband . config [ " connect_rnode_ifac_netname " ]
self . connectivity_screen . ids . connectivity_rnode_ifac_passphrase . text = self . sideband . config [ " connect_rnode_ifac_passphrase " ]
self . connectivity_screen . ids . connectivity_use_modem . active = self . sideband . config [ " connect_modem " ]
con_collapse_modem ( collapse = not self . connectivity_screen . ids . connectivity_use_modem . active )
self . connectivity_screen . ids . connectivity_modem_ifac_netname . text = self . sideband . config [ " connect_modem_ifac_netname " ]
self . connectivity_screen . ids . connectivity_modem_ifac_passphrase . text = self . sideband . config [ " connect_modem_ifac_passphrase " ]
self . connectivity_screen . ids . connectivity_use_serial . active = self . sideband . config [ " connect_serial " ]
con_collapse_serial ( collapse = not self . connectivity_screen . ids . connectivity_use_serial . active )
self . connectivity_screen . ids . connectivity_serial_ifac_netname . text = self . sideband . config [ " connect_serial_ifac_netname " ]
self . connectivity_screen . ids . connectivity_serial_ifac_passphrase . text = self . sideband . config [ " connect_serial_ifac_passphrase " ]
self . connectivity_screen . ids . connectivity_enable_transport . active = self . sideband . config [ " connect_transport " ]
2022-10-18 07:06:25 -06:00
con_collapse_transport ( collapse = not self . sideband . config [ " connect_transport " ] )
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_enable_transport . bind ( active = save_connectivity )
self . connectivity_screen . ids . connectivity_local_ifmode . text = self . sideband . config [ " connect_ifmode_local " ] . capitalize ( )
self . connectivity_screen . ids . connectivity_tcp_ifmode . text = self . sideband . config [ " connect_ifmode_tcp " ] . capitalize ( )
self . connectivity_screen . ids . connectivity_i2p_ifmode . text = self . sideband . config [ " connect_ifmode_i2p " ] . capitalize ( )
self . connectivity_screen . ids . connectivity_rnode_ifmode . text = self . sideband . config [ " connect_ifmode_rnode " ] . capitalize ( )
self . connectivity_screen . ids . connectivity_modem_ifmode . text = self . sideband . config [ " connect_ifmode_modem " ] . capitalize ( )
self . connectivity_screen . ids . connectivity_serial_ifmode . text = self . sideband . config [ " connect_ifmode_serial " ] . capitalize ( )
self . connectivity_screen . ids . connectivity_use_local . bind ( active = save_connectivity )
self . connectivity_screen . ids . connectivity_local_groupid . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_local_ifac_netname . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_local_ifac_passphrase . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_use_tcp . bind ( active = save_connectivity )
self . connectivity_screen . ids . connectivity_tcp_host . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_tcp_port . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_tcp_ifac_netname . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_tcp_ifac_passphrase . bind ( focus = focus_save )
2022-10-18 07:06:25 -06:00
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_use_i2p . bind ( active = save_connectivity )
self . connectivity_screen . ids . connectivity_i2p_b32 . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_i2p_ifac_netname . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_i2p_ifac_passphrase . bind ( focus = focus_save )
2022-10-18 07:06:25 -06:00
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_use_rnode . bind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_rnode_ifac_netname . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_rnode_ifac_passphrase . bind ( focus = focus_save )
2022-10-13 11:45:20 -06:00
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_use_modem . bind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_modem_ifac_netname . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_modem_ifac_passphrase . bind ( focus = focus_save )
2022-10-15 03:11:34 -06:00
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_use_serial . bind ( active = serial_connectivity_save )
self . connectivity_screen . ids . connectivity_serial_ifac_netname . bind ( focus = focus_save )
self . connectivity_screen . ids . connectivity_serial_ifac_passphrase . bind ( focus = focus_save )
2022-10-15 03:11:34 -06:00
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_local_ifmode . bind ( focus = ifmode_validate )
self . connectivity_screen . ids . connectivity_tcp_ifmode . bind ( focus = ifmode_validate )
self . connectivity_screen . ids . connectivity_i2p_ifmode . bind ( focus = ifmode_validate )
self . connectivity_screen . ids . connectivity_rnode_ifmode . bind ( focus = ifmode_validate )
self . connectivity_screen . ids . connectivity_modem_ifmode . bind ( focus = ifmode_validate )
self . connectivity_screen . ids . connectivity_serial_ifmode . bind ( focus = ifmode_validate )
2022-10-18 07:06:25 -06:00
2022-07-06 05:07:11 -06:00
else :
2022-10-06 09:12:42 -06:00
info = " "
2022-07-06 05:07:11 -06:00
2022-10-06 09:12:42 -06:00
if self . sideband . reticulum . is_connected_to_shared_instance :
info = " Sideband is connected via a shared Reticulum instance running on this system. \n \n "
info + = " To get connectivity status, use the rnstatus utility. \n \n "
info + = " To configure connectivity, edit the configuration file located at: \n \n "
info + = str ( RNS . Reticulum . configpath )
else :
info = " Sideband is currently running a standalone or master Reticulum instance on this system. \n \n "
info + = " To get connectivity status, use the rnstatus utility. \n \n "
info + = " To configure connectivity, edit the configuration file located at: \n \n "
info + = str ( RNS . Reticulum . configpath )
2022-07-06 05:07:11 -06:00
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_info . text = info
2022-07-06 04:19:05 -06:00
2022-10-06 09:12:42 -06:00
con_hide_settings ( )
2022-07-06 04:19:05 -06:00
2022-10-06 09:12:42 -06:00
self . connectivity_ready = True
2022-07-06 04:19:05 -06:00
def close_connectivity_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2023-10-07 04:59:59 -06:00
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 \n A configuration line containing your Reticulum RPC key will be copied to the system clipboard. \n \n While 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 \n Are 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 ( )
2022-07-06 04:19:05 -06:00
2023-09-20 12:12:47 -06:00
### Repository screen
######################################
def repository_action ( self , sender = None , direction = " left " ) :
self . repository_init ( )
self . root . ids . screen_manager . transition . direction = direction
self . root . ids . screen_manager . current = " repository_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
if not RNS . vendor . platformutils . is_android ( ) :
2023-10-22 09:14:32 -06:00
self . widget_hide ( self . repository_screen . ids . repository_enable_button )
self . widget_hide ( self . repository_screen . ids . repository_disable_button )
self . widget_hide ( self . repository_screen . ids . repository_download_button )
self . repository_screen . ids . repository_info . text = " \n The [b]Repository Webserver[/b] feature is currently only available on mobile devices. "
2023-09-20 12:12:47 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
def repository_update_info ( self , sender = None ) :
info = " Sideband includes a small repository of useful software and guides related to the Sideband and Reticulum ecosystem. You can start this repository to allow other people on your local network to download software and information directly from this device, without needing an Internet connection. \n \n "
info + = " If you want to share the Sideband application itself via the repository server, you must first download it into the local repository, using the \" Update Content \" button below. \n \n "
info + = " To make the repository available on your local network, simply start it below, and it will become browsable on a local IP address for anyone connected to the same WiFi or wired network. \n \n "
if self . sideband . webshare_server != None :
if RNS . vendor . platformutils . is_android ( ) :
def getIP ( ) :
adrs = [ ]
try :
from jnius import autoclass
import ipaddress
mActivity = autoclass ( ' org.kivy.android.PythonActivity ' ) . mActivity
SystemProperties = autoclass ( ' android.os.SystemProperties ' )
Context = autoclass ( ' android.content.Context ' )
connectivity_manager = mActivity . getSystemService ( Context . CONNECTIVITY_SERVICE )
ns = connectivity_manager . getAllNetworks ( )
if not ns == None and len ( ns ) > 0 :
for n in ns :
lps = connectivity_manager . getLinkProperties ( n )
las = lps . getLinkAddresses ( )
for la in las :
ina = la . getAddress ( )
ha = ina . getHostAddress ( )
if not ina . isLinkLocalAddress ( ) :
adrs . append ( ha )
except Exception as e :
RNS . log ( " Error while getting repository IP address: " + str ( e ) , RNS . LOG_ERROR )
return None
return adrs
ips = getIP ( )
if ips == None or len ( ips ) == 0 :
info + = " The repository server is running, but the local device IP address could not be determined. \n \n You can access the repository by pointing a browser to: http://DEVICE_IP:4444/ "
else :
ipstr = " "
for ip in ips :
ipstr + = " http:// " + str ( ip ) + " :4444/ \n "
ms = " " if len ( ips ) == 1 else " es "
info + = " The repository server is running at the following address " + ms + " : \n " + ipstr
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_enable_button . disabled = True
self . repository_screen . ids . repository_disable_button . disabled = False
2023-09-20 12:12:47 -06:00
else :
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_enable_button . disabled = False
self . repository_screen . ids . repository_disable_button . disabled = True
2023-09-20 12:12:47 -06:00
info + = " \n "
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_info . text = info
2023-09-20 12:12:47 -06:00
def repository_start_action ( self , sender = None ) :
self . sideband . start_webshare ( )
Clock . schedule_once ( self . repository_update_info , 1.0 )
def repository_stop_action ( self , sender = None ) :
self . sideband . stop_webshare ( )
Clock . schedule_once ( self . repository_update_info , 0.75 )
def repository_download_action ( self , sender = None ) :
def update_job ( sender = None ) :
try :
import requests
# Get release info
apk_version = None
apk_url = None
pkgname = None
try :
release_url = " https://api.github.com/repos/markqvist/sideband/releases "
with requests . get ( release_url ) as response :
releases = response . json ( )
release = releases [ 0 ]
assets = release [ " assets " ]
for asset in assets :
if asset [ " name " ] . lower ( ) . endswith ( " .apk " ) :
apk_url = asset [ " browser_download_url " ]
pkgname = asset [ " name " ]
apk_version = release [ " tag_name " ]
RNS . log ( f " Found version { apk_version } artefact { pkgname } at { apk_url } " )
except Exception as e :
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = f " Downloading release info failed with the error: \n " + str ( e )
2023-09-20 12:12:47 -06:00
return
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = " Downloading: " + str ( apk_url )
2023-09-20 12:12:47 -06:00
with requests . get ( apk_url , stream = True ) as response :
with open ( " ./dl_tmp " , " wb " ) as tmp_file :
cs = 32 * 1024
tds = 0
for chunk in response . iter_content ( chunk_size = cs ) :
tmp_file . write ( chunk )
tds + = cs
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = " Downloaded " + RNS . prettysize ( tds ) + " of " + str ( pkgname )
2023-09-20 12:12:47 -06:00
os . rename ( " ./dl_tmp " , f " ./share/pkg/ { pkgname } " )
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = f " Added { pkgname } to the repository! "
2023-09-20 12:12:47 -06:00
except Exception as e :
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = f " Downloading contents failed with the error: \n " + str ( e )
2023-09-20 12:12:47 -06:00
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = " Starting package download... "
2023-09-20 12:12:47 -06:00
def start_update_job ( sender = None ) :
threading . Thread ( target = update_job , daemon = True ) . start ( )
Clock . schedule_once ( start_update_job , 0.5 )
def repository_init ( self , sender = None ) :
if not self . repository_ready :
2023-10-22 09:14:32 -06:00
if not self . root . ids . screen_manager . has_screen ( " repository_screen " ) :
self . repository_screen = Builder . load_string ( layout_repository_screen )
self . repository_screen . app = self
self . root . ids . screen_manager . add_widget ( self . repository_screen )
self . repository_screen . ids . repository_scrollview . effect_cls = ScrollEffect
2023-09-20 12:12:47 -06:00
self . repository_update_info ( )
2023-10-22 09:14:32 -06:00
self . repository_screen . ids . repository_update . text = " "
2023-09-20 12:12:47 -06:00
self . repository_ready = True
def close_repository_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2022-10-13 10:37:59 -06:00
### Hardware screen
######################################
def hardware_action ( self , sender = None , direction = " left " ) :
self . hardware_init ( )
self . root . ids . screen_manager . transition . direction = direction
self . root . ids . screen_manager . current = " hardware_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-10-15 02:06:42 -06:00
def close_sub_hardware_action ( self , sender = None ) :
self . hardware_action ( direction = " right " )
def hardware_init ( self , sender = None ) :
if not self . hardware_ready :
2023-10-22 09:44:44 -06:00
if not self . root . ids . screen_manager . has_screen ( " hardware_screen " ) :
self . hardware_screen = Builder . load_string ( layout_hardware_screen )
self . hardware_screen . app = self
self . root . ids . screen_manager . add_widget ( self . hardware_screen )
self . hardware_screen . ids . hardware_scrollview . effect_cls = ScrollEffect
2022-10-18 11:17:55 -06:00
2022-10-15 02:06:42 -06:00
def con_hide_settings ( ) :
2023-10-22 09:44:44 -06:00
self . widget_hide ( self . hardware_screen . ids . hardware_rnode_button )
self . widget_hide ( self . hardware_screen . ids . hardware_modem_button )
self . widget_hide ( self . hardware_screen . ids . hardware_serial_button )
2022-10-15 02:06:42 -06:00
2023-10-22 09:44:44 -06:00
# def con_collapse_local(collapse=True):
# self.widget_hide(self.root.ids.connectivity_local_fields, collapse)
2022-10-15 02:06:42 -06:00
2023-10-22 09:44:44 -06:00
# def save_connectivity(sender=None, event=None):
# # self.sideband.config["connect_local"] = self.root.ids.connectivity_use_local.active
# con_collapse_local(collapse=not self.root.ids.connectivity_use_local.active)
# self.sideband.save_configuration()
2022-10-15 02:06:42 -06:00
2022-11-03 15:55:35 -06:00
if RNS . vendor . platformutils . get_platform ( ) == " android " :
if not self . sideband . getpersistent ( " service.is_controlling_connectivity " ) :
2022-10-15 02:06:42 -06:00
info = " Sideband is connected via a shared Reticulum instance running on this system. \n \n "
info + = " To configure hardware parameters, edit the relevant configuration file for the instance. "
2023-10-22 09:44:44 -06:00
self . hardware_screen . ids . hardware_info . text = info
2022-10-15 02:06:42 -06:00
con_hide_settings ( )
else :
info = " When using external hardware for communicating, you may configure various parameters, such as channel settings, modulation schemes, interface speeds and access parameters. You can set up these parameters per device type, and Sideband will apply the configuration when opening a device of that type. \n \n "
info + = " Hardware configurations can also be exported or imported as [i]config motes[/i], which are self-contained plaintext strings that are easy to share with others. When importing a config mote, Sideband will automatically set all relevant parameters as specified within it. \n \n "
info + = " For changes to hardware parameters to take effect, you must shut down and restart Sideband. \n "
2023-10-22 09:44:44 -06:00
self . hardware_screen . ids . hardware_info . text = info
2022-10-15 02:06:42 -06:00
else :
info = " "
if self . sideband . reticulum . is_connected_to_shared_instance :
info = " Sideband is connected via a shared Reticulum instance running on this system. \n \n "
info + = " To configure hardware parameters, edit the configuration file located at: \n \n "
info + = str ( RNS . Reticulum . configpath )
else :
info = " Sideband is currently running a standalone or master Reticulum instance on this system. \n \n "
info + = " To configure hardware parameters, edit the configuration file located at: \n \n "
info + = str ( RNS . Reticulum . configpath )
2023-10-22 09:44:44 -06:00
self . hardware_screen . ids . hardware_info . text = info
2022-10-15 02:06:42 -06:00
con_hide_settings ( )
self . hardware_ready = True
def close_hardware_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
## RNode hardware screen
2022-10-13 10:37:59 -06:00
def hardware_rnode_action ( self , sender = None ) :
self . hardware_rnode_init ( )
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " hardware_rnode_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
def hardware_rnode_save ( self ) :
2023-09-13 13:14:30 -06:00
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_frequency " ] = int ( float ( self . hardware_rnode_screen . ids . hardware_rnode_frequency . text ) * 1000000 )
2023-09-13 13:14:30 -06:00
except :
pass
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_bandwidth " ] = int ( float ( self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . text ) * 1000 )
2023-09-13 13:14:30 -06:00
except :
pass
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_tx_power " ] = int ( self . hardware_rnode_screen . ids . hardware_rnode_txpower . text )
2023-09-13 13:14:30 -06:00
except :
pass
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_spreading_factor " ] = int ( self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . text )
2023-09-13 13:14:30 -06:00
except :
pass
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_coding_rate " ] = int ( self . hardware_rnode_screen . ids . hardware_rnode_codingrate . text )
2023-09-13 13:14:30 -06:00
except :
pass
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_atl_short " ] = float ( self . hardware_rnode_screen . ids . hardware_rnode_atl_short . text )
2023-09-13 13:14:30 -06:00
except :
self . sideband . config [ " hw_rnode_atl_short " ] = None
try :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_atl_long " ] = float ( self . hardware_rnode_screen . ids . hardware_rnode_atl_long . text )
2023-09-13 13:14:30 -06:00
except :
self . sideband . config [ " hw_rnode_atl_long " ] = None
2022-10-13 10:37:59 -06:00
2023-10-22 09:44:44 -06:00
if self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text == " " :
2022-10-13 10:37:59 -06:00
self . sideband . config [ " hw_rnode_beaconinterval " ] = None
else :
2023-10-22 09:44:44 -06:00
try :
self . sideband . config [ " hw_rnode_beaconinterval " ] = int ( self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text )
except :
pass
2022-10-13 10:37:59 -06:00
2023-10-22 09:44:44 -06:00
if self . hardware_rnode_screen . ids . hardware_rnode_beacondata . text == " " :
2022-10-13 10:37:59 -06:00
self . sideband . config [ " hw_rnode_beacondata " ] = None
else :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_beacondata " ] = self . hardware_rnode_screen . ids . hardware_rnode_beacondata . text
2022-10-13 10:37:59 -06:00
2023-10-22 09:44:44 -06:00
if self . hardware_rnode_screen . ids . hardware_rnode_bt_device . text == " " :
2022-11-03 13:22:16 -06:00
self . sideband . config [ " hw_rnode_bt_device " ] = None
else :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_rnode_bt_device " ] = self . hardware_rnode_screen . ids . hardware_rnode_bt_device . text
2022-11-03 13:22:16 -06:00
2022-10-13 11:45:20 -06:00
self . sideband . save_configuration ( )
2022-11-02 15:31:46 -06:00
def hardware_rnode_bt_on_action ( self , sender = None ) :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bt_pair_button . disabled = True
self . hardware_rnode_screen . ids . hardware_rnode_bt_on_button . disabled = True
self . hardware_rnode_screen . ids . hardware_rnode_bt_off_button . disabled = True
2022-11-02 15:31:46 -06:00
def re_enable ( ) :
time . sleep ( 2 )
while self . sideband . getstate ( " executing.bt_on " ) :
time . sleep ( 1 )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bt_off_button . disabled = False
self . hardware_rnode_screen . ids . hardware_rnode_bt_pair_button . disabled = False
self . hardware_rnode_screen . ids . hardware_rnode_bt_on_button . disabled = False
2022-11-02 15:31:46 -06:00
threading . Thread ( target = re_enable , daemon = True ) . start ( )
self . sideband . setstate ( " wants.bt_on " , True )
def hardware_rnode_bt_off_action ( self , sender = None ) :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bt_pair_button . disabled = True
self . hardware_rnode_screen . ids . hardware_rnode_bt_on_button . disabled = True
self . hardware_rnode_screen . ids . hardware_rnode_bt_off_button . disabled = True
2022-11-02 15:31:46 -06:00
def re_enable ( ) :
time . sleep ( 2 )
while self . sideband . getstate ( " executing.bt_off " ) :
time . sleep ( 1 )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bt_off_button . disabled = False
self . hardware_rnode_screen . ids . hardware_rnode_bt_pair_button . disabled = False
self . hardware_rnode_screen . ids . hardware_rnode_bt_on_button . disabled = False
2022-11-02 15:31:46 -06:00
threading . Thread ( target = re_enable , daemon = True ) . start ( )
self . sideband . setstate ( " wants.bt_off " , True )
def hardware_rnode_bt_pair_action ( self , sender = None ) :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bt_pair_button . disabled = True
self . hardware_rnode_screen . ids . hardware_rnode_bt_on_button . disabled = True
self . hardware_rnode_screen . ids . hardware_rnode_bt_off_button . disabled = True
2022-11-02 15:31:46 -06:00
def re_enable ( ) :
time . sleep ( 2 )
while self . sideband . getstate ( " executing.bt_pair " ) :
time . sleep ( 1 )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bt_off_button . disabled = False
self . hardware_rnode_screen . ids . hardware_rnode_bt_pair_button . disabled = False
self . hardware_rnode_screen . ids . hardware_rnode_bt_on_button . disabled = False
2022-11-02 15:31:46 -06:00
threading . Thread ( target = re_enable , daemon = True ) . start ( )
self . sideband . setstate ( " wants.bt_pair " , True )
def hardware_rnode_bt_toggle_action ( self , sender = None , event = None ) :
if sender . active :
self . sideband . config [ " hw_rnode_bluetooth " ] = True
self . request_bluetooth_permissions ( )
else :
self . sideband . config [ " hw_rnode_bluetooth " ] = False
self . sideband . save_configuration ( )
2023-09-13 13:14:30 -06:00
def hardware_rnode_framebuffer_toggle_action ( self , sender = None , event = None ) :
if sender . active :
self . sideband . config [ " hw_rnode_enable_framebuffer " ] = True
else :
self . sideband . config [ " hw_rnode_enable_framebuffer " ] = False
self . sideband . save_configuration ( )
2022-10-13 10:37:59 -06:00
def hardware_rnode_init ( self , sender = None ) :
if not self . hardware_rnode_ready :
2023-10-22 09:44:44 -06:00
if not self . root . ids . screen_manager . has_screen ( " hardware_rnode_screen " ) :
self . hardware_rnode_screen = Builder . load_string ( layout_hardware_rnode_screen )
self . hardware_rnode_screen . app = self
self . root . ids . screen_manager . add_widget ( self . hardware_rnode_screen )
self . hardware_rnode_screen . ids . hardware_rnode_scrollview . effect_cls = ScrollEffect
2022-10-13 10:37:59 -06:00
def save_connectivity ( sender = None , event = None ) :
if self . hardware_rnode_validate ( ) :
self . hardware_rnode_save ( )
def focus_save ( sender = None , event = None ) :
if sender != None :
if not sender . focus :
save_connectivity ( sender = sender )
if self . sideband . config [ " hw_rnode_frequency " ] != None :
t_freq = str ( self . sideband . config [ " hw_rnode_frequency " ] / 1000000.0 )
else :
t_freq = " "
if self . sideband . config [ " hw_rnode_bandwidth " ] != None :
t_bw = str ( self . sideband . config [ " hw_rnode_bandwidth " ] / 1000.0 )
else :
t_bw = str ( 62.5 )
if self . sideband . config [ " hw_rnode_tx_power " ] != None :
t_p = str ( self . sideband . config [ " hw_rnode_tx_power " ] )
else :
t_p = str ( 0 )
if self . sideband . config [ " hw_rnode_spreading_factor " ] != None :
t_sf = str ( self . sideband . config [ " hw_rnode_spreading_factor " ] )
else :
t_sf = str ( 8 )
if self . sideband . config [ " hw_rnode_coding_rate " ] != None :
t_cr = str ( self . sideband . config [ " hw_rnode_coding_rate " ] )
else :
t_cr = str ( 6 )
if self . sideband . config [ " hw_rnode_beaconinterval " ] != None :
t_bi = str ( self . sideband . config [ " hw_rnode_beaconinterval " ] )
else :
t_bi = " "
if self . sideband . config [ " hw_rnode_beacondata " ] != None :
t_bd = str ( self . sideband . config [ " hw_rnode_beacondata " ] )
else :
t_bd = " "
2022-11-03 13:22:16 -06:00
if self . sideband . config [ " hw_rnode_bt_device " ] != None :
t_btd = str ( self . sideband . config [ " hw_rnode_bt_device " ] )
else :
t_btd = " "
2023-09-13 13:14:30 -06:00
if self . sideband . config [ " hw_rnode_atl_short " ] != None :
t_ats = str ( self . sideband . config [ " hw_rnode_atl_short " ] )
else :
t_ats = " "
if self . sideband . config [ " hw_rnode_atl_long " ] != None :
t_atl = str ( self . sideband . config [ " hw_rnode_atl_long " ] )
else :
t_atl = " "
2022-10-13 10:37:59 -06:00
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bluetooth . active = self . sideband . config [ " hw_rnode_bluetooth " ]
self . hardware_rnode_screen . ids . hardware_rnode_framebuffer . active = self . sideband . config [ " hw_rnode_enable_framebuffer " ]
self . hardware_rnode_screen . ids . hardware_rnode_frequency . text = t_freq
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . text = t_bw
self . hardware_rnode_screen . ids . hardware_rnode_txpower . text = t_p
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . text = t_sf
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . text = t_cr
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text = t_bi
self . hardware_rnode_screen . ids . hardware_rnode_beacondata . text = t_bd
self . hardware_rnode_screen . ids . hardware_rnode_bt_device . text = t_btd
self . hardware_rnode_screen . ids . hardware_rnode_atl_short . text = t_ats
self . hardware_rnode_screen . ids . hardware_rnode_atl_long . text = t_atl
self . hardware_rnode_screen . ids . hardware_rnode_frequency . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_txpower . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_beacondata . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_bt_device . bind ( focus = focus_save )
self . hardware_rnode_screen . ids . hardware_rnode_frequency . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_txpower . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_beacondata . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_atl_short . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_atl_long . bind ( on_text_validate = save_connectivity )
self . hardware_rnode_screen . ids . hardware_rnode_bluetooth . bind ( active = self . hardware_rnode_bt_toggle_action )
self . hardware_rnode_screen . ids . hardware_rnode_framebuffer . bind ( active = self . hardware_rnode_framebuffer_toggle_action )
2022-11-02 15:31:46 -06:00
2022-10-13 10:37:59 -06:00
def hardware_rnode_validate ( self , sender = None ) :
valid = True
try :
2023-10-22 09:44:44 -06:00
val = float ( self . hardware_rnode_screen . ids . hardware_rnode_frequency . text )
2022-10-13 10:37:59 -06:00
if not val > 0 :
raise ValueError ( " Invalid frequency " )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_frequency . error = False
self . hardware_rnode_screen . ids . hardware_rnode_frequency . text = str ( val )
2022-10-13 10:37:59 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_frequency . error = True
2022-10-13 10:37:59 -06:00
valid = False
try :
valid_vals = [ 7.8 , 10.4 , 15.6 , 20.8 , 31.25 , 41.7 , 62.5 , 125 , 250 , 500 ]
2023-10-22 09:44:44 -06:00
val = float ( self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . text )
2022-10-13 10:37:59 -06:00
if not val in valid_vals :
raise ValueError ( " Invalid bandwidth " )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . error = False
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . text = str ( val )
2022-10-13 10:37:59 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . error = True
2022-10-13 10:37:59 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_rnode_screen . ids . hardware_rnode_txpower . text )
2022-10-13 10:37:59 -06:00
if not val > = 0 :
raise ValueError ( " Invalid TX power " )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_txpower . error = False
self . hardware_rnode_screen . ids . hardware_rnode_txpower . text = str ( val )
2022-10-13 10:37:59 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_txpower . error = True
2022-10-13 10:37:59 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . text )
2022-10-13 10:37:59 -06:00
if val < 7 or val > 12 :
raise ValueError ( " Invalid sf " )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . error = False
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . text = str ( val )
2022-10-13 10:37:59 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . error = True
2022-10-13 10:37:59 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_rnode_screen . ids . hardware_rnode_codingrate . text )
2022-10-13 10:37:59 -06:00
if val < 5 or val > 8 :
raise ValueError ( " Invalid cr " )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . error = False
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . text = str ( val )
2022-10-13 10:37:59 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . error = True
2022-10-13 10:37:59 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
if self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text != " " :
val = int ( self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text )
2022-10-13 10:37:59 -06:00
if val < 10 :
raise ValueError ( " Invalid bi " )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text = str ( val )
2022-10-13 10:37:59 -06:00
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . error = False
2022-10-13 10:37:59 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text = " "
2022-10-13 10:37:59 -06:00
valid = False
return valid
def hardware_rnode_import ( self , sender = None ) :
mote = None
try :
mote = Clipboard . paste ( )
except Exception as e :
2022-10-13 14:12:39 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-13 10:37:59 -06:00
dialog = MDDialog (
title = " Import Failed " ,
text = " Could not read data from your clipboard, please check your system permissions. " ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
try :
config = msgpack . unpackb ( base64 . b32decode ( mote ) )
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_frequency . text = str ( config [ " f " ] / 1000000.0 )
self . hardware_rnode_screen . ids . hardware_rnode_bandwidth . text = str ( config [ " b " ] / 1000.0 )
self . hardware_rnode_screen . ids . hardware_rnode_txpower . text = str ( config [ " t " ] )
self . hardware_rnode_screen . ids . hardware_rnode_spreadingfactor . text = str ( config [ " s " ] )
self . hardware_rnode_screen . ids . hardware_rnode_codingrate . text = str ( config [ " c " ] )
2022-10-13 11:45:20 -06:00
if " n " in config and config [ " n " ] != None :
ifn = str ( config [ " n " ] )
else :
ifn = " "
if " p " in config and config [ " p " ] != None :
ifp = str ( config [ " p " ] )
else :
ifp = " "
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_rnode_ifac_netname . text = ifn
2022-10-13 11:45:20 -06:00
self . sideband . config [ " connect_rnode_ifac_netname " ] = ifn
2023-10-22 09:44:44 -06:00
self . connectivity_screen . ids . connectivity_rnode_ifac_passphrase . text = ifp
2022-10-13 11:45:20 -06:00
self . sideband . config [ " connect_rnode_ifac_passphrase " ] = ifp
2022-10-13 10:37:59 -06:00
if config [ " i " ] != None :
ti = str ( config [ " i " ] )
else :
ti = " "
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_beaconinterval . text = ti
2022-10-13 10:37:59 -06:00
if config [ " d " ] != None :
td = str ( config [ " d " ] )
else :
td = " "
2023-10-22 09:44:44 -06:00
self . hardware_rnode_screen . ids . hardware_rnode_beacondata . text = td
2022-10-13 10:37:59 -06:00
if self . hardware_rnode_validate ( ) :
self . hardware_rnode_save ( )
2022-10-13 14:12:39 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-13 10:37:59 -06:00
dialog = MDDialog (
title = " Configuration Imported " ,
text = " The config mote was imported and saved as your active configuration. " ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
else :
raise ValueError ( " Invalid mote " )
except Exception as e :
2022-10-13 14:12:39 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-13 10:37:59 -06:00
dialog = MDDialog (
title = " Import Failed " ,
text = " The read data did not contain a valid config mote. If any data was decoded, you may try to correct it by editing the relevant fields. The reported error was: \n \n " + str ( e ) ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
def hardware_rnode_export ( self , sender = None ) :
mote = None
try :
mote = base64 . b32encode ( msgpack . packb ( {
" f " : self . sideband . config [ " hw_rnode_frequency " ] ,
" b " : self . sideband . config [ " hw_rnode_bandwidth " ] ,
" t " : self . sideband . config [ " hw_rnode_tx_power " ] ,
" s " : self . sideband . config [ " hw_rnode_spreading_factor " ] ,
" c " : self . sideband . config [ " hw_rnode_coding_rate " ] ,
" i " : self . sideband . config [ " hw_rnode_beaconinterval " ] ,
" d " : self . sideband . config [ " hw_rnode_beacondata " ] ,
2022-10-13 11:45:20 -06:00
" n " : self . sideband . config [ " connect_rnode_ifac_netname " ] ,
" p " : self . sideband . config [ " connect_rnode_ifac_passphrase " ] ,
2022-10-13 10:37:59 -06:00
} ) )
except Exception as e :
pass
if mote != None :
Clipboard . copy ( mote )
2022-10-13 14:12:39 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-13 10:37:59 -06:00
dialog = MDDialog (
title = " Configuration Exported " ,
text = " The config mote was created and copied to your clipboard. " ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
else :
2022-10-13 14:12:39 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-13 10:37:59 -06:00
dialog = MDDialog (
title = " Export Failed " ,
text = " The config mote could not be created, please check your settings. " ,
buttons = [ yes_button ] ,
# elevation=0,
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
2022-10-15 02:06:42 -06:00
## Modem hardware screen
2022-10-13 10:37:59 -06:00
def hardware_modem_action ( self , sender = None ) :
self . hardware_modem_init ( )
self . root . ids . screen_manager . transition . direction = " left "
2022-10-15 06:31:47 -06:00
self . root . ids . screen_manager . current = " hardware_modem_screen "
2022-10-13 10:37:59 -06:00
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
def hardware_modem_init ( self , sender = None ) :
2022-10-15 06:31:47 -06:00
if not self . hardware_modem_ready :
2023-10-22 09:44:44 -06:00
if not self . root . ids . screen_manager . has_screen ( " hardware_modem_screen " ) :
self . hardware_modem_screen = Builder . load_string ( layout_hardware_modem_screen )
self . hardware_modem_screen . app = self
self . root . ids . screen_manager . add_widget ( self . hardware_modem_screen )
self . hardware_modem_screen . ids . hardware_modem_scrollview . effect_cls = ScrollEffect
2022-10-15 06:31:47 -06:00
def save_connectivity ( sender = None , event = None ) :
if self . hardware_modem_validate ( ) :
self . hardware_modem_save ( )
def focus_save ( sender = None , event = None ) :
if sender != None :
if not sender . focus :
save_connectivity ( sender = sender )
if self . sideband . config [ " hw_modem_baudrate " ] != None :
t_b = str ( self . sideband . config [ " hw_modem_baudrate " ] )
else :
t_b = " "
if self . sideband . config [ " hw_modem_databits " ] != None :
t_db = str ( self . sideband . config [ " hw_modem_databits " ] )
else :
t_db = " "
if self . sideband . config [ " hw_modem_parity " ] != None :
t_p = str ( self . sideband . config [ " hw_modem_parity " ] )
else :
t_p = " "
if self . sideband . config [ " hw_modem_stopbits " ] != None :
t_sb = str ( self . sideband . config [ " hw_modem_stopbits " ] )
else :
t_sb = " "
if self . sideband . config [ " hw_modem_preamble " ] != None :
t_pa = str ( self . sideband . config [ " hw_modem_preamble " ] )
else :
t_pa = " "
if self . sideband . config [ " hw_modem_tail " ] != None :
t_t = str ( self . sideband . config [ " hw_modem_tail " ] )
else :
t_t = " "
if self . sideband . config [ " hw_modem_persistence " ] != None :
t_ps = str ( self . sideband . config [ " hw_modem_persistence " ] )
else :
t_ps = " "
if self . sideband . config [ " hw_modem_slottime " ] != None :
t_st = str ( self . sideband . config [ " hw_modem_slottime " ] )
else :
t_st = " "
if self . sideband . config [ " hw_modem_beaconinterval " ] != None :
t_bi = str ( self . sideband . config [ " hw_modem_beaconinterval " ] )
else :
t_bi = " "
if self . sideband . config [ " hw_modem_beacondata " ] != None :
t_bd = str ( self . sideband . config [ " hw_modem_beacondata " ] )
else :
t_bd = " "
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_baudrate . text = t_b
self . hardware_modem_screen . ids . hardware_modem_databits . text = t_db
self . hardware_modem_screen . ids . hardware_modem_parity . text = t_p
self . hardware_modem_screen . ids . hardware_modem_stopbits . text = t_sb
self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text = t_bi
self . hardware_modem_screen . ids . hardware_modem_beacondata . text = t_bd
self . hardware_modem_screen . ids . hardware_modem_preamble . text = t_pa
self . hardware_modem_screen . ids . hardware_modem_tail . text = t_t
self . hardware_modem_screen . ids . hardware_modem_persistence . text = t_ps
self . hardware_modem_screen . ids . hardware_modem_slottime . text = t_st
self . hardware_modem_screen . ids . hardware_modem_baudrate . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_databits . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_parity . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_stopbits . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_beaconinterval . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_beacondata . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_preamble . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_tail . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_persistence . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_slottime . bind ( focus = focus_save )
self . hardware_modem_screen . ids . hardware_modem_baudrate . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_databits . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_parity . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_stopbits . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_beaconinterval . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_beacondata . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_preamble . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_tail . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_persistence . bind ( on_text_validate = save_connectivity )
self . hardware_modem_screen . ids . hardware_modem_slottime . bind ( on_text_validate = save_connectivity )
2022-10-15 06:31:47 -06:00
def hardware_modem_save ( self ) :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_modem_baudrate " ] = int ( self . hardware_modem_screen . ids . hardware_modem_baudrate . text )
self . sideband . config [ " hw_modem_databits " ] = int ( self . hardware_modem_screen . ids . hardware_modem_databits . text )
self . sideband . config [ " hw_modem_parity " ] = self . hardware_modem_screen . ids . hardware_modem_parity . text
self . sideband . config [ " hw_modem_stopbits " ] = int ( self . hardware_modem_screen . ids . hardware_modem_stopbits . text )
self . sideband . config [ " hw_modem_preamble " ] = int ( self . hardware_modem_screen . ids . hardware_modem_preamble . text )
self . sideband . config [ " hw_modem_tail " ] = int ( self . hardware_modem_screen . ids . hardware_modem_tail . text )
self . sideband . config [ " hw_modem_persistence " ] = int ( self . hardware_modem_screen . ids . hardware_modem_persistence . text )
self . sideband . config [ " hw_modem_slottime " ] = int ( self . hardware_modem_screen . ids . hardware_modem_slottime . text )
if self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text == " " :
2022-10-15 06:31:47 -06:00
self . sideband . config [ " hw_modem_beaconinterval " ] = None
else :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_modem_beaconinterval " ] = int ( self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text )
2022-10-15 06:31:47 -06:00
2023-10-22 09:44:44 -06:00
if self . hardware_modem_screen . ids . hardware_modem_beacondata . text == " " :
2022-10-15 06:31:47 -06:00
self . sideband . config [ " hw_modem_beacondata " ] = None
else :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_modem_beacondata " ] = self . hardware_modem_screen . ids . hardware_modem_beacondata . text
2022-10-15 06:31:47 -06:00
self . sideband . save_configuration ( )
def hardware_modem_validate ( self , sender = None ) :
valid = True
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_baudrate . text )
2022-10-15 06:31:47 -06:00
if not val > 0 :
raise ValueError ( " Invalid baudrate " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_baudrate . error = False
self . hardware_modem_screen . ids . hardware_modem_baudrate . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_baudrate . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_databits . text )
2022-10-15 06:31:47 -06:00
if not val > 0 :
raise ValueError ( " Invalid databits " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_databits . error = False
self . hardware_modem_screen . ids . hardware_modem_databits . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_databits . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_stopbits . text )
2022-10-15 06:31:47 -06:00
if not val > 0 :
raise ValueError ( " Invalid stopbits " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_stopbits . error = False
self . hardware_modem_screen . ids . hardware_modem_stopbits . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_stopbits . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_preamble . text )
2022-10-15 06:31:47 -06:00
if not ( val > = 0 and val < = 1000 ) :
raise ValueError ( " Invalid preamble " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_preamble . error = False
self . hardware_modem_screen . ids . hardware_modem_preamble . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_preamble . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_tail . text )
2022-10-15 06:31:47 -06:00
if not ( val > 0 and val < = 500 ) :
raise ValueError ( " Invalid tail " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_tail . error = False
self . hardware_modem_screen . ids . hardware_modem_tail . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_tail . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_slottime . text )
2022-10-15 06:31:47 -06:00
if not ( val > 0 and val < = 500 ) :
raise ValueError ( " Invalid slottime " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_slottime . error = False
self . hardware_modem_screen . ids . hardware_modem_slottime . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_slottime . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_modem_screen . ids . hardware_modem_persistence . text )
2022-10-15 06:31:47 -06:00
if not ( val > 0 and val < = 255 ) :
raise ValueError ( " Invalid persistence " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_persistence . error = False
self . hardware_modem_screen . ids . hardware_modem_persistence . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_persistence . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = self . hardware_modem_screen . ids . hardware_modem_parity . text
2022-10-15 06:31:47 -06:00
nval = val . lower ( )
if nval in [ " e " , " ev " , " eve " , " even " ] :
val = " even "
if nval in [ " o " , " od " , " odd " ] :
val = " odd "
if nval in [ " n " , " no " , " non " , " none " , " not " , " null " , " off " ] :
val = " none "
if not val in [ " even " , " odd " , " none " ] :
raise ValueError ( " Invalid parity " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_parity . error = False
self . hardware_modem_screen . ids . hardware_modem_parity . text = str ( val )
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_parity . error = True
2022-10-15 06:31:47 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
if self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text != " " :
val = int ( self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text )
2022-10-15 06:31:47 -06:00
if val < 10 :
raise ValueError ( " Invalid bi " )
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text = str ( val )
2022-10-15 06:31:47 -06:00
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_beaconinterval . error = False
2022-10-15 06:31:47 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_modem_screen . ids . hardware_modem_beaconinterval . text = " "
2022-10-15 06:31:47 -06:00
valid = False
return valid
2022-10-13 10:37:59 -06:00
2022-10-15 02:06:42 -06:00
## Serial hardware screen
2022-10-13 10:37:59 -06:00
def hardware_serial_action ( self , sender = None ) :
self . hardware_serial_init ( )
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " hardware_serial_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
def hardware_serial_init ( self , sender = None ) :
2022-10-15 02:35:40 -06:00
if not self . hardware_serial_ready :
2023-10-22 09:44:44 -06:00
if not self . root . ids . screen_manager . has_screen ( " hardware_serial_screen " ) :
self . hardware_serial_screen = Builder . load_string ( layout_hardware_serial_screen )
self . hardware_serial_screen . app = self
self . root . ids . screen_manager . add_widget ( self . hardware_serial_screen )
self . hardware_serial_screen . ids . hardware_serial_scrollview . effect_cls = ScrollEffect
2022-10-15 02:35:40 -06:00
def save_connectivity ( sender = None , event = None ) :
if self . hardware_serial_validate ( ) :
self . hardware_serial_save ( )
def focus_save ( sender = None , event = None ) :
if sender != None :
if not sender . focus :
save_connectivity ( sender = sender )
if self . sideband . config [ " hw_serial_baudrate " ] != None :
t_b = str ( self . sideband . config [ " hw_serial_baudrate " ] )
else :
t_b = " "
if self . sideband . config [ " hw_serial_databits " ] != None :
t_db = str ( self . sideband . config [ " hw_serial_databits " ] )
else :
t_db = " "
if self . sideband . config [ " hw_serial_parity " ] != None :
t_p = str ( self . sideband . config [ " hw_serial_parity " ] )
else :
t_p = " "
if self . sideband . config [ " hw_serial_stopbits " ] != None :
t_sb = str ( self . sideband . config [ " hw_serial_stopbits " ] )
else :
t_sb = " "
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_baudrate . text = t_b
self . hardware_serial_screen . ids . hardware_serial_databits . text = t_db
self . hardware_serial_screen . ids . hardware_serial_parity . text = t_p
self . hardware_serial_screen . ids . hardware_serial_stopbits . text = t_sb
self . hardware_serial_screen . ids . hardware_serial_baudrate . bind ( focus = focus_save )
self . hardware_serial_screen . ids . hardware_serial_databits . bind ( focus = focus_save )
self . hardware_serial_screen . ids . hardware_serial_parity . bind ( focus = focus_save )
self . hardware_serial_screen . ids . hardware_serial_stopbits . bind ( focus = focus_save )
self . hardware_serial_screen . ids . hardware_serial_baudrate . bind ( on_text_validate = save_connectivity )
self . hardware_serial_screen . ids . hardware_serial_databits . bind ( on_text_validate = save_connectivity )
self . hardware_serial_screen . ids . hardware_serial_parity . bind ( on_text_validate = save_connectivity )
self . hardware_serial_screen . ids . hardware_serial_stopbits . bind ( on_text_validate = save_connectivity )
2022-10-15 02:35:40 -06:00
def hardware_serial_validate ( self , sender = None ) :
valid = True
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_serial_screen . ids . hardware_serial_baudrate . text )
2022-10-15 02:35:40 -06:00
if not val > 0 :
raise ValueError ( " Invalid baudrate " )
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_baudrate . error = False
self . hardware_serial_screen . ids . hardware_serial_baudrate . text = str ( val )
2022-10-15 02:35:40 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_baudrate . error = True
2022-10-15 02:35:40 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_serial_screen . ids . hardware_serial_databits . text )
2022-10-15 02:35:40 -06:00
if not val > 0 :
raise ValueError ( " Invalid databits " )
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_databits . error = False
self . hardware_serial_screen . ids . hardware_serial_databits . text = str ( val )
2022-10-15 02:35:40 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_databits . error = True
2022-10-15 02:35:40 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = int ( self . hardware_serial_screen . ids . hardware_serial_stopbits . text )
2022-10-15 02:35:40 -06:00
if not val > 0 :
raise ValueError ( " Invalid stopbits " )
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_stopbits . error = False
self . hardware_serial_screen . ids . hardware_serial_stopbits . text = str ( val )
2022-10-15 02:35:40 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_stopbits . error = True
2022-10-15 02:35:40 -06:00
valid = False
try :
2023-10-22 09:44:44 -06:00
val = self . hardware_serial_screen . ids . hardware_serial_parity . text
2022-10-15 02:35:40 -06:00
nval = val . lower ( )
if nval in [ " e " , " ev " , " eve " , " even " ] :
val = " even "
if nval in [ " o " , " od " , " odd " ] :
val = " odd "
if nval in [ " n " , " no " , " non " , " none " , " not " , " null " , " off " ] :
val = " none "
if not val in [ " even " , " odd " , " none " ] :
raise ValueError ( " Invalid parity " )
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_parity . error = False
self . hardware_serial_screen . ids . hardware_serial_parity . text = str ( val )
2022-10-15 02:35:40 -06:00
except :
2023-10-22 09:44:44 -06:00
self . hardware_serial_screen . ids . hardware_serial_parity . error = True
2022-10-15 02:35:40 -06:00
valid = False
return valid
def hardware_serial_save ( self ) :
2023-10-22 09:44:44 -06:00
self . sideband . config [ " hw_serial_baudrate " ] = int ( self . hardware_serial_screen . ids . hardware_serial_baudrate . text )
self . sideband . config [ " hw_serial_databits " ] = int ( self . hardware_serial_screen . ids . hardware_serial_databits . text )
self . sideband . config [ " hw_serial_parity " ] = self . hardware_serial_screen . ids . hardware_serial_parity . text
self . sideband . config [ " hw_serial_stopbits " ] = int ( self . hardware_serial_screen . ids . hardware_serial_stopbits . text )
2022-10-15 02:35:40 -06:00
self . sideband . save_configuration ( )
2022-10-13 10:37:59 -06:00
2022-04-07 13:03:53 -06:00
### Announce Stream screen
######################################
2022-10-06 08:07:03 -06:00
def init_announces_view ( self , sender = None ) :
if not self . announces_view :
self . announces_view = Announces ( self )
self . sideband . setstate ( " app.flags.new_announces " , True )
2022-04-07 13:03:53 -06:00
2023-10-22 07:49:00 -06:00
for child in self . announces_view . ids . announces_scrollview . children :
self . announces_view . ids . announces_scrollview . remove_widget ( child )
2022-04-07 13:03:53 -06:00
2023-10-22 07:49:00 -06:00
self . announces_view . ids . announces_scrollview . effect_cls = ScrollEffect
self . announces_view . ids . announces_scrollview . add_widget ( self . announces_view . get_widget ( ) )
2022-04-07 13:03:53 -06:00
2022-10-06 08:07:03 -06:00
def announces_action ( self , sender = None ) :
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . nav_drawer . set_state ( " closed " )
if self . sideband . getstate ( " app.flags.new_announces " ) :
self . init_announces_view ( )
self . announces_view . update ( )
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . current = " announces_screen "
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
def close_announces_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2022-04-07 13:03:53 -06:00
def announce_filter_action ( self , sender = None ) :
pass
2022-10-06 08:07:03 -06:00
def screen_transition_complete ( self , sender ) :
if self . root . ids . screen_manager . current == " announces_screen " :
pass
2022-10-07 09:22:03 -06:00
if self . root . ids . screen_manager . current == " conversations_screen " :
pass
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
### Keys screen
######################################
2022-04-07 13:03:53 -06:00
def keys_action ( self , sender = None ) :
2023-10-22 09:14:32 -06:00
if not self . root . ids . screen_manager . has_screen ( " keys_screen " ) :
self . keys_screen = Builder . load_string ( layout_keys_screen )
self . keys_screen . app = self
self . root . ids . screen_manager . add_widget ( self . keys_screen )
2022-09-17 14:55:27 -06:00
2023-10-22 09:14:32 -06:00
self . keys_screen . ids . keys_scrollview . effect_cls = ScrollEffect
2022-09-20 09:35:14 -06:00
info = " Your primary encryption keys are stored in a Reticulum Identity within the Sideband app. If you want to backup this Identity for later use on this or another device, you can export it as a plain text blob, with the key data encoded in Base32 format. This will allow you to restore your address in Sideband or other LXMF clients at a later point. \n \n [b]Warning![/b] Anyone that gets access to the key data will be able to control your LXMF address, impersonate you, and read your messages. In is [b]extremely important[/b] that you keep the Identity data secure if you export it. \n \n Before displaying or exporting your Identity data, make sure that no machine or person in your vicinity is able to see, copy or record your device screen or similar. "
2022-09-17 14:55:27 -06:00
if not RNS . vendor . platformutils . get_platform ( ) == " android " :
2023-10-22 09:14:32 -06:00
self . widget_hide ( self . keys_screen . ids . keys_share )
2022-04-07 13:03:53 -06:00
2023-10-22 09:14:32 -06:00
self . keys_screen . ids . keys_info . text = info
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " keys_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
def close_keys_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
def identity_display_action ( self , sender = None ) :
2022-10-13 15:36:41 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
dialog = MDDialog (
text = " Your Identity key, in base32 format is as follows: \n \n [b] " + str ( base64 . b32encode ( self . sideband . identity . get_private_key ( ) ) . decode ( " utf-8 " ) ) + " [/b] " ,
buttons = [ yes_button ] ,
2022-10-02 16:56:39 -06:00
# elevation=0,
2022-09-17 14:55:27 -06:00
)
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
def identity_copy_action ( self , sender = None ) :
2022-10-13 15:41:05 -06:00
c_yes_button = MDRectangleFlatButton ( text = " Yes " , font_size = dp ( 18 ) , theme_text_color = " Custom " , line_color = self . color_reject , text_color = self . color_reject )
2022-10-13 15:36:41 -06:00
c_no_button = MDRectangleFlatButton ( text = " No, go back " , font_size = dp ( 18 ) )
2022-10-03 14:36:44 -06:00
c_dialog = MDDialog ( text = " [b]Caution![/b] \n \n Your Identity key will be copied to the system clipboard. Take extreme care that no untrusted app steals your key by reading the clipboard data. Clear the system clipboard immediately after pasting your key where you need it. \n \n Are you sure that you wish to proceed? " , buttons = [ c_no_button , c_yes_button ] )
2022-09-17 14:55:27 -06:00
def c_dl_no ( s ) :
c_dialog . dismiss ( )
def c_dl_yes ( s ) :
c_dialog . dismiss ( )
2022-10-13 15:36:41 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " )
2022-10-03 14:36:44 -06:00
dialog = MDDialog ( text = " Your Identity key was copied to the system clipboard " , buttons = [ yes_button ] )
2022-09-17 14:55:27 -06:00
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
Clipboard . copy ( str ( base64 . b32encode ( self . sideband . identity . get_private_key ( ) ) . decode ( " utf-8 " ) ) )
dialog . open ( )
c_yes_button . bind ( on_release = c_dl_yes )
c_no_button . bind ( on_release = c_dl_no )
c_dialog . open ( )
def identity_share_action ( self , sender = None ) :
if RNS . vendor . platformutils . get_platform ( ) == " android " :
self . share_text ( str ( base64 . b32encode ( self . sideband . identity . get_private_key ( ) ) . decode ( " utf-8 " ) ) )
def identity_restore_action ( self , sender = None ) :
2022-10-13 15:41:05 -06:00
c_yes_button = MDRectangleFlatButton ( text = " Yes " , font_size = dp ( 18 ) , theme_text_color = " Custom " , line_color = self . color_reject , text_color = self . color_reject )
2022-10-13 15:36:41 -06:00
c_no_button = MDRectangleFlatButton ( text = " No, go back " , font_size = dp ( 18 ) )
2022-10-03 14:36:44 -06:00
c_dialog = MDDialog ( text = " [b]Caution![/b] \n \n You are about to import a new Identity key into Sideband. The currently active key will be irreversibly destroyed, and you will loose your LXMF address if you have not already backed up your current Identity key. \n \n Are you sure that you wish to import the key? " , buttons = [ c_no_button , c_yes_button ] )
2022-09-17 14:55:27 -06:00
def c_dl_no ( s ) :
c_dialog . dismiss ( )
def c_dl_yes ( s ) :
c_dialog . dismiss ( )
2023-10-22 09:14:32 -06:00
b32_text = self . keys_screen . ids . key_restore_text . text
2022-09-17 14:55:27 -06:00
try :
key_bytes = base64 . b32decode ( b32_text )
new_id = RNS . Identity . from_bytes ( key_bytes )
if new_id != None :
new_id . to_file ( self . sideband . identity_path )
2022-10-13 15:36:41 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-03 14:36:44 -06:00
dialog = MDDialog ( text = " [b]The provided Identity key data was imported[/b] \n \n The app will now exit. Please restart Sideband to use the new Identity. " , buttons = [ yes_button ] )
2022-09-17 14:55:27 -06:00
def dl_yes ( s ) :
dialog . dismiss ( )
self . quit_action ( sender = self )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
except Exception as e :
2022-10-13 15:36:41 -06:00
yes_button = MDRectangleFlatButton ( text = " OK " , font_size = dp ( 18 ) )
2022-10-03 14:36:44 -06:00
dialog = MDDialog ( text = " [b]The provided Identity key data was not valid[/b] \n \n The error reported by Reticulum was: \n \n [i] " + str ( e ) + " [/i] \n \n No Identity was imported into Sideband. " , buttons = [ yes_button ] )
2022-09-17 14:55:27 -06:00
def dl_yes ( s ) :
dialog . dismiss ( )
yes_button . bind ( on_release = dl_yes )
dialog . open ( )
c_yes_button . bind ( on_release = c_dl_yes )
c_no_button . bind ( on_release = c_dl_no )
c_dialog . open ( )
2022-04-07 13:03:53 -06:00
2023-10-19 18:41:05 -06:00
### Telemetry Screen
######################################
def telemetry_init ( self ) :
if not self . telemetry_ready :
2023-10-22 07:49:00 -06:00
if not self . root . ids . screen_manager . has_screen ( " telemetry_screen " ) :
self . telemetry_screen = Builder . load_string ( layout_telemetry_screen )
self . telemetry_screen . app = self
self . root . ids . screen_manager . add_widget ( self . telemetry_screen )
self . telemetry_screen . ids . telemetry_collector . bind ( focus = self . telemetry_save )
2023-10-19 18:41:05 -06:00
if self . sideband . config [ " telemetry_collector " ] == None :
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_collector . text = " "
2023-10-19 18:41:05 -06:00
else :
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_collector . text = RNS . hexrep ( self . sideband . config [ " telemetry_collector " ] , delimit = False )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_icon_preview . icon_color = self . sideband . config [ " telemetry_fg " ]
self . telemetry_screen . ids . telemetry_icon_preview . md_bg_color = self . sideband . config [ " telemetry_bg " ]
self . telemetry_screen . ids . telemetry_icon_preview . icon = self . sideband . config [ " telemetry_icon " ]
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_enabled . active = self . sideband . config [ " telemetry_enabled " ]
self . telemetry_screen . ids . telemetry_enabled . bind ( active = self . telemetry_enabled_toggle )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_send_to_collector . active = self . sideband . config [ " telemetry_send_to_collector " ]
self . telemetry_screen . ids . telemetry_send_to_collector . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_send_to_trusted . active = self . sideband . config [ " telemetry_send_to_trusted " ]
self . telemetry_screen . ids . telemetry_send_to_trusted . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 17:26:44 -06:00
self . telemetry_screen . ids . telemetry_display_trusted_only . active = self . sideband . config [ " telemetry_display_trusted_only " ]
self . telemetry_screen . ids . telemetry_display_trusted_only . bind ( active = self . telemetry_save )
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_send_appearance . active = self . sideband . config [ " telemetry_send_appearance " ]
self . telemetry_screen . ids . telemetry_send_appearance . bind ( active = self . telemetry_save )
2023-10-20 15:38:28 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_location . active = self . sideband . config [ " telemetry_s_location " ]
self . telemetry_screen . ids . telemetry_s_location . bind ( active = self . telemetry_location_toggle )
2023-10-19 18:41:05 -06:00
2023-10-23 17:14:59 -06:00
self . telemetry_screen . ids . telemetry_s_fixed_location . active = self . sideband . config [ " telemetry_s_fixed_location " ]
self . telemetry_screen . ids . telemetry_s_fixed_location . bind ( active = self . telemetry_location_toggle )
self . telemetry_screen . ids . telemetry_s_fixed_latlon . bind ( focus = self . telemetry_save )
self . telemetry_screen . ids . telemetry_s_fixed_altitude . bind ( focus = self . telemetry_save )
self . telemetry_screen . ids . telemetry_s_fixed_altitude . text = str ( self . sideband . config [ " telemetry_s_fixed_altitude " ] )
try :
lat = self . sideband . config [ " telemetry_s_fixed_latlon " ] [ 0 ] ; lon = self . sideband . config [ " telemetry_s_fixed_latlon " ] [ 1 ]
except :
lat = 0.0 ; lon = 0.0
self . telemetry_screen . ids . telemetry_s_fixed_latlon . text = f " { lat } , { lon } "
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_battery . active = self . sideband . config [ " telemetry_s_battery " ]
self . telemetry_screen . ids . telemetry_s_battery . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_barometer . active = self . sideband . config [ " telemetry_s_pressure " ]
self . telemetry_screen . ids . telemetry_s_barometer . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_temperature . active = self . sideband . config [ " telemetry_s_temperature " ]
self . telemetry_screen . ids . telemetry_s_temperature . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_humidity . active = self . sideband . config [ " telemetry_s_humidity " ]
self . telemetry_screen . ids . telemetry_s_humidity . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_compass . active = self . sideband . config [ " telemetry_s_magnetic_field " ]
self . telemetry_screen . ids . telemetry_s_compass . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_light . active = self . sideband . config [ " telemetry_s_ambient_light " ]
self . telemetry_screen . ids . telemetry_s_light . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_gravity . active = self . sideband . config [ " telemetry_s_gravity " ]
self . telemetry_screen . ids . telemetry_s_gravity . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_gyroscope . active = self . sideband . config [ " telemetry_s_angular_velocity " ]
self . telemetry_screen . ids . telemetry_s_gyroscope . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_accelerometer . active = self . sideband . config [ " telemetry_s_acceleration " ]
self . telemetry_screen . ids . telemetry_s_accelerometer . bind ( active = self . telemetry_save )
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_s_proximity . active = self . sideband . config [ " telemetry_s_proximity " ]
self . telemetry_screen . ids . telemetry_s_proximity . bind ( active = self . telemetry_save )
2023-10-25 15:21:06 -06:00
self . telemetry_screen . ids . telemetry_s_information . active = self . sideband . config [ " telemetry_s_information " ]
self . telemetry_screen . ids . telemetry_s_information . bind ( active = self . telemetry_save )
self . telemetry_screen . ids . telemetry_s_information_text . text = str ( self . sideband . config [ " telemetry_s_information_text " ] )
self . telemetry_screen . ids . telemetry_s_information_text . bind ( focus = self . telemetry_save )
2023-10-19 18:41:05 -06:00
self . telemetry_ready = True
def telemetry_set_icon ( self , text = " " , search = False ) :
if text in md_icons . keys ( ) :
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_icon_preview . icon = text
2023-10-19 18:41:05 -06:00
else :
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_icon_preview . icon = " alpha-p-circle-outline "
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . sideband . config [ " telemetry_icon " ] = self . telemetry_screen . ids . telemetry_icon_preview . icon
2023-10-19 18:41:05 -06:00
self . sideband . save_configuration ( )
2023-10-21 17:12:55 -06:00
self . own_appearance_changed = True
2023-10-19 18:41:05 -06:00
2023-10-20 07:09:48 -06:00
def telemetry_enabled_toggle ( self , sender = None , event = None ) :
self . telemetry_save ( )
2023-10-22 07:49:00 -06:00
if self . telemetry_screen . ids . telemetry_enabled . active :
2023-10-20 07:09:48 -06:00
self . sideband . run_telemetry ( )
else :
self . sideband . stop_telemetry ( )
2023-10-20 05:00:29 -06:00
def telemetry_location_toggle ( self , sender = None , event = None ) :
2023-10-23 17:14:59 -06:00
if sender == self . telemetry_screen . ids . telemetry_s_location :
if self . telemetry_screen . ids . telemetry_s_location . active :
self . telemetry_screen . ids . telemetry_s_fixed_location . active = False
if sender == self . telemetry_screen . ids . telemetry_s_fixed_location :
if self . telemetry_screen . ids . telemetry_s_fixed_location . active :
self . telemetry_screen . ids . telemetry_s_location . active = False
2023-10-22 07:49:00 -06:00
if self . telemetry_screen . ids . telemetry_s_location . active :
2023-10-21 17:12:55 -06:00
if RNS . vendor . platformutils . is_android ( ) :
if not check_permission ( " android.permission.ACCESS_COARSE_LOCATION " ) or not check_permission ( " android.permission.ACCESS_FINE_LOCATION " ) :
RNS . log ( " Requesting location permission " , RNS . LOG_DEBUG )
request_permissions ( [ " android.permission.ACCESS_COARSE_LOCATION " , " android.permission.ACCESS_FINE_LOCATION " ] )
2023-10-20 05:00:29 -06:00
self . telemetry_save ( )
2023-10-19 18:41:05 -06:00
def telemetry_save ( self , sender = None , event = None ) :
2023-10-22 07:49:00 -06:00
if len ( self . telemetry_screen . ids . telemetry_collector . text ) != 32 :
self . telemetry_screen . ids . telemetry_collector . text = " "
2023-10-19 18:41:05 -06:00
self . sideband . config [ " telemetry_collector " ] = None
else :
try :
2023-10-22 07:49:00 -06:00
self . sideband . config [ " telemetry_collector " ] = bytes . fromhex ( self . telemetry_screen . ids . telemetry_collector . text )
2023-10-19 18:41:05 -06:00
except :
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_collector . text = " "
2023-10-19 18:41:05 -06:00
self . sideband . config [ " telemetry_collector " ] = None
2023-10-22 07:49:00 -06:00
self . sideband . config [ " telemetry_enabled " ] = self . telemetry_screen . ids . telemetry_enabled . active
self . sideband . config [ " telemetry_send_to_collector " ] = self . telemetry_screen . ids . telemetry_send_to_collector . active
self . sideband . config [ " telemetry_send_to_trusted " ] = self . telemetry_screen . ids . telemetry_send_to_trusted . active
2023-10-22 17:26:44 -06:00
self . sideband . config [ " telemetry_display_trusted_only " ] = self . telemetry_screen . ids . telemetry_display_trusted_only . active
2023-10-22 07:49:00 -06:00
self . sideband . config [ " telemetry_send_appearance " ] = self . telemetry_screen . ids . telemetry_send_appearance . active
2023-10-19 18:41:05 -06:00
2023-10-22 07:49:00 -06:00
self . sideband . config [ " telemetry_s_location " ] = self . telemetry_screen . ids . telemetry_s_location . active
2023-10-23 17:14:59 -06:00
self . sideband . config [ " telemetry_s_fixed_location " ] = self . telemetry_screen . ids . telemetry_s_fixed_location . active
2023-10-22 07:49:00 -06:00
self . sideband . config [ " telemetry_s_battery " ] = self . telemetry_screen . ids . telemetry_s_battery . active
self . sideband . config [ " telemetry_s_pressure " ] = self . telemetry_screen . ids . telemetry_s_barometer . active
self . sideband . config [ " telemetry_s_temperature " ] = self . telemetry_screen . ids . telemetry_s_temperature . active
self . sideband . config [ " telemetry_s_humidity " ] = self . telemetry_screen . ids . telemetry_s_humidity . active
self . sideband . config [ " telemetry_s_magnetic_field " ] = self . telemetry_screen . ids . telemetry_s_compass . active
self . sideband . config [ " telemetry_s_ambient_light " ] = self . telemetry_screen . ids . telemetry_s_light . active
self . sideband . config [ " telemetry_s_gravity " ] = self . telemetry_screen . ids . telemetry_s_gravity . active
self . sideband . config [ " telemetry_s_angular_velocity " ] = self . telemetry_screen . ids . telemetry_s_gyroscope . active
self . sideband . config [ " telemetry_s_acceleration " ] = self . telemetry_screen . ids . telemetry_s_accelerometer . active
self . sideband . config [ " telemetry_s_proximity " ] = self . telemetry_screen . ids . telemetry_s_proximity . active
2023-10-23 17:14:59 -06:00
2023-10-25 10:49:30 -06:00
run_telemetry_update = False
2023-10-26 03:53:42 -06:00
if self . sideband . config [ " telemetry_s_information " ] != self . telemetry_screen . ids . telemetry_s_information . active :
self . sideband . config [ " telemetry_s_information " ] = self . telemetry_screen . ids . telemetry_s_information . active
run_telemetry_update = True
if self . sideband . config [ " telemetry_s_information_text " ] != self . telemetry_screen . ids . telemetry_s_information_text . text :
self . sideband . config [ " telemetry_s_information_text " ] = self . telemetry_screen . ids . telemetry_s_information_text . text
run_telemetry_update = True
2023-10-23 17:14:59 -06:00
try :
alt = float ( self . telemetry_screen . ids . telemetry_s_fixed_altitude . text . strip ( ) . replace ( " " , " " ) )
self . telemetry_screen . ids . telemetry_s_fixed_altitude . text = str ( alt )
2023-10-25 10:49:30 -06:00
if self . sideband . config [ " telemetry_s_fixed_altitude " ] != alt :
self . sideband . config [ " telemetry_s_fixed_altitude " ] = alt
run_telemetry_update = True
2023-10-23 17:14:59 -06:00
except :
self . telemetry_screen . ids . telemetry_s_fixed_altitude . text = str ( self . sideband . config [ " telemetry_s_fixed_altitude " ] )
try :
s = self . telemetry_screen . ids . telemetry_s_fixed_latlon . text
l = s . strip ( ) . replace ( " " , " " ) . split ( " , " )
lat = float ( l [ 0 ] ) ; lon = float ( l [ 1 ] )
2023-10-25 10:49:30 -06:00
if self . sideband . config [ " telemetry_s_fixed_latlon " ] != [ lat , lon ] :
run_telemetry_update = True
2023-10-23 17:14:59 -06:00
self . sideband . config [ " telemetry_s_fixed_latlon " ] = [ lat , lon ]
self . telemetry_screen . ids . telemetry_s_fixed_latlon . text = f " { lat } , { lon } "
except :
try :
lat = self . sideband . config [ " telemetry_s_fixed_latlon " ] [ 0 ]
lon = self . sideband . config [ " telemetry_s_fixed_latlon " ] [ 1 ]
self . telemetry_screen . ids . telemetry_s_fixed_latlon . text = f " { lat } , { lon } "
except :
self . sideband . config [ " telemetry_s_fixed_latlon " ] = [ 0.0 , 0.0 ]
self . telemetry_screen . ids . telemetry_s_fixed_latlon . text = " 0.0, 0.0 "
2023-10-19 18:41:05 -06:00
self . sideband . save_configuration ( )
2023-10-25 10:49:30 -06:00
if run_telemetry_update :
self . sideband . update_telemetry ( )
else :
self . sideband . setstate ( " app.flags.last_telemetry " , time . time ( ) )
2023-10-19 18:41:05 -06:00
def telemetry_action ( self , sender = None , direction = " left " ) :
self . telemetry_init ( )
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_scrollview . effect_cls = ScrollEffect
2023-10-20 05:00:29 -06:00
info = " \n Sideband allows you to securely share telemetry, such as location and sensor data, with people, custom programs, machines or other system over LXMF. You have complete control over what kind of telemetry to send, and who you share it with. \n \n Telemetry data is never sent to, via or processed by any external services or servers, but is carried exclusively within encrypted LXMF messages over Reticulum. \n \n When telemetry is enabled, it is possible to embed telemetry data in normal messages on a per-peer basis. You can control this from the [b]Conversations[/b] list, by selecting the [b]Edit[/b] option for the relevant peer. \n \n You can also define a [b]Telemetry Collector[/b], that Sideband will automatically send telemetry to on a periodic basis - for example your Nomad Network home node. \n "
2023-10-19 18:41:05 -06:00
info3 = " \n To include a specific type of telemetry data while sending, it must be enabled below. Please note that some sensor types are not supported on all devices. Sideband will only be able to read a specific type of sensor if your device actually includes hardware for it. \n "
if self . theme_cls . theme_style == " Dark " :
info = " [color=# " + dark_theme_text_color + " ] " + info + " [/color] "
# info2 = "[color=#"+dark_theme_text_color+"]"+info2+"[/color]"
info3 = " [color=# " + dark_theme_text_color + " ] " + info3 + " [/color] "
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_info . text = info
2023-10-19 18:41:05 -06:00
# self.root.ids.telemetry_info2.text = info2
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_info3 . text = info3
2023-10-19 18:41:05 -06:00
self . root . ids . screen_manager . transition . direction = direction
self . root . ids . screen_manager . current = " telemetry_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2023-10-20 05:00:29 -06:00
def telemetry_copy ( self , sender = None ) :
Clipboard . copy ( str ( self . sideband . get_telemetry ( ) ) )
2023-10-22 05:16:43 -06:00
self . sideband . update_telemetry ( )
2023-10-20 05:00:29 -06:00
2023-10-20 07:09:48 -06:00
def telemetry_send_update ( self , sender = None ) :
2023-10-20 05:00:29 -06:00
# TODO: Implement
2023-10-22 17:26:44 -06:00
pass
def telemetry_request_action ( self , sender = None ) :
# TODO: Implement
pass
2023-10-20 05:00:29 -06:00
2023-10-19 18:41:05 -06:00
def telemetry_fg_color ( self , sender = None ) :
color_picker = MDColorPicker ( size_hint = ( 0.85 , 0.85 ) )
self . color_picker = color_picker
2023-10-22 07:49:00 -06:00
color_picker . open ( )
color_picker . bind ( on_release = self . telemetry_fg_select )
def job ( sender = None ) :
2023-10-22 08:02:39 -06:00
color_picker . _rgb = self . sideband . config [ " telemetry_fg " ] [ 0 : 3 ]
2023-10-22 07:49:00 -06:00
color_picker . ids . view_headline . on_tab_press ( )
Clock . schedule_once ( job , 0 )
2023-10-19 18:41:05 -06:00
def telemetry_fg_select ( self , instance_color_picker : MDColorPicker , type_color : str , selected_color : Union [ list , str ] ) :
2023-10-22 08:02:39 -06:00
s = selected_color ; color = [ s [ 0 ] , s [ 1 ] , s [ 2 ] , 1 ]
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_icon_preview . icon_color = color
2023-10-19 18:41:05 -06:00
self . sideband . config [ " telemetry_fg " ] = color
self . sideband . save_configuration ( )
2023-10-21 17:12:55 -06:00
self . own_appearance_changed = True
2023-10-19 18:41:05 -06:00
if hasattr ( self , " color_picker " ) and self . color_picker != None :
self . color_picker . dismiss ( )
self . color_picker = None
def telemetry_bg_color ( self , sender = None ) :
color_picker = MDColorPicker ( size_hint = ( 0.85 , 0.85 ) )
self . color_picker = color_picker
2023-10-22 07:49:00 -06:00
color_picker . open ( )
color_picker . bind ( on_release = self . telemetry_bg_select )
def job ( sender = None ) :
2023-10-22 08:02:39 -06:00
color_picker . _rgb = self . sideband . config [ " telemetry_bg " ] [ 0 : 3 ]
2023-10-22 07:49:00 -06:00
color_picker . ids . view_headline . on_tab_press ( )
Clock . schedule_once ( job , 0 )
2023-10-19 18:41:05 -06:00
def telemetry_bg_select ( self , instance_color_picker : MDColorPicker , type_color : str , selected_color : Union [ list , str ] ) :
2023-10-22 08:02:39 -06:00
s = selected_color ; color = [ s [ 0 ] , s [ 1 ] , s [ 2 ] , 1 ]
2023-10-22 07:49:00 -06:00
self . telemetry_screen . ids . telemetry_icon_preview . md_bg_color = color
2023-10-19 18:41:05 -06:00
self . sideband . config [ " telemetry_bg " ] = color
2023-10-21 17:12:55 -06:00
self . sideband . save_configuration ( )
self . own_appearance_changed = True
2023-10-19 18:41:05 -06:00
if hasattr ( self , " color_picker " ) and self . color_picker != None :
self . color_picker . dismiss ( )
self . color_picker = None
def close_sub_telemetry_action ( self , sender = None ) :
self . telemetry_action ( direction = " right " )
### Icons Screen
######################################
def icons_action ( self , sender = None ) :
2023-10-22 07:49:00 -06:00
if not self . root . ids . screen_manager . has_screen ( " icons_screen " ) :
self . icons_screen = Builder . load_string ( layout_icons_screen )
self . icons_screen . app = self
self . root . ids . screen_manager . add_widget ( self . icons_screen )
2023-10-19 18:41:05 -06:00
self . icons_filter ( )
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " icons_screen "
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
def icons_selected ( self , selected = None ) :
RNS . log ( " Selected: " + str ( selected ) )
if selected == None :
selected = " alpha-p-circle-outline "
self . telemetry_set_icon ( selected )
self . close_sub_telemetry_action ( )
def icons_filter ( self , text = " " , search = False ) :
def add_icon_item ( name_icon ) :
def select_factory ( x ) :
def f ( ) :
2023-10-22 07:49:00 -06:00
self . icons_selected ( x )
2023-10-19 18:41:05 -06:00
return f
2023-10-22 07:49:00 -06:00
self . icons_screen . ids . icons_rv . data . append (
2023-10-19 18:41:05 -06:00
{
" viewclass " : " CustomOneLineIconListItem " ,
" icon " : name_icon ,
" text " : name_icon ,
" callback " : lambda x : x ,
" on_release " : select_factory ( name_icon )
}
)
2023-10-22 07:49:00 -06:00
self . icons_screen . ids . icons_rv . data = [ ]
2023-10-19 18:41:05 -06:00
for name_icon in md_icons . keys ( ) :
if search :
if text in name_icon :
add_icon_item ( name_icon )
else :
add_icon_item ( name_icon )
### Map Screen
######################################
2023-10-25 18:28:41 -06:00
def map_fm_got_path ( self , path ) :
self . map_fm_exited ( )
# TODO: Remove
toast ( path )
###
try :
source = MBTilesMapSource ( path )
self . map_update_source ( source )
self . sideband . config [ " map_storage_file " ] = path
self . sideband . save_configuration ( )
except Exception as e :
RNS . log ( f " Error while loading map \" { path } \" : " + str ( e ) , RNS . LOG_ERROR )
selfmap_update_source ( )
def map_fm_exited ( self , * args ) :
RNS . log ( " Closing file manager " , RNS . LOG_DEBUG )
self . sideband . config [ " map_storage_file " ] = None
self . sideband . save_configuration ( )
self . manager_open = False
self . file_manager . close ( )
self . map_update_source ( )
def map_get_source ( self ) :
current_map_path = self . sideband . config [ " map_storage_file " ]
source = None
if current_map_path :
try :
source = MBTilesMapSource ( current_map_path )
except Exception as e :
RNS . log ( f " Error while loading map from \" { current_map_path } \" : " + str ( e ) )
self . sideband . config [ " map_storage_file " ] = None
self . sideband . save_configuration ( )
if source == None :
source = MapSource . from_provider ( " osm " )
return source
def map_update_source ( self , source = None ) :
ns = source or self . map_get_source ( )
if self . map != None :
self . map . map_source = ns
def map_test_action ( self , sender = None ) :
perm_ok = False
if RNS . vendor . platformutils . is_android ( ) :
perm_ok = self . check_storage_permission ( )
if self . sideband . config [ " map_storage_external " ] :
path = secondary_external_storage_path ( )
if path == None : path = primary_external_storage_path ( )
else :
path = primary_external_storage_path ( )
else :
perm_ok = True
path = os . path . expanduser ( " ~ " )
if perm_ok and path != None :
self . file_manager = MDFileManager (
exit_manager = self . map_fm_exited ,
select_path = self . map_fm_got_path ,
)
self . file_manager . ext = [ " .mbtiles " ]
self . file_manager . show ( path )
else :
toast ( " No file access, check permissions! " )
2023-10-22 17:26:44 -06:00
def map_action ( self , sender = None , direction = " left " ) :
2023-10-22 07:49:00 -06:00
if not self . root . ids . screen_manager . has_screen ( " map_screen " ) :
self . map_screen = Builder . load_string ( layout_map_screen )
self . map_screen . app = self
self . root . ids . screen_manager . add_widget ( self . map_screen )
2023-10-19 18:41:05 -06:00
from mapview import MapView
2023-10-25 18:28:41 -06:00
mapview = MapView ( map_source = self . map_get_source ( ) , zoom = self . sideband . config [ " map_zoom " ] , lat = self . sideband . config [ " map_lat " ] , lon = self . sideband . config [ " map_lon " ] )
2023-10-19 18:41:05 -06:00
mapview . snap_to_zoom = False
2023-10-21 17:12:55 -06:00
mapview . double_tap_zoom = True
2023-10-25 18:28:41 -06:00
self . map = mapview
2023-10-22 07:49:00 -06:00
self . map_screen . ids . map_layout . map = mapview
self . map_screen . ids . map_layout . add_widget ( self . map_screen . ids . map_layout . map )
2023-10-19 18:41:05 -06:00
2023-10-22 17:26:44 -06:00
self . root . ids . screen_manager . transition . direction = direction
2023-10-19 18:41:05 -06:00
self . root . ids . screen_manager . current = " map_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-09-17 14:55:27 -06:00
2023-10-20 15:38:28 -06:00
if not hasattr ( self , " map_markers " ) or self . map_markers == None :
self . map_markers = { }
def am_job ( dt ) :
self . map_update_markers ( )
Clock . schedule_once ( am_job , 0.6 )
2023-10-21 17:12:55 -06:00
def close_location_error_dialog ( self , sender = None ) :
if hasattr ( self , " location_error_dialog " ) and self . location_error_dialog != None :
self . location_error_dialog . dismiss ( )
2023-10-25 18:28:41 -06:00
def map_object_list ( self , sender ) :
pass
2023-10-21 17:12:55 -06:00
def map_show ( self , location ) :
2023-10-25 18:28:41 -06:00
if hasattr ( self , " map " ) and self . map :
self . map . center_on ( location [ " latitude " ] , location [ " longtitude " ] )
# self.map.lat = location["latitude"]
# self.map.lon = location["longtitude"]
self . map . zoom = 16
self . map . trigger_update ( True )
2023-10-21 17:12:55 -06:00
def map_show_peer_location ( self , context_dest ) :
location = self . sideband . peer_location ( context_dest )
if not location :
self . location_error_dialog = MDDialog (
title = " No Location " ,
text = " During the last 24 hours, no location updates have been received from this peer. You can use the the [b]Situation Map[/b] to manually search for earlier telemetry. " ,
buttons = [
MDRectangleFlatButton (
text = " OK " ,
font_size = dp ( 18 ) ,
on_release = self . close_location_error_dialog
)
] ,
)
self . location_error_dialog . open ( )
else :
self . map_action ( )
self . map_show ( location )
2023-10-23 17:14:59 -06:00
def map_display_telemetry ( self , sender = None ) :
self . object_details_action ( sender )
2023-10-22 17:26:44 -06:00
2023-10-25 15:21:06 -06:00
def map_display_own_telemetry ( self , sender = None ) :
self . object_details_action ( source_dest = self . sideband . lxmf_destination . hash , from_telemetry = True )
2023-10-22 17:26:44 -06:00
def close_sub_map_action ( self , sender = None ) :
self . map_action ( direction = " right " )
2023-10-25 15:21:06 -06:00
def object_details_action ( self , sender = None , from_conv = False , from_telemetry = False , source_dest = None ) :
2023-10-22 17:26:44 -06:00
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . nav_drawer . set_state ( " closed " )
2023-10-25 15:21:06 -06:00
if source_dest != None :
telemetry_source = source_dest
else :
if sender != None and hasattr ( sender , " source_dest " ) and sender . source_dest != None :
telemetry_source = sender . source_dest
if telemetry_source != None :
2023-10-23 17:14:59 -06:00
if self . object_details_screen == None :
self . object_details_screen = ObjectDetails ( self )
2023-10-25 15:21:06 -06:00
Clock . schedule_once ( lambda dt : self . object_details_screen . set_source ( telemetry_source , from_conv = from_conv , from_telemetry = from_telemetry ) , 0.0 )
2023-10-23 17:14:59 -06:00
2023-10-25 10:49:30 -06:00
def vj ( dt ) :
self . root . ids . screen_manager . current = " object_details_screen "
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
Clock . schedule_once ( vj , 0.15 )
2023-10-22 17:26:44 -06:00
2023-10-21 17:12:55 -06:00
def map_create_marker ( self , source , telemetry , appearance ) :
try :
l = telemetry [ " location " ]
a_icon = appearance [ 0 ]
a_fg = appearance [ 1 ] ; a_bg = appearance [ 2 ]
marker = CustomMapMarker ( lat = l [ " latitude " ] , lon = l [ " longtitude " ] , icon_bg = a_bg )
2023-10-23 17:14:59 -06:00
marker . app = self
2023-10-21 17:12:55 -06:00
marker . source_dest = source
marker . location_time = l [ " last_update " ]
marker . icon = MDMapIconButton (
icon = a_icon , icon_color = a_fg ,
md_bg_color = a_bg , theme_icon_color = " Custom " ,
icon_size = dp ( 32 ) ,
2023-10-22 17:26:44 -06:00
on_release = self . map_display_telemetry ,
2023-10-21 17:12:55 -06:00
)
marker . icon . _default_icon_pad = dp ( 16 )
2023-10-23 17:14:59 -06:00
marker . icon . source_dest = marker . source_dest
2023-10-21 17:12:55 -06:00
marker . add_widget ( marker . icon )
########
# marker.badge = MDMapIconButton(
# icon="network-strength-2", icon_color=[0,0,0,1],
# md_bg_color=[1,1,1,1], theme_icon_color="Custom",
# icon_size=dp(18),
# )
# marker.badge._default_icon_pad = dp(5)
# marker.icon.add_widget(marker.badge)
########
return marker
except Exception as e :
RNS . log ( " Could not create map marker for " + RNS . prettyhexrep ( source ) + " : " + str ( e ) , RNS . LOG_ERROR )
return None
2023-10-20 15:38:28 -06:00
def map_update_markers ( self , sender = None ) :
2023-10-22 15:13:51 -06:00
RNS . log ( " Updating map markers " , RNS . LOG_DEBUG )
2023-10-20 15:38:28 -06:00
earliest = time . time ( ) - self . sideband . config [ " map_history_limit " ]
telemetry_entries = self . sideband . list_telemetry ( after = earliest )
2023-10-20 17:02:43 -06:00
own_address = self . sideband . lxmf_destination . hash
2023-10-20 15:38:28 -06:00
changes = False
2023-10-20 15:40:51 -06:00
# Add own marker if available
2023-10-20 17:02:43 -06:00
retain_own = False
own_telemetry = self . sideband . get_telemetry ( )
2023-10-21 17:12:55 -06:00
own_appearance = [
self . sideband . config [ " telemetry_icon " ] ,
self . sideband . config [ " telemetry_fg " ] ,
self . sideband . config [ " telemetry_bg " ]
]
2023-10-22 17:26:44 -06:00
skip_entries = [ ]
if self . sideband . config [ " telemetry_display_trusted_only " ] :
for telemetry_source in telemetry_entries :
try :
if not self . sideband . is_trusted ( telemetry_source ) :
skip_entries . append ( telemetry_source )
except :
pass
for skip_entry in skip_entries :
try :
telemetry_entries . pop ( skip_entry )
except :
pass
2023-10-21 17:12:55 -06:00
try :
if own_telemetry != None and " location " in own_telemetry and own_telemetry [ " location " ] != None and own_telemetry [ " location " ] [ " latitude " ] != None and own_telemetry [ " location " ] [ " longtitude " ] != None :
retain_own = True
if not own_address in self . map_markers :
marker = self . map_create_marker ( own_address , own_telemetry , own_appearance )
if marker != None :
self . map_markers [ own_address ] = marker
2023-10-22 07:49:00 -06:00
self . map_screen . ids . map_layout . map . add_marker ( marker )
2023-10-21 17:12:55 -06:00
changes = True
2023-10-20 17:02:43 -06:00
else :
2023-10-21 17:12:55 -06:00
marker = self . map_markers [ own_address ]
o = own_telemetry [ " location " ]
if o [ " last_update " ] > marker . location_time or ( hasattr ( self , " own_appearance_changed " ) and self . own_appearance_changed ) :
marker . location_time = o [ " last_update " ]
marker . lat = o [ " latitude " ]
marker . lon = o [ " longtitude " ]
marker . icon . icon = own_appearance [ 0 ]
marker . icon . icon_color = own_appearance [ 1 ]
marker . icon . md_bg_color = own_appearance [ 2 ]
self . own_appearance_changed = False
changes = True
stale_markers = [ ]
for marker in self . map_markers :
if not marker in telemetry_entries :
if marker == own_address :
if not retain_own :
stale_markers . append ( marker )
else :
2023-10-20 17:02:43 -06:00
stale_markers . append ( marker )
2023-10-21 17:12:55 -06:00
for marker in stale_markers :
2023-10-22 15:13:51 -06:00
RNS . log ( " Removing stale marker: " + str ( marker ) , RNS . LOG_DEBUG )
2023-10-21 17:12:55 -06:00
try :
2023-10-22 15:13:51 -06:00
to_remove = self . map_markers [ marker ]
self . map_screen . ids . map_layout . map . remove_marker ( to_remove )
2023-10-21 17:12:55 -06:00
self . map_markers . pop ( marker )
2023-10-22 15:13:51 -06:00
changes = True
2023-10-21 17:12:55 -06:00
except Exception as e :
RNS . log ( " Error while removing map marker: " + str ( e ) , RNS . LOG_ERROR )
except Exception as e :
RNS . log ( " Error while updating own map marker: " + str ( e ) , RNS . LOG_ERROR )
2023-10-20 17:02:43 -06:00
2023-10-20 15:38:28 -06:00
for telemetry_source in telemetry_entries :
2023-10-21 17:12:55 -06:00
try :
skip = False
if telemetry_source == own_address :
2023-10-20 15:38:28 -06:00
skip = True
2023-10-21 17:12:55 -06:00
elif telemetry_source in self . map_markers :
marker = self . map_markers [ telemetry_source ]
newest_timestamp = telemetry_entries [ telemetry_source ] [ 0 ] [ 0 ]
if newest_timestamp < = marker . location_time :
skip = True
latest_viewable = None
if not skip :
for telemetry_entry in telemetry_entries [ telemetry_source ] :
telemetry_timestamp = telemetry_entry [ 0 ]
telemetry_data = telemetry_entry [ 1 ]
t = Telemeter . from_packed ( telemetry_data )
if t != None :
telemetry = t . read_all ( )
2023-10-22 13:18:37 -06:00
if " location " in telemetry and telemetry [ " location " ] != None and telemetry [ " location " ] [ " latitude " ] != None and telemetry [ " location " ] [ " longtitude " ] != None :
2023-10-21 17:12:55 -06:00
latest_viewable = telemetry
break
if latest_viewable != None :
l = latest_viewable [ " location " ]
if not telemetry_source in self . map_markers :
marker = self . map_create_marker ( telemetry_source , latest_viewable , self . sideband . peer_appearance ( telemetry_source ) )
if marker != None :
self . map_markers [ telemetry_source ] = marker
2023-10-22 07:49:00 -06:00
self . map_screen . ids . map_layout . map . add_marker ( marker )
2023-10-21 17:12:55 -06:00
changes = True
else :
marker = self . map_markers [ telemetry_source ]
marker . location_time = latest_viewable [ " time " ] [ " utc " ]
marker . lat = l [ " latitude " ]
marker . lon = l [ " longtitude " ]
appearance = self . sideband . peer_appearance ( telemetry_source )
marker . icon . icon = appearance [ 0 ]
marker . icon . icon_color = appearance [ 1 ]
marker . icon . md_bg_color = appearance [ 2 ]
changes = True
2023-10-20 15:38:28 -06:00
2023-10-21 17:12:55 -06:00
except Exception as e :
RNS . log ( " Error while updating map entry for " + RNS . prettyhexrep ( telemetry_source ) + " : " + str ( e ) , RNS . LOG_ERROR )
2023-10-20 15:38:28 -06:00
self . last_map_update = time . time ( )
if changes :
2023-10-25 18:28:41 -06:00
self . map . trigger_update ( True )
2023-10-20 15:38:28 -06:00
2022-09-17 14:55:27 -06:00
### Guide screen
######################################
def close_guide_action ( self , sender = None ) :
self . open_conversations ( direction = " right " )
2022-04-07 13:03:53 -06:00
def guide_action ( self , sender = None ) :
2023-10-22 09:14:32 -06:00
if not self . root . ids . screen_manager . has_screen ( " guide_screen " ) :
self . guide_screen = Builder . load_string ( layout_guide_screen )
self . guide_screen . app = self
self . root . ids . screen_manager . add_widget ( self . guide_screen )
2022-04-07 13:03:53 -06:00
def link_exec ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
def lj ( ) :
import webbrowser
webbrowser . open ( " https://unsigned.io/donate " )
if not RNS . vendor . platformutils . is_android ( ) :
threading . Thread ( target = lj , daemon = True ) . start ( )
else :
lj ( )
2022-04-07 13:03:53 -06:00
2022-10-08 16:46:14 -06:00
guide_text1 = """
2022-10-02 05:44:42 -06:00
[ size = 18 dp ] [ b ] Introduction [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] Welcome to [ i ] Sideband [ / i ] , an LXMF client for Android , Linux and macOS . With Sideband , you can communicate with other people or LXMF - compatible systems over Reticulum networks using LoRa , Packet Radio , WiFi , I2P , or anything else Reticulum supports .
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
This short guide will give you a basic introduction to the concepts that underpin Sideband and LXMF ( which is the protocol that Sideband uses to communicate ) . If you are not already familiar with LXMF and Reticulum , it is probably a good idea to read this guide , since Sideband is very different from other messaging apps . """
guide_text2 = """
2022-10-02 05:44:42 -06:00
[ size = 18 dp ] [ b ] Communication Without Subjection [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] Sideband is completely free , permission - less , anonymous and infrastructure - less . Sideband uses the peer - to - peer and distributed messaging system LXMF . There is no sign - up , no service providers , no " end-user license agreements " , no data theft and no surveillance . You own the system .
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
This also means that Sideband operates differently than what you might be used to . It does not need a connection to a server on the Internet to function , and you do not have an account anywhere . """
guide_text3 = """
[ size = 18 dp ] [ b ] Operating Principles [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] When Sideband is started on your device for the first time , it randomly generates a set of cryptographic keys . These keys are then used to create an LXMF address for your use . Any other endpoint in [ i ] any [ / i ] Reticulum network will be able to send data to this address , as long as there is [ i ] some sort of physical connection [ / i ] between your device and the remote endpoint . You can also move around to other Reticulum networks with this address , even ones that were never connected to the network the address was created on , or that didn ' t exist when the address was created. The address is yours to keep and control for as long (or short) a time you need it, and you can always delete it and create a new one. " " "
guide_text4 = """
2022-10-02 05:44:42 -06:00
[ size = 18 dp ] [ b ] Becoming Reachable [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] To establish reachability for any Reticulum address on a network , an [ i ] announce [ / i ] must be sent . Sideband does not do this automatically by default , but can be configured to do so every time the program starts . To send an announce manually , press the [ i ] Announce [ / i ] button in the [ i ] Conversations [ / i ] section of the program . When you send an announce , you make your LXMF address reachable for real - time messaging to the entire network you are connected to . Even in very large networks , you can expect global reachability for your address to be established in under a minute .
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
If you don ' t move to other places in the network, and keep connected through the same hubs or gateways, it is generally not necessary to send an announce more often than once every week. If you change your entry point to the network, you may want to send an announce, or you may just want to stay quiet. " " "
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
guide_text5 = """
2022-10-02 05:44:42 -06:00
[ size = 18 dp ] [ b ] Relax & Disconnect [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] If you are not connected to the network , it is still possible for other people to message you , as long as one or more [ i ] Propagation Nodes [ / i ] exist on the network . These nodes pick up and hold encrypted in - transit messages for offline users . Messages are always encrypted before leaving the originators device , and nobody else than the intended recipient can decrypt messages in transit .
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
The Propagation Nodes also distribute copies of messages between each other , such that even the failure of almost every node in the network will still allow users to sync their waiting messages . If all Propagation Nodes disappear or are destroyed , users can still communicate directly . Reticulum and LXMF will degrade gracefully all the way down to single users communicating directly via long - range data radios . Anyone can start up new propagation nodes and integrate them into existing networks without permission or coordination . Even a small and cheap device like a Rasperry Pi can handle messages for millions of users . LXMF networks are designed to be quite resilient , as long as there are people using them . """
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
guide_text6 = """
[ size = 18 dp ] [ b ] Packets Find A Way [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] Connections in Reticulum networks can be wired or wireless , span many intermediary hops , run over fast links or ultra - low bandwidth radio , tunnel over the Invisible Internet ( I2P ) , private networks , satellite connections , serial lines or anything else that Reticulum can carry data over . In most cases it will not be possible to know what path data takes in a Reticulum network , and no transmitted packets carries any identifying characteristics , apart from a destination address . There is no source addresses in Reticulum . As long as you do not reveal any connecting details between your person and your LXMF address , you can remain anonymous . Sending messages to others does not reveal [ i ] your [ / i ] address to anyone else than the intended recipient . """
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
guide_text7 = """
2022-10-13 14:40:33 -06:00
[ size = 18 dp ] [ b ] Be Yourself , Be Unknown , Stay Free [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] Even with the above characteristics in mind , you [ b ] must remember [ / b ] that LXMF and Reticulum is not a technology that can guarantee anonymising connections that are already de - anonymised ! If you use Sideband to connect to TCP Reticulum hubs over the clear Internet , from a network that can be tied to your personal identity , an adversary may learn that you are generating LXMF traffic . If you want to avoid this , it is recommended to use I2P to connect to Reticulum hubs on the Internet . Or only connecting from within pure Reticulum networks , that take one or more hops to reach connections that span the Internet . This is a complex topic , with many more nuances than can be covered here . You are encouraged to ask on the various Reticulum discussion forums if you are in doubt .
2022-07-06 12:48:46 -06:00
2022-10-08 16:46:14 -06:00
If you use Reticulum and LXMF on hardware that does not carry any identifiers tied to you , it is possible to establish a completely free and anonymous communication system with Reticulum and LXMF clients . """
guide_text8 = """
2022-10-06 09:12:42 -06:00
[ size = 18 dp ] [ b ] Keyboard Shortcuts [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] - Ctrl + Q or Ctrl - W Shut down Sideband
- Ctrl - D or Ctrl - S Send message
- Ctrl - R Show Conversations
- Ctrl - L Show Announce Stream
2023-10-20 15:38:28 -06:00
- Ctrl - M Show Situation Map
- Ctrl - T Show Telemetry Setup
2022-10-06 09:12:42 -06:00
- Ctrl - N New conversation
2022-10-08 16:46:14 -06:00
- Ctrl - G Show guide """
guide_text9 = """
2022-11-03 12:52:27 -06:00
[ size = 18 dp ] [ b ] Sow Seeds Of Freedom [ / b ] [ / size ] [ size = 5 dp ] \n \n [ / size ] It took me more than seven years to design and built the entire ecosystem of software and hardware that makes this possible . If this project is valuable to you , please go to [ u ] [ ref = link ] https : / / unsigned . io / donate [ / ref ] [ / u ] to support the project with a donation . Every donation directly makes the entire Reticulum project possible .
2022-07-06 12:48:46 -06:00
Thank you very much for using Free Communications Systems .
"""
2022-10-08 16:46:14 -06:00
info1 = guide_text1
info2 = guide_text2
info3 = guide_text3
info4 = guide_text4
info5 = guide_text5
info6 = guide_text6
info7 = guide_text7
info8 = guide_text8
info9 = guide_text9
2022-10-02 14:00:15 -06:00
if self . theme_cls . theme_style == " Dark " :
2022-10-08 16:46:14 -06:00
info1 = " [color=# " + dark_theme_text_color + " ] " + info1 + " [/color] "
info2 = " [color=# " + dark_theme_text_color + " ] " + info2 + " [/color] "
info3 = " [color=# " + dark_theme_text_color + " ] " + info3 + " [/color] "
info4 = " [color=# " + dark_theme_text_color + " ] " + info4 + " [/color] "
info5 = " [color=# " + dark_theme_text_color + " ] " + info5 + " [/color] "
info6 = " [color=# " + dark_theme_text_color + " ] " + info6 + " [/color] "
info7 = " [color=# " + dark_theme_text_color + " ] " + info7 + " [/color] "
info8 = " [color=# " + dark_theme_text_color + " ] " + info8 + " [/color] "
info9 = " [color=# " + dark_theme_text_color + " ] " + info9 + " [/color] "
2023-10-22 09:14:32 -06:00
self . guide_screen . ids . guide_info1 . text = info1
self . guide_screen . ids . guide_info2 . text = info2
self . guide_screen . ids . guide_info3 . text = info3
self . guide_screen . ids . guide_info4 . text = info4
self . guide_screen . ids . guide_info5 . text = info5
self . guide_screen . ids . guide_info6 . text = info6
self . guide_screen . ids . guide_info7 . text = info7
self . guide_screen . ids . guide_info8 . text = info8
self . guide_screen . ids . guide_info9 . text = info9
self . guide_screen . ids . guide_info9 . bind ( on_ref_press = link_exec )
self . guide_screen . ids . guide_scrollview . effect_cls = ScrollEffect
2022-04-07 13:03:53 -06:00
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " guide_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-04-07 13:03:53 -06:00
2022-09-17 14:55:27 -06:00
#################################################
# Unimplemented Screens #
#################################################
def broadcasts_action ( self , sender = None ) :
def link_exec ( sender = None , event = None ) :
2023-10-22 09:14:32 -06:00
def lj ( ) :
2023-10-22 07:49:00 -06:00
import webbrowser
webbrowser . open ( " https://unsigned.io/donate " )
2023-10-22 09:14:32 -06:00
if not RNS . vendor . platformutils . is_android ( ) :
threading . Thread ( target = lj , daemon = True ) . start ( )
else :
lj ( )
2023-10-22 07:49:00 -06:00
if not self . root . ids . screen_manager . has_screen ( " broadcasts_screen " ) :
self . broadcasts_screen = Builder . load_string ( layout_broadcasts_screen )
self . broadcasts_screen . app = self
self . root . ids . screen_manager . add_widget ( self . broadcasts_screen )
2022-09-17 14:55:27 -06:00
2023-10-22 07:49:00 -06:00
self . broadcasts_screen . ids . broadcasts_scrollview . effect_cls = ScrollEffect
2022-11-03 16:04:28 -06:00
info = " The [b]Local Broadcasts[/b] feature will allow you to send and listen for local broadcast transmissions on connected radio, LoRa and WiFi interfaces. \n \n [b]Local Broadcasts[/b] makes it easy to establish public information exchange with anyone in direct radio range, or even with large areas far away using the [i]Remote Broadcast Repeater[/i] feature. \n \n These features are not yet implemented in Sideband. \n \n Want it faster? Go to [u][ref=link]https://unsigned.io/donate[/ref][/u] to support the project. "
2022-10-02 14:00:15 -06:00
if self . theme_cls . theme_style == " Dark " :
info = " [color=# " + dark_theme_text_color + " ] " + info + " [/color] "
2023-10-22 07:49:00 -06:00
self . broadcasts_screen . ids . broadcasts_info . text = info
self . broadcasts_screen . ids . broadcasts_info . bind ( on_ref_press = link_exec )
2022-09-17 14:55:27 -06:00
self . root . ids . screen_manager . transition . direction = " left "
self . root . ids . screen_manager . current = " broadcasts_screen "
self . root . ids . nav_drawer . set_state ( " closed " )
2022-10-01 17:14:29 -06:00
self . sideband . setstate ( " app.displaying " , self . root . ids . screen_manager . current )
2022-09-17 14:55:27 -06:00
2023-10-19 18:41:05 -06:00
class CustomOneLineIconListItem ( OneLineIconListItem ) :
icon = StringProperty ( )
2022-09-17 14:55:27 -06:00
2023-10-21 17:12:55 -06:00
class MDMapIconButton ( MDIconButton ) :
pass
2022-07-07 14:16:10 -06:00
def run ( ) :
SidebandApp ( ) . run ( )
if __name__ == " __main__ " :
2022-10-15 15:16:44 -06:00
run ( )