Compare commits

..

No commits in common. "55f6574297e6d12b7d2d0314774d93a6657d3bc9" and "d639ffcf9a3808103b58c3ee83d952a33f650c4e" have entirely different histories.

31 changed files with 387 additions and 2032 deletions

View File

@ -20,7 +20,7 @@ RUN git clone https://github.com/jacobeva/Reticulum \
# Switch branches
WORKDIR "Reticulum"
#RUN git switch ble-dev
RUN git switch ble-dev
WORKDIR ".."

View File

@ -31,9 +31,6 @@ preparewheel:
build_wheel:
. sbapp/venv/bin/activate; python3 setup.py sdist bdist_wheel
build_win_exe:
python -m PyInstaller sideband.spec --noconfirm
release: build_wheel apk fetchapk
release_docker:

View File

@ -39,7 +39,7 @@ Sideband can run on most computing devices, but installation methods vary by dev
## On Android
For your Android devices, you can install Sideband through F-Droid, by adding the [Between the Borders Repo](https://reticulum.betweentheborders.com/fdroid/repo/), or you can download an [APK on the latest release page](https://github.com/markqvist/Sideband/releases/latest). Both sources are signed with the same release keys, and can be used interchangably.
For your Android devices, you can install Sideband through F-Droid, by adding the [Between the Borders Repo](https://reticulum.betweentheborders.com/fdroid/repo/), or you can download an [APK on the latest release](https://github.com/markqvist/Sideband/releases/latest) page. Both sources are signed with the same release keys, and can be used interchangably.
After the application is installed on your Android device, it is also possible to pull updates directly through the **Repository** section of the application.
@ -47,8 +47,6 @@ After the application is installed on your Android device, it is also possible t
On all Linux-based operating systems, Sideband is available as a `pipx`/`pip` package. This installation method **includes desktop integration**, so that Sideband will show up in your applications menu and launchers. Below are install steps for the most common recent Linux distros. For Debian 11, see the end of this section.
**Please note!** The very latest Python release, Python 3.13 is currently **not** compatible with the Kivy framework, that Sideband uses to render its user interface. If your Linux distribution uses Python 3.13 as its default Python installation, you will need to install an earlier version as well. Using [the latest release of Python 3.12](https://www.python.org/downloads/release/python-3127/) is recommended.
You will first need to install a few dependencies for audio messaging and Codec2 support to work:
```bash
@ -68,10 +66,6 @@ Once those are installed, install the Sideband application itself:
```bash
# Finally, install Sideband using pipx:
pipx install sbapp
# If you need to specify a specific Python version,
# use something like the following:
pipx install sbapp --python python3.12
```
After installation, you can now run Sideband in a number of different ways:
@ -115,9 +109,8 @@ pip install sbapp --break-system-packages
# any of the normal UI dependencies:
pip install sbapp --no-dependencies
# In the case of using --no-dependencies, you
# will still need to manually install the RNS
# and LXMF dependencies:
# In the above case, you will still need to
# manually install the RNS and LXMF dependencies:
pip install rns lxmf
# Install Sideband on Debian 11 and derivatives:
@ -161,54 +154,28 @@ sideband
## On macOS
To install Sideband on macOS, you have two options available:
On macOS, you can install Sideband with `pip3` or `pipx`. Due to the many different potential Python versions and install paths across macOS versions, the easiest install method is to use `pipx`.
1. An easy to install pre-built disk image package
2. A source package install for more advanced setups
#### Prebuilt Executable
You can download a disk image with Sideband for macOS (ARM and Intel) from the [latest release page](https://github.com/markqvist/Sideband/releases/latest). Simply mount the downloaded disk image, drag `Sideband` to your applications folder, and run it.
**Please note!** If you have application install restrictions enabled on your macOS install, or have restricted your system to only allow installation of application from the Apple App Store, you will need to create an exception for Sideband. The Sideband application will *never* be distributed with an Apple-controlled digital signature, as this will allow Apple to simply disable Sideband from running on your system if they decide to do so, or are forced to by authorities or other circumstances.
If you install Sideband from the DMG file, it is still recommended to install the `rns` package via the `pip` or `pipx` package manager, so you can use the RNS utility programs, like `rnstatus` to see interface and connectivity status from the terminal. If you already have Python and `pip` installed on your system, simply open a terminal window and use one of the following commands:
If you don't already have the `pipx` package manager installed, it can be installed via [Homebrew](https://brew.sh/) with `brew install pipx`.
```bash
# Install Reticulum and utilities with pip:
pip3 install rns
# Install Sideband and dependencies on macOS using pipx:
pipx install sbapp
pipx ensurepath
# On some versions, you may need to use the
# flag --break-system-packages to install:
pip3 install rns --break-system-packages
# Run it
sideband
```
If you do not have Python and `pip` available, [download and install it](https://www.python.org/downloads/) first.
#### Source Package Install
For more advanced setups, including the ability to run Sideband in headless daemon mode, enable debug logging output, configuration import and export and more, you may want to install it from the source package via `pip` instead.
**Please note!** The very latest Python release, Python 3.13 is currently **not** compatible with the Kivy framework, that Sideband uses to render its user interface. If your version of macOS uses Python 3.13 as its default Python installation, you will need to install an earlier version as well. Using [the latest release of Python 3.12](https://www.python.org/downloads/release/python-3127/) is recommended.
To install Sideband via `pip`, follow these instructions:
Or, if you prefer to use `pip` directly, follow the instructions below. In this case, if you have not already installed Python and `pip3` on your macOS system, [download and install](https://www.python.org/downloads/) the latest version first.
```bash
# Install Sideband and dependencies on macOS using pip:
pip3 install sbapp --user --break-system-packages
# Optionally install RNS command line utilities:
pip3 install rns
# Run Sideband from the terminal:
# Run it:
python3 -m sbapp.main
# Enable debug logging:
python3 -m sbapp.main -v
# Start Sideband in daemon mode:
python3 -m sbapp.main -d
# If you add your pip install location to
# the PATH environment variable, you can
# also run Sideband simply using:
@ -218,32 +185,13 @@ sideband
## On Windows
To install Sideband on Windows, you have two options available:
Even though there is currently not an automated installer, or packaged `.exe` file for Sideband on Windows, you can still install it through `pip`. If you don't already have Python installed, [download and install](https://www.python.org/downloads/) the latest version of Python.
1. An easy to install pre-built executable package
2. A source package install for more advanced setups
Please note that audio messaging functionality isn't supported on Windows yet. Please support the development if you'd like to see this feature added faster.
#### Prebuilt Executable
**Important!** When asked by the installer, make sure to add the Python program to your PATH environment variables. If you don't do this, you will not be able to use the `pip` installer, or run the `sideband` command.
Simply download the packaged Windows ZIP file from the [latest release page](https://github.com/markqvist/Sideband/releases/latest), unzip the file, and run `Sideband.exe` from the unzipped directory. You can create desktop or start menu shortcuts from this executable if needed.
When running Sideband for the first time, a default Reticulum configuration file will be created, if you don't already have one. If you don't have any existing Reticulum connectivity available locally, you may want to edit the file, located at `C:\Users\USERNAME\.reticulum\config` and manually add an interface that provides connectivity to a wider network. If you just want to connect over the Internet, you can add one of the public hubs on the [Reticulum Testnet](https://reticulum.network/connect.html).
Though the ZIP file contains everything necessary to run Sideband, it is also recommended to install the Reticulum command line utilities separately, so that you can use commands like `rnstatus` and `rnsd` from the command line. This will make it easier to manage Reticulum connectivity on your system. If you do not already have Python installed on your system, [download and install it](https://www.python.org/downloads/) first.
**Important!** When asked by the installer, make sure to add the Python program to your `PATH` environment variables. If you don't do this, you will not be able to use the `pip` installer, or run any of the installed commands. When Python has been installed, you can open a command prompt and install the Reticulum package via `pip`:
```bash
pip install rns
```
#### Source Package Install
For more advanced setups, including the ability to run Sideband in headless daemon mode, enable debug logging output, configuration import and export and more, you may want to install it from the source package via `pip` instead.
In this case, you will need to [download and install the latest supported version of Python](https://www.python.org/downloads/release/python-3127/) (currently Python 3.12.7), since very latest Python release, Python 3.13 is currently **not** compatible with the Kivy framework, that Sideband uses to render its user interface. The binary package already includes a compatible Python version, so if you are running Sideband from that, there is no need to install a specific version of Python.
When Python has been installed, you can open a command prompt and install Sideband via `pip`:
When Python has been installed, you can open a command prompt and install sideband via `pip`:
```bash
pip install sbapp
@ -251,7 +199,7 @@ pip install sbapp
The Sideband application can now be launched by running the command `sideband` in the command prompt. If needed, you can create a shortcut for Sideband on your desktop or in the start menu.
Since this installation method automatically installs the `rns` and `lxmf` packages as well, you will also have access to using all the included RNS and LXMF utilities like `rnstatus`, `rnsd` and `lxmd` on your system.
When running Sideband for the first time, a default Reticulum configuration file will be created, if you don't already have one. If you don't have any existing Reticulum connectivity available locally, you may want to edit the file, located at `C:\Users\USERNAME\.reticulum\config` and manually add an interface that provides connectivity to a wider network. If you just want to connect over the Internet, you can add one of the public hubs on the [Reticulum Testnet](https://reticulum.network/connect.html).
# Paper Messaging Example
@ -288,7 +236,7 @@ You can help support the continued development of open, free and private communi
<br/>
# Planned Features
# Development Roadmap
- <s>Secure and private location and telemetry sharing</s>
- <s>Including images in messages</s>
@ -298,15 +246,15 @@ You can help support the continued development of open, free and private communi
- <s>Using Sideband as a Reticulum Transport Instance</s>
- <s>Encryption keys export and import</s>
- <s>Plugin support for commands, services and telemetry</s>
- <s>Adding Linux .desktop file integration</s>
- <s>Sending voice messages (using Codec2 and Opus)</s>
- <s>Adding a Linux desktop integration</s>
- <s>Adding prebuilt Windows binaries to the releases</s>
- <s>Adding prebuilt macOS binaries to the releases</s>
- Adding a Nomad Net page browser
- Implementing the Local Broadcasts feature
- LXMF sneakernet functionality
- Network visualisation and test tools
- Better message sorting mechanism
- A debug log viewer
- Better message sorting mechanism
- Fix I2P status not being displayed correctly when the I2P router disappears unexpectedly
- Adding a Nomad Net page browser
# License
Unless otherwise noted, this work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].

View File

@ -67,7 +67,7 @@ class GpsdLocationPlugin(SidebandTelemetryPlugin):
self.latitude = gpsd_latitude
self.longitude = gpsd_longitude
self.altitude = gpsd_altitude
self.speed = gpsd_speed*3.6 # Convert from m/s to km/h
self.speed = gpsd_speed
self.bearing = gpsd_bearing
epx = result.get("epx", None); epy = result.get("epy", None)

View File

@ -1 +0,0 @@
import sbapp.main

View File

@ -7,7 +7,7 @@ clean:
-(rm ./__pycache__ -r)
-(rm ./app_storage -r)
-(rm ./share/pkg/* -r)
-(rm ./share/mirrors/* -rf)
-(rm ./share/mirrors/* -r)
-(rm ./bin -r)
cleanlibs:
@ -66,14 +66,13 @@ fetchshare:
cp ../../dist_archive/lxmf-*-py3-none-any.whl ./share/pkg/
cp ../../dist_archive/nomadnet-*-py3-none-any.whl ./share/pkg/
cp ../../dist_archive/rnsh-*-py3-none-any.whl ./share/pkg/
# cp ../../dist_archive/sbapp-*-py3-none-any.whl ./share/pkg/
cp ../../dist_archive/RNode_Firmware_*_Source.zip ./share/pkg/
zip --junk-paths ./share/pkg/example_plugins.zip ../docs/example_plugins/*.py
cp -r ../../dist_archive/reticulum.network ./share/mirrors/
cp -r ../../dist_archive/unsigned.io ./share/mirrors/
cp ../../dist_archive/Reticulum\ Manual.pdf ./share/mirrors/Reticulum_Manual.pdf
cp ../../dist_archive/Reticulum\ Manual.epub ./share/mirrors/Reticulum_Manual.epub
cp -r ../../rnode-flasher ./share/mirrors/
-(rm ./share/mirrors/rnode-flasher/.git -rf)
release:
. venv/bin/activate; buildozer android release

View File

@ -1,4 +1,4 @@
# Entry version 20241128
# Entry version 20240630
[Desktop Entry]
Comment[en_US]=Messaging, telemetry and remote control over LXMF
Comment=Messaging, telemetry and remote control over LXMF

View File

@ -10,7 +10,7 @@ source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py
android.numeric_version = 20241213
android.numeric_version = 20241013
requirements = kivy==2.3.0,libbz2,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,ffpyplayer,codec2,pycodec2,sh,pynacl,typing-extensions

View File

@ -30,13 +30,10 @@ def get_variant() -> str:
version = re.findall(version_regex, version_file_data, re.M)[0]
return version
except IndexError:
return None
raise ValueError(f"Unable to find version string in {version_file}.")
__version__ = get_version()
__variant__ = get_variant()
variant_str = ""
if __variant__:
variant_str = " "+__variant__
def glob_paths(pattern):
out_files = []
@ -63,14 +60,14 @@ package_data = {
]
}
print("Freezing openCom Companion "+__version__+" "+variant_str)
print("Freezing openCom Companion "+__version__+" "+__variant__)
if build_appimage:
global_excludes = [".buildozer", "build", "dist"]
# Dependencies are automatically detected, but they might need fine-tuning.
appimage_options = {
"target_name": "openCom Companion",
"target_version": __version__+" "+variant_str,
"target_version": __version__+" "+__variant__,
"include_files": [],
"excludes": [],
"packages": ["kivy"],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -1,6 +1,6 @@
__debug_build__ = False
__disable_shaders__ = False
__version__ = "1.2.0"
__version__ = "1.1.3"
__variant__ = ""
import sys
@ -24,54 +24,6 @@ import base64
import threading
import RNS.vendor.umsgpack as msgpack
WINDOW_DEFAULT_WIDTH = "494"
WINDOW_DEFAULT_HEIGHT = "800"
app_ui_scaling_path = None
def apply_ui_scale():
global app_ui_scaling_path
default_scale = os.environ["KIVY_METRICS_DENSITY"] if "KIVY_METRICS_DENSITY" in os.environ else "unknown"
config_path = None
ui_scale_path = None
try:
if RNS.vendor.platformutils.is_android():
import plyer
ui_scale_path = plyer.storagepath.get_application_dir()+"/io.unsigned.sideband/files/app_storage/ui_scale"
else:
if config_path == None:
import sbapp.plyer as plyer
ui_scale_path = plyer.storagepath.get_home_dir()+"/.config/sideband/app_storage/ui_scale"
if ui_scale_path.startswith("file://"):
ui_scale_path = ui_scale_path.replace("file://", "")
else:
ui_scale_path = config_path+"/app_storage/ui_scale"
app_ui_scaling_path = ui_scale_path
except Exception as e:
RNS.log(f"Error while locating UI scale file: {e}", RNS.LOG_ERROR)
if ui_scale_path != None:
RNS.log("Default scaling factor on this platform is "+str(default_scale), RNS.LOG_NOTICE)
try:
RNS.log("Looking for scaling info in "+str(ui_scale_path))
if os.path.isfile(ui_scale_path):
scale_factor = None
with open(ui_scale_path, "r") as sf:
scale_factor = float(sf.readline())
if scale_factor != None:
if scale_factor >= 0.3 and scale_factor <= 5.0:
os.environ["KIVY_METRICS_DENSITY"] = str(scale_factor)
RNS.log("UI scaling factor set to "+str(os.environ["KIVY_METRICS_DENSITY"]), RNS.LOG_NOTICE)
elif scale_factor == 0.0:
RNS.log("Using default UI scaling factor", RNS.LOG_NOTICE)
except Exception as e:
RNS.log(f"Error while reading UI scaling factor: {e}", RNS.LOG_ERROR)
if args.export_settings:
from .sideband.core import SidebandCore
sideband = SidebandCore(
@ -174,11 +126,6 @@ if not args.daemon:
local = os.path.dirname(__file__)
sys.path.append(local)
if not RNS.vendor.platformutils.is_android():
from kivy.config import Config
Config.set("graphics", "width", WINDOW_DEFAULT_WIDTH)
Config.set("graphics", "height", WINDOW_DEFAULT_HEIGHT)
if args.daemon:
from .sideband.core import SidebandCore
class DaemonElement():
@ -196,11 +143,9 @@ if args.daemon:
NewConv = DaemonElement; Telemetry = DaemonElement; ObjectDetails = DaemonElement; Announces = DaemonElement;
Messages = DaemonElement; ts_format = DaemonElement; messages_screen_kv = DaemonElement; plyer = DaemonElement; multilingual_markup = DaemonElement;
ContentNavigationDrawer = DaemonElement; DrawerList = DaemonElement; IconListItem = DaemonElement; escape_markup = DaemonElement;
SoundLoader = DaemonElement; BoxLayout = DaemonElement;
SoundLoader = DaemonElement;
else:
apply_ui_scale()
from kivymd.app import MDApp
app_superclass = MDApp
from kivy.core.window import Window
@ -212,7 +157,6 @@ else:
from kivy.effects.scroll import ScrollEffect
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.screenmanager import FadeTransition, NoTransition, SlideTransition
from kivy.uix.boxlayout import BoxLayout
from kivymd.uix.list import OneLineIconListItem, IconLeftWidget
from kivy.properties import StringProperty
from kivymd.uix.button import BaseButton, MDIconButton
@ -237,7 +181,6 @@ else:
from ui.layouts import *
from ui.conversations import Conversations, MsgSync, NewConv
from ui.telemetry import Telemetry
from ui.utilities import Utilities
from ui.objectdetails import ObjectDetails
from ui.announces import Announces
from ui.messages import Messages, ts_format, messages_screen_kv
@ -265,7 +208,6 @@ else:
from .ui.conversations import Conversations, MsgSync, NewConv
from .ui.announces import Announces
from .ui.telemetry import Telemetry
from .ui.utilities import Utilities
from .ui.objectdetails import ObjectDetails
from .ui.messages import Messages, ts_format, messages_screen_kv
from .ui.helpers import ContentNavigationDrawer, DrawerList, IconListItem
@ -352,7 +294,6 @@ class SidebandApp(MDApp):
self.sync_dialog = None
self.settings_ready = False
self.telemetry_ready = False
self.utilities_ready = False
self.connectivity_ready = False
self.hardware_ready = False
self.repository_ready = False
@ -365,11 +306,9 @@ class SidebandApp(MDApp):
self.service_last_available = 0
self.closing_app = False
self.file_manager = None
self.attach_path = None
self.attach_type = None
self.attach_dialog = None
self.shared_attach_dialog = None
self.rec_dialog = None
self.last_msg_audio = None
self.msg_sound = None
@ -566,15 +505,6 @@ class SidebandApp(MDApp):
fn_italic=fb_path+"NotoSans-Italic.ttf",
fn_bolditalic=fb_path+"NotoSans-BoldItalic.ttf")
LabelBase.register(name="mono",
fn_regular=fb_path+"RobotoMonoNerdFont-Regular.ttf")
LabelBase.register(name="term",
fn_regular=fb_path+"BigBlueTerm437NerdFont-Regular.ttf")
LabelBase.register(name="nf",
fn_regular=fb_path+"RobotoMonoNerdFont-Regular.ttf")
def update_input_language(self):
language = self.sideband.config["input_language"]
if language == None:
@ -769,13 +699,6 @@ class SidebandApp(MDApp):
else:
RNS.log("Conversations view did not exist", RNS.LOG_DEBUG)
def ui_update_job():
time.sleep(0.05)
def cb(dt):
self.perform_wake_update()
Clock.schedule_once(cb, 0.1)
threading.Thread(target=ui_update_job, daemon=True).start()
RNS.log("App resumed", RNS.LOG_DEBUG)
def on_stop(self):
@ -791,21 +714,6 @@ class SidebandApp(MDApp):
else:
return False
def perform_wake_update(self):
# This workaround mitigates a bug in Kivy on Android
# which causes the UI to turn black on app resume,
# probably due to an invalid GL draw context. By
# simply opening and immediately closing the nav
# drawer, we force the UI to do a frame redraw, which
# results in the UI actually being visible again.
if RNS.vendor.platformutils.is_android():
RNS.log("Performing app wake UI update", RNS.LOG_DEBUG)
self.root.ids.nav_drawer.set_state("open")
def cb(dt):
self.root.ids.nav_drawer.set_state("closed")
Clock.schedule_once(cb, 0)
def check_bluetooth_permissions(self):
if RNS.vendor.platformutils.get_platform() == "android":
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
@ -962,37 +870,6 @@ class SidebandApp(MDApp):
if data.lower().startswith(LXMF.LXMessage.URI_SCHEMA):
action = "lxm_uri"
if intent_action == "android.intent.action.SEND":
try:
Intent = autoclass("android.content.Intent")
extras = intent.getExtras()
target = extras.get(Intent.EXTRA_STREAM)
mime_types = extras.get(Intent.EXTRA_MIME_TYPES)
target_uri = target.toString()
target_path = target.getPath()
target_filename = target.getLastPathSegment()
RNS.log(f"Received share intent: {target_uri} / {target_path} / {target_filename}", RNS.LOG_DEBUG)
for cf in os.listdir(self.sideband.share_cache):
rt = os.path.join(self.sideband.share_cache, cf)
os.unlink(rt)
RNS.log("Removed previously cached data: "+str(rt), RNS.LOG_DEBUG)
ContentResolver = autoclass("android.content.ContentResolver")
cr = mActivity.getContentResolver()
cache_path = os.path.join(self.sideband.share_cache, target_filename)
input_stream = cr.openInputStream(target)
with open(cache_path, "wb") as cache_file:
cache_file.write(bytes(input_stream.readAllBytes()))
RNS.log("Cached shared data from Android intent", RNS.LOG_DEBUG)
action = "shared_data"
data = {"filename": target_filename, "data_path": cache_path}
except Exception as e:
RNS.log(f"Error while getting intent action data: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
if action != None:
self.handle_action(action, data)
@ -1000,16 +877,6 @@ class SidebandApp(MDApp):
if action == "lxm_uri":
self.ingest_lxm_uri(data)
if action == "shared_data":
RNS.log("Got shared data: "+str(data))
def cb(dt):
try:
self.shared_attachment_action(data)
except Exception as e:
RNS.log("Error while handling external message attachment", RNS.LOG_ERROR)
RNS.trace_exception(e)
Clock.schedule_once(cb, 0.1)
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)
@ -1197,9 +1064,6 @@ class SidebandApp(MDApp):
self.quit_action(None)
return True
def file_dropped(self, window, file_path, x, y, *args):
self.shared_attachment_action({"data_path": file_path.decode("utf-8")})
def on_start(self):
self.last_exit_event = time.time()
self.root.ids.screen_manager.transition = self.slide_transition
@ -1210,7 +1074,6 @@ class SidebandApp(MDApp):
EventLoop.window.bind(on_key_down=self.keydown_event)
EventLoop.window.bind(on_key_up=self.keyup_event)
Window.bind(on_request_close=self.close_requested)
Window.bind(on_drop_file=self.file_dropped)
if __variant__ != "":
variant_str = " "+__variant__
@ -1317,8 +1180,6 @@ class SidebandApp(MDApp):
self.close_sub_telemetry_action()
elif self.root.ids.screen_manager.current == "icons_screen":
self.close_sub_telemetry_action()
elif self.root.ids.screen_manager.current == "utilities_screen":
self.close_sub_utilities_action()
else:
self.open_conversations(direction="right")
@ -1358,11 +1219,8 @@ class SidebandApp(MDApp):
else:
self.telemetry_action(self)
if text == "y":
self.map_display_own_telemetry()
if text == "u":
self.utilities_action()
self.map_display_own_telemetry()
if text == "o":
self.objects_action()
@ -1375,8 +1233,6 @@ class SidebandApp(MDApp):
self.lxmf_sync_action(self)
elif self.root.ids.screen_manager.current == "telemetry_screen":
self.conversations_action(self, direction="right")
elif self.root.ids.screen_manager.current == "rnstatus_screen":
self.utilities_screen.update_rnstatus()
elif self.root.ids.screen_manager.current == "object_details_screen":
if not self.object_details_screen.object_hash == self.sideband.lxmf_destination.hash:
self.converse_from_telemetry(self)
@ -1421,10 +1277,6 @@ class SidebandApp(MDApp):
self.close_sub_telemetry_action()
elif self.root.ids.screen_manager.current == "icons_screen":
self.close_sub_telemetry_action()
elif self.root.ids.screen_manager.current == "rnstatus_screen":
self.close_sub_utilities_action()
elif self.root.ids.screen_manager.current == "logviewer_screen":
self.close_sub_utilities_action()
else:
self.open_conversations(direction="right")
@ -1827,8 +1679,7 @@ class SidebandApp(MDApp):
def message_fm_exited(self, *args):
self.manager_open = False
if self.file_manager != None:
self.file_manager.close()
self.file_manager.close()
def message_select_file_action(self, sender=None):
perm_ok = False
@ -1843,20 +1694,11 @@ class SidebandApp(MDApp):
if perm_ok and path != None:
try:
if self.attach_type in ["lbimg", "defimg", "hqimg"]:
self.file_manager = MDFileManager(
exit_manager=self.message_fm_exited,
select_path=self.message_fm_got_path,
# Current KivyMD preview implementation is too slow to be reliable on Android
preview=False)
else:
self.file_manager = MDFileManager(
exit_manager=self.message_fm_exited,
select_path=self.message_fm_got_path,
preview=False)
# self.file_manager.ext = []
# self.file_manager.search = "all"
self.file_manager = MDFileManager(
exit_manager=self.message_fm_exited,
select_path=self.message_fm_got_path,
)
# self.file_manager.ext = ["*"]
self.file_manager.show(path)
except Exception as e:
@ -2333,65 +2175,6 @@ class SidebandApp(MDApp):
ate_dialog.open()
def shared_attachment_action(self, attachment_data):
if not self.root.ids.screen_manager.current == "messages_screen":
if RNS.vendor.platformutils.is_android():
toast("Please select a conversation first")
else:
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
ate_dialog = MDDialog(
title="No active conversation",
text="To drop files as attachments, please open a conversation first",
buttons=[ ok_button ],
)
ok_button.bind(on_release=ate_dialog.dismiss)
ate_dialog.open()
else:
self.rec_dialog_is_open = False
def a_img_lb(sender):
self.attach_type="lbimg"
self.shared_attach_dialog.dismiss()
self.shared_attach_dialog.att_exc()
def a_img_def(sender):
self.attach_type="defimg"
self.shared_attach_dialog.dismiss()
self.shared_attach_dialog.att_exc()
def a_img_hq(sender):
self.attach_type="hqimg"
self.shared_attach_dialog.dismiss()
self.shared_attach_dialog.att_exc()
def a_file(sender):
self.attach_type="file"
self.shared_attach_dialog.dismiss()
self.shared_attach_dialog.att_exc()
if self.shared_attach_dialog == None:
ss = int(dp(18))
cancel_button = MDRectangleFlatButton(text="Cancel", font_size=dp(18))
ad_items = [
DialogItem(IconLeftWidget(icon="message-image-outline", on_release=a_img_lb), text="[size="+str(ss)+"]Low-bandwidth Image[/size]", on_release=a_img_lb),
DialogItem(IconLeftWidget(icon="file-image", on_release=a_img_def), text="[size="+str(ss)+"]Medium Image[/size]", on_release=a_img_def),
DialogItem(IconLeftWidget(icon="image-outline", on_release=a_img_hq), text="[size="+str(ss)+"]High-res Image[/size]", on_release=a_img_hq),
DialogItem(IconLeftWidget(icon="file-outline", on_release=a_file), text="[size="+str(ss)+"]File Attachment[/size]", on_release=a_file)]
self.shared_attach_dialog = MDDialog(
title="Add Attachment",
type="simple",
text="Select how you want to attach this data to the next message sent\n",
items=ad_items,
buttons=[ cancel_button ],
width_offset=dp(32),
)
cancel_button.bind(on_release=self.shared_attach_dialog.dismiss)
def att_exc():
self.message_fm_got_path(attachment_data["data_path"])
self.shared_attach_dialog.att_exc = att_exc
self.shared_attach_dialog.open()
def update_message_widgets(self):
toolbar_items = self.messages_view.ids.messages_toolbar.ids.right_actions.children
mode_item = toolbar_items[1]
@ -2520,35 +2303,30 @@ class SidebandApp(MDApp):
return "Could not retrieve connectivity status"
def connectivity_status(self, sender):
if RNS.vendor.platformutils.is_android():
hs = dp(22)
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Connectivity Status",
text=str(self.get_connectivity_text()),
buttons=[ yes_button ],
# elevation=0,
)
def cs_updater(dt):
dialog.text = str(self.get_connectivity_text())
def dl_yes(s):
self.connectivity_updater.cancel()
dialog.dismiss()
if self.connectivity_updater != None:
self.connectivity_updater.cancel()
yes_button.bind(on_release=dl_yes)
dialog.open()
hs = dp(22)
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Connectivity Status",
text=str(self.get_connectivity_text()),
buttons=[ yes_button ],
# elevation=0,
)
def cs_updater(dt):
dialog.text = str(self.get_connectivity_text())
def dl_yes(s):
self.connectivity_updater.cancel()
dialog.dismiss()
if self.connectivity_updater != None:
self.connectivity_updater.cancel()
self.connectivity_updater = Clock.schedule_interval(cs_updater, 2.0)
yes_button.bind(on_release=dl_yes)
dialog.open()
else:
if not self.utilities_ready:
self.utilities_init()
self.utilities_screen.rnstatus_action()
if self.connectivity_updater != None:
self.connectivity_updater.cancel()
self.connectivity_updater = Clock.schedule_interval(cs_updater, 2.0)
def ingest_lxm_action(self, sender):
def cb(dt):
@ -2622,14 +2400,13 @@ class SidebandApp(MDApp):
else:
sl = None
sync_title = "LXMF Sync"
if not hasattr(self, "message_sync_dialog") or self.message_sync_dialog == None:
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)
dialog_content = MsgSync()
dialog = MDDialog(
title=sync_title,
title="LXMF Sync via "+RNS.prettyhexrep(self.sideband.message_router.get_outbound_propagation_node()),
type="custom",
content_cls=dialog_content,
buttons=[ stop_button, close_button ],
@ -2666,8 +2443,7 @@ class SidebandApp(MDApp):
dsp = 0
self.sideband.setstate("app.flags.lxmf_sync_dialog_open", True)
self.message_sync_dialog.title = sync_title
self.message_sync_dialog.d_content.ids.node_info.text = f"Via {RNS.prettyhexrep(self.sideband.message_router.get_outbound_propagation_node())}\n"
self.message_sync_dialog.title = f"LXMF Sync via "+RNS.prettyhexrep(self.sideband.message_router.get_outbound_propagation_node())
self.message_sync_dialog.d_content.ids.sync_status.text = self.sideband.get_sync_status()
self.message_sync_dialog.d_content.ids.sync_progress.value = dsp
self.message_sync_dialog.d_content.ids.sync_progress.start()
@ -2711,15 +2487,11 @@ class SidebandApp(MDApp):
RNS.log("Error while creating conversation: "+str(e), RNS.LOG_ERROR)
if new_result:
dialog.d_content.ids["n_address_field"].helper_text = ""
dialog.d_content.ids["n_address_field"].helper_text_mode = "on_focus"
dialog.d_content.ids["n_address_field"].error = False
dialog.dismiss()
if self.conversations_view != None:
self.conversations_view.update()
else:
dialog.d_content.ids["n_address_field"].helper_text = "Invalid address, check your input"
dialog.d_content.ids["n_address_field"].helper_text_mode = "persistent"
dialog.d_content.ids["n_address_field"].error = True
# dialog.d_content.ids["n_error_field"].text = "Could not create conversation. Check your input."
@ -2813,72 +2585,6 @@ class SidebandApp(MDApp):
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def configure_ui_scaling_action(self, sender=None):
global app_ui_scaling_path
try:
cancel_button = MDRectangleFlatButton(text="Cancel",font_size=dp(18))
set_button = MDRectangleFlatButton(text="Set",font_size=dp(18), theme_text_color="Custom", line_color=self.color_accept, text_color=self.color_accept)
dialog_content = UIScaling()
dialog = MDDialog(
title="UI Scaling",
type="custom",
content_cls=dialog_content,
buttons=[ set_button, cancel_button ],
# elevation=0,
)
dialog.d_content = dialog_content
dialog.d_content.ids["scaling_factor"].text = os.environ["KIVY_METRICS_DENSITY"] if "KIVY_METRICS_DENSITY" in os.environ else "0.0"
def dl_yes(s):
new_sf = 1.0
scaling_ok = False
try:
si = dialog.d_content.ids["scaling_factor"].text
sf = float(si)
if (sf >= 0.3 and sf <= 5.0) or sf == 0.0:
new_sf = sf
scaling_ok = True
except Exception as e:
RNS.log("Error while getting scaling factor from user: "+str(e), RNS.LOG_ERROR)
if scaling_ok:
dialog.d_content.ids["scaling_factor"].helper_text = ""
dialog.d_content.ids["scaling_factor"].helper_text_mode = "on_focus"
dialog.d_content.ids["scaling_factor"].error = False
dialog.dismiss()
if app_ui_scaling_path == None:
RNS.log("No path to UI scaling factor file could be found, cannot save scaling factor", RNS.LOG_ERROR)
else:
try:
with open(app_ui_scaling_path, "w") as sfile:
sfile.write(str(new_sf))
RNS.log(f"Saved configured scaling factor {new_sf} to {app_ui_scaling_path}", RNS.LOG_DEBUG)
except Exception as e:
RNS.log(f"Error while saving scaling factor {new_sf} to {app_ui_scaling_path}: {e}", RNS.LOG_ERROR)
else:
dialog.d_content.ids["scaling_factor"].helper_text = "Invalid scale factor, check your input"
dialog.d_content.ids["scaling_factor"].helper_text_mode = "persistent"
dialog.d_content.ids["scaling_factor"].error = True
def dl_no(s):
dialog.dismiss()
def dl_ds(s):
self.dialog_open = False
set_button.bind(on_release=dl_yes)
cancel_button.bind(on_release=dl_no)
dialog.bind(on_dismiss=dl_ds)
dialog.open()
self.dialog_open = True
except Exception as e:
RNS.log("Error while creating UI scaling dialog: "+str(e), RNS.LOG_ERROR)
def settings_action(self, sender=None, direction="left"):
if self.settings_ready:
self.settings_open(direction=direction)
@ -3033,11 +2739,6 @@ class SidebandApp(MDApp):
self.sideband.save_configuration()
self.update_ui_theme()
def save_classic_message_colors(sender=None, event=None):
self.sideband.config["classic_message_colors"] = self.settings_screen.ids.settings_classic_message_colors.active
self.sideband.save_configuration()
self.update_ui_theme()
def save_display_style_in_contact_list(sender=None, event=None):
self.sideband.config["display_style_in_contact_list"] = self.settings_screen.ids.display_style_in_contact_list.active
self.sideband.save_configuration()
@ -3048,10 +2749,6 @@ class SidebandApp(MDApp):
self.sideband.save_configuration()
self.sideband.setstate("wants.viewupdate.conversations", True)
def save_trusted_markup_only(sender=None, event=None):
self.sideband.config["trusted_markup_only"] = self.settings_screen.ids.settings_trusted_markup_only.active
self.sideband.save_configuration()
def save_advanced_stats(sender=None, event=None):
self.sideband.config["advanced_stats"] = self.settings_screen.ids.settings_advanced_statistics.active
self.sideband.save_configuration()
@ -3203,9 +2900,6 @@ class SidebandApp(MDApp):
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)
self.settings_screen.ids.settings_classic_message_colors.active = self.sideband.config["classic_message_colors"]
self.settings_screen.ids.settings_classic_message_colors.bind(active=save_classic_message_colors)
self.settings_screen.ids.display_style_in_contact_list.active = self.sideband.config["display_style_in_contact_list"]
self.settings_screen.ids.display_style_in_contact_list.bind(active=save_display_style_in_contact_list)
@ -3227,9 +2921,6 @@ class SidebandApp(MDApp):
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)
self.settings_screen.ids.settings_trusted_markup_only.active = self.sideband.config["trusted_markup_only"]
self.settings_screen.ids.settings_trusted_markup_only.bind(active=save_trusted_markup_only)
self.settings_screen.ids.settings_ignore_invalid_stamps.active = self.sideband.config["lxmf_ignore_invalid_stamps"]
self.settings_screen.ids.settings_ignore_invalid_stamps.bind(active=save_lxmf_ignore_invalid_stamps)
@ -3678,7 +3369,6 @@ class SidebandApp(MDApp):
######################################
def repository_action(self, sender=None, direction="left"):
if self.repository_ready:
self.repository_update_info()
self.repository_open(direction=direction)
else:
self.loader_action(direction=direction)
@ -3715,9 +3405,9 @@ class SidebandApp(MDApp):
info += "If you want to share the openCom Companion 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:
def getIP():
adrs = []
if RNS.vendor.platformutils.is_android():
if RNS.vendor.platformutils.is_android():
def getIP():
adrs = []
try:
from jnius import autoclass
import ipaddress
@ -3740,30 +3430,24 @@ class SidebandApp(MDApp):
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\nYou can access the repository by pointing a browser to: http://DEVICE_IP:4444/"
self.reposository_url = None
else:
import socket
adrs.append(socket.gethostbyname(socket.gethostname()))
ipstr = ""
for ip in ips:
ipstr += "http://"+str(ip)+":4444/\n"
self.reposository_url = ipstr
return adrs
ms = "" if len(ips) == 1 else "es"
info += "The repository server is running at the following address"+ms+":\n [u][ref=link]"+ipstr+"[/ref][u]"
self.repository_screen.ids.repository_info.bind(on_ref_press=self.repository_link_action)
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\nYou can access the repository by pointing a browser to: https://DEVICE_IP:4444/"
self.reposository_url = None
else:
ipstr = ""
for ip in ips:
ipstr += "https://"+str(ip)+":4444/\n"
self.reposository_url = ipstr
ms = "" if len(ips) == 1 else "es"
info += "The repository server is running at the following address"+ms+":\n [u][ref=link]"+ipstr+"[/ref][u]"
self.repository_screen.ids.repository_info.bind(on_ref_press=self.repository_link_action)
def cb(dt):
self.repository_screen.ids.repository_enable_button.disabled = True
self.repository_screen.ids.repository_disable_button.disabled = False
Clock.schedule_once(cb, 0.1)
self.repository_screen.ids.repository_enable_button.disabled = True
self.repository_screen.ids.repository_disable_button.disabled = False
else:
self.repository_screen.ids.repository_enable_button.disabled = False
@ -3785,85 +3469,39 @@ class SidebandApp(MDApp):
def update_job(sender=None):
try:
import requests
### RNode Firmwares ###########
if True:
downloads = []
try:
release_url = "https://api.github.com/repos/markqvist/rnode_firmware/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().startswith("rnode_firmware"):
fw_url = asset["browser_download_url"]
pkgname = asset["name"]
fw_version = release["tag_name"]
RNS.log(f"Found version {fw_version} artefact {pkgname} at {fw_url}", RNS.LOG_DEBUG)
downloads.append([fw_url, pkgname, fw_version])
except Exception as e:
self.repository_screen.ids.repository_update.text = f"Downloading RNode firmware release info failed with the error:\n"+str(e)
return
# 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:
self.repository_screen.ids.repository_update.text = f"Downloading release info failed with the error:\n"+str(e)
return
try:
for download in downloads:
fw_url = download[0]
pkgname = download[1]
self.repository_screen.ids.repository_update.text = "Downloading: "+str(pkgname)
with requests.get(fw_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
self.repository_screen.ids.repository_update.text = "Downloaded "+RNS.prettysize(tds)+" of "+str(pkgname)
os.rename("./dl_tmp", f"{self.sideband.webshare_dir}/pkg/{pkgname}")
self.repository_screen.ids.repository_update.text = f"Added {pkgname} to the repository!"
except Exception as e:
self.repository_screen.ids.repository_update.text = f"Downloading RNode firmware failed with the error:\n"+str(e)
return
### Sideband APK File #########
if True:
# 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}", RNS.LOG_DEBUG)
except Exception as e:
self.repository_screen.ids.repository_update.text = f"Downloading Sideband APK release info failed with the error:\n"+str(e)
return
self.repository_screen.ids.repository_update.text = "Downloading: "+str(pkgname)
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
self.repository_screen.ids.repository_update.text = "Downloaded "+RNS.prettysize(tds)+" of "+str(pkgname)
os.rename("./dl_tmp", f"{self.sideband.webshare_dir}/pkg/{pkgname}")
self.repository_screen.ids.repository_update.text = f"Added {pkgname} to the repository!"
self.repository_screen.ids.repository_update.text = f"Repository contents updated successfully!"
self.repository_screen.ids.repository_update.text = "Downloading: "+str(apk_url)
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
self.repository_screen.ids.repository_update.text = "Downloaded "+RNS.prettysize(tds)+" of "+str(pkgname)
os.rename("./dl_tmp", f"./share/pkg/{pkgname}")
self.repository_screen.ids.repository_update.text = f"Added {pkgname} to the repository!"
except Exception as e:
self.repository_screen.ids.repository_update.text = f"Downloading contents failed with the error:\n"+str(e)
@ -3880,7 +3518,15 @@ class SidebandApp(MDApp):
self.root.ids.screen_manager.add_widget(self.repository_screen)
self.repository_screen.ids.repository_scrollview.effect_cls = ScrollEffect
self.repository_update_info()
if not RNS.vendor.platformutils.is_android():
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 = "\nThe [b]Repository Webserver[/b] feature is currently only available on mobile devices."
self.repository_ready = True
def close_repository_action(self, sender=None):
@ -4450,14 +4096,14 @@ class SidebandApp(MDApp):
self.sideband.save_configuration()
#def hardware_rnode_ble_toggle_action(self, sender=None, event=None):
# if sender.active:
# self.sideband.config["hw_rnode_ble"] = True
# self.request_bluetooth_permissions()
# else:
# self.sideband.config["hw_rnode_ble"] = False
def hardware_rnode_ble_toggle_action(self, sender=None, event=None):
if sender.active:
self.sideband.config["hw_rnode_ble"] = True
self.request_bluetooth_permissions()
else:
self.sideband.config["hw_rnode_ble"] = False
# self.sideband.save_configuration()
self.sideband.save_configuration()
def hardware_rnode_framebuffer_toggle_action(self, sender=None, event=None):
if sender.active:
@ -4564,7 +4210,7 @@ class SidebandApp(MDApp):
t_btd = ""
self.hardware_rnode_screen.ids.hardware_rnode_bluetooth.active = self.sideband.config["hw_rnode_bluetooth"]
#self.hardware_rnode_screen.ids.hardware_rnode_ble.active = self.sideband.config["hw_rnode_ble"]
self.hardware_rnode_screen.ids.hardware_rnode_ble.active = self.sideband.config["hw_rnode_ble"]
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.active = self.sideband.config["hw_rnode_enable_framebuffer"]
self.hardware_rnode_screen.ids.hardware_rnode_advanced_cfg.active = self.sideband.config["hw_rnode_advanced_cfg"]
@ -4631,7 +4277,7 @@ class SidebandApp(MDApp):
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_bluetooth.bind(active=self.hardware_rnode_bt_toggle_action)
#self.hardware_rnode_screen.ids.hardware_rnode_ble.bind(active=self.hardware_rnode_ble_toggle_action)
self.hardware_rnode_screen.ids.hardware_rnode_ble.bind(active=self.hardware_rnode_ble_toggle_action)
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.bind(active=self.hardware_rnode_framebuffer_toggle_action)
self.hardware_rnode_screen.ids.hardware_rnode_advanced_cfg.bind(active=self.hardware_rnode_advanced_cfg_toggle_action)
@ -5634,44 +5280,6 @@ class SidebandApp(MDApp):
ate_dialog.open()
### Utilities Screen
######################################
def utilities_init(self):
if not self.utilities_ready:
self.utilities_screen = Utilities(self)
self.utilities_ready = True
def utilities_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "utilities_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def utilities_action(self, sender=None, direction="left"):
if self.utilities_ready:
self.utilities_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.utilities_init()
def o(dt):
self.utilities_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def close_sub_utilities_action(self, sender=None):
self.utilities_action(direction="right")
### Telemetry Screen
######################################
@ -6667,9 +6275,6 @@ class DialogItem(OneLineIconListItem):
class MDMapIconButton(MDIconButton):
pass
class UIScaling(BoxLayout):
pass
if not args.daemon:
from kivy.base import ExceptionManager, ExceptionHandler
class SidebandExceptionHandler(ExceptionHandler):
@ -6705,6 +6310,3 @@ def run():
if __name__ == "__main__":
run()
if __name__ == "sbapp.main":
run()

View File

@ -13,22 +13,11 @@
<!-- This intent filter allows opening scanned LXM URLs directly in Sideband -->
<intent-filter>
<action android:name="android.intent.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />

View File

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/water.css">
<link rel="shortcut icon" type="image/x-icon" href="gfx/icon.png">
<meta charset="utf-8"/>
<title>Sideband Repository</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<span class="logo">RNode Flasher</span>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="flasher.html">RNode Flasher</a> | <a href="guides.html">Guides</a></span></center></p><hr>
<br/>Sideband includes a copy of the web-based RNode Flasher developed by <a href="https://github.com/liamcottle/rnode-flasher">Liam Cottle</a>. You can use this flasher to install and provision the RNode firmware on any compatible boards.<br/>
<br/>
<b>Please note!</b> Your browser must support Web-USB for this to work.<br/>
<br/>
To use the flasher, you will need firmware packages for the boards you want use. You can obtain these in different ways:
<ul>
<li>Sideband can automatically download the latest release of these, and include them directly in this repository.
<ul>
<li>To do so, go to the <b>Repository</b> menu item, and select <b>Update Contents</b>.</li>
<li>After that, they will be available on the <a href="pkgs.html">Software</a> page of this repository.</li>
</ul>
</li>
<li>You can download them manually from <a href="https://github.com/markqvist/RNode_Firmware/releases/latest">the latest release page on GitHub</a>.</li>
<li>You can compile them yourself from the RNode Firmware source code package <a href="pkgs.html">included in this repository</a>.</li>
</ul>
<br/>
<center><a href="/mirrors/rnode-flasher/index.html"><button type="button" id="task-replicate">Launch Web Flasher</button></a></center>
<br/>
<hr>
<p><center></p>
</body></html>

View File

@ -9,7 +9,7 @@
</head>
<body>
<span class="logo">Guides</span>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="flasher.html">RNode Flasher</a> | <a href="guides.html">Guides</a></span></center></p><hr><br/>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="guides.html">Guides</a></span></center></p><hr>
Welcome to the <b>Guide Section</b>!<br/><br/>From here, you can browse or download various included manuals, documentation, references and guides.
<ul>
@ -19,7 +19,6 @@ Welcome to the <b>Guide Section</b>!<br/><br/>From here, you can browse or downl
<li><a href="./mirrors/Reticulum_Manual.epub">Download the Reticulum Manual in EPUB format</a></li>
<li><a href="./mirrors/reticulum.network/index.html">Browse a local copy of the Reticulum website</a></li>
</ul>
<br/>
<hr>
<p><center></p>
</body></html>

View File

@ -9,9 +9,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<<<<<<< HEAD
<span class="logo">openCom Companion Repo</span>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="flasher.html">RNode Flasher</a> |<a href="guides.html">Guides</a></span></center></p><hr><h2>Hello!</h2>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="guides.html">Guides</a></span></center></p><hr><h2>Hello!</h2>
<table style="margin-bottom: 1.5em;">
<tbody>
<tr>

View File

@ -9,10 +9,10 @@
</head>
<body>
<span class="logo">Software</span>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="flasher.html">RNode Flasher</a> | <a href="guides.html">Guides</a></span></center></p><hr><br/>
<p><center><span class="menu"><a href="index.html">Start</a> | <a href="pkgs.html">Software</a> | <a href="guides.html">Guides</a></span></center></p><hr>
Welcome to the <b>Software Library</b>!<br/><br/>From here, you can download installable Python Wheel packages of Reticulum and various other auxillary programs and utilities.
<ul id="filelist">
</ul><br/>
</ul>
<hr>
<p><center></p>
</body></html>

View File

@ -1,101 +0,0 @@
# MIT License
#
# Copyright (c) 2024 Mark Qvist / unsigned.io.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
KEY_PASSPHRASE = None
LOADED_KEY = None
import os
import RNS
import datetime
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography import __version__ as cryptography_version_str
try:
cryptography_major_version = int(cryptography_version_str.split(".")[0])
except:
RNS.log(f"Could not determine PyCA/cryptography version: {e}", RNS.LOG_ERROR)
RNS.log(f"Assuming recent version with automatic backend selection", RNS.LOG_ERROR)
def get_key(key_path, force_reload=False):
KEY_PATH = key_path
key = None
if LOADED_KEY != None and not force_reload:
return LOADED_KEY
elif os.path.isfile(KEY_PATH):
with open(KEY_PATH, "rb") as f:
key = load_pem_private_key(f.read(), KEY_PASSPHRASE)
else:
if cryptography_major_version > 3:
key = ec.generate_private_key(curve=ec.SECP256R1())
else:
from cryptography.hazmat.backends import default_backend
key = ec.generate_private_key(curve=ec.SECP256R1(), backend=default_backend())
if KEY_PASSPHRASE == None:
key_encryption = serialization.NoEncryption()
else:
key_encryption = serialization.BestAvailableEncryption(KEY_PASSPHRASE)
with open(KEY_PATH, "wb") as f:
f.write(key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=key_encryption))
return key
def gen_cert(cert_path, key):
CERT_PATH = cert_path
cert_attrs = [x509.NameAttribute(NameOID.COUNTRY_NAME, "NA"),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, "None"),
x509.NameAttribute(NameOID.LOCALITY_NAME, "Earth"),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "Sideband"),
x509.NameAttribute(NameOID.COMMON_NAME, "Sideband Repository")]
issuer = x509.Name(cert_attrs)
subject = issuer
cb = x509.CertificateBuilder()
cb = cb.subject_name(subject)
cb = cb.issuer_name(issuer)
cb = cb.public_key(key.public_key())
cb = cb.serial_number(x509.random_serial_number())
cb = cb.not_valid_before(datetime.datetime.now(datetime.timezone.utc)+datetime.timedelta(days=-14))
cb = cb.not_valid_after(datetime.datetime.now(datetime.timezone.utc)+datetime.timedelta(days=3652))
cb = cb.add_extension(x509.SubjectAlternativeName([x509.DNSName("localhost")]), critical=False)
if cryptography_major_version > 3:
cert = cb.sign(key, hashes.SHA256())
else:
from cryptography.hazmat.backends import default_backend
cert = cb.sign(key, hashes.SHA256(), backend=default_backend())
with open(CERT_PATH, "wb") as f:
f.write(cert.public_bytes(serialization.Encoding.PEM))
def ensure_certificate(key_path, cert_path):
gen_cert(cert_path, get_key(key_path))
return cert_path

View File

@ -10,13 +10,11 @@ import shlex
import RNS.vendor.umsgpack as msgpack
import RNS.Interfaces.Interface as Interface
from LXMF import pn_announce_data_is_valid
import multiprocessing.connection
from copy import deepcopy
from threading import Lock
from collections import deque
from .res import sideband_fb_data
from .sense import Telemeter, Commands
from .plugins import SidebandCommandPlugin, SidebandServicePlugin, SidebandTelemetryPlugin
@ -45,49 +43,38 @@ class PropagationNodeDetector():
aspect_filter = "lxmf.propagation"
def received_announce(self, destination_hash, announced_identity, app_data, announce_packet_hash):
def received_announce(self, destination_hash, announced_identity, app_data):
try:
if app_data != None and len(app_data) > 0:
if pn_announce_data_is_valid(app_data):
unpacked = msgpack.unpackb(app_data)
node_active = unpacked[0]
emitted = unpacked[1]
hops = RNS.Transport.hops_to(destination_hash)
unpacked = msgpack.unpackb(app_data)
node_active = unpacked[0]
emitted = unpacked[1]
hops = RNS.Transport.hops_to(destination_hash)
age = time.time() - emitted
if age < 0:
RNS.log("Warning, propagation node announce emitted in the future, possible timing inconsistency or tampering attempt.")
if age < -1*PropagationNodeDetector.EMITTED_DELTA_GRACE:
raise ValueError("Announce timestamp too far in the future, discarding it")
age = time.time() - emitted
if age < 0:
RNS.log("Warning, propagation node announce emitted in the future, possible timing inconsistency or tampering attempt.")
if age < -1*PropagationNodeDetector.EMITTED_DELTA_GRACE:
raise ValueError("Announce timestamp too far in the future, discarding it")
if age > -1*PropagationNodeDetector.EMITTED_DELTA_IGNORE:
# age = 0
pass
if age > -1*PropagationNodeDetector.EMITTED_DELTA_IGNORE:
# age = 0
pass
link_stats = {"rssi": self.owner_app.sideband.reticulum.get_packet_rssi(announce_packet_hash),
"snr": self.owner_app.sideband.reticulum.get_packet_snr(announce_packet_hash),
"q": self.owner_app.sideband.reticulum.get_packet_q(announce_packet_hash)}
RNS.log("Detected active propagation node "+RNS.prettyhexrep(destination_hash)+" emission "+str(age)+" seconds ago, "+str(hops)+" hops away")
self.owner.log_announce(destination_hash, RNS.prettyhexrep(destination_hash).encode("utf-8"), dest_type=PropagationNodeDetector.aspect_filter)
RNS.log("Detected active propagation node "+RNS.prettyhexrep(destination_hash)+" emission "+str(age)+" seconds ago, "+str(hops)+" hops away")
self.owner.log_announce(destination_hash, app_data, dest_type=PropagationNodeDetector.aspect_filter, link_stats=link_stats)
if self.owner.config["lxmf_propagation_node"] == None:
if self.owner.active_propagation_node == None:
if self.owner.config["lxmf_propagation_node"] == None:
if self.owner.active_propagation_node == None:
self.owner.set_active_propagation_node(destination_hash)
else:
prev_hops = RNS.Transport.hops_to(self.owner.active_propagation_node)
if hops <= prev_hops:
self.owner.set_active_propagation_node(destination_hash)
else:
prev_hops = RNS.Transport.hops_to(self.owner.active_propagation_node)
if hops <= prev_hops:
self.owner.set_active_propagation_node(destination_hash)
else:
pass
else:
pass
pass
else:
RNS.log(f"Received malformed propagation node announce from {RNS.prettyhexrep(destination_hash)} with data: {app_data}", RNS.LOG_DEBUG)
else:
RNS.log(f"Received malformed propagation node announce from {RNS.prettyhexrep(destination_hash)} with data: {app_data}", RNS.LOG_DEBUG)
pass
except Exception as e:
RNS.log("Error while processing received propagation node announce: "+str(e))
@ -115,17 +102,11 @@ class SidebandCore():
DEFAULT_APPEARANCE = ["account", [0,0,0,1], [1,1,1,1]]
LOG_DEQUE_MAXLEN = 128
aspect_filter = "lxmf.delivery"
def received_announce(self, destination_hash, announced_identity, app_data, announce_packet_hash):
def received_announce(self, destination_hash, announced_identity, app_data):
# Add the announce to the directory announce
# stream logger
link_stats = {"rssi": self.reticulum.get_packet_rssi(announce_packet_hash),
"snr": self.reticulum.get_packet_snr(announce_packet_hash),
"q": self.reticulum.get_packet_q(announce_packet_hash)}
# This reformats the new v0.5.0 announce data back to the expected format
# for Sidebands database and other handling functions.
dn = LXMF.display_name_from_app_data(app_data)
@ -134,7 +115,7 @@ class SidebandCore():
if dn != None:
app_data = dn.encode("utf-8")
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter, stamp_cost=sc, link_stats=link_stats)
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter, stamp_cost=sc)
def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False):
self.is_service = is_service
@ -153,7 +134,6 @@ class SidebandCore():
self.is_standalone = False
self.log_verbose = verbose
self.log_deque = deque(maxlen=self.LOG_DEQUE_MAXLEN)
self.owner_app = owner_app
self.reticulum = None
self.webshare_server = None
@ -168,7 +148,6 @@ class SidebandCore():
self.telemetry_send_blocked_until = 0
self.pending_telemetry_request = False
self.telemetry_request_max_history = 7*24*60*60
self.live_tracked_objects = {}
self.default_lxm_limit = 128*1000
self.state_db = {}
self.state_lock = Lock()
@ -180,7 +159,6 @@ class SidebandCore():
self.owner_service = owner_service
self.allow_service_dispatch = True
self.version_str = ""
self.config_template = rns_config
if config_path == None:
self.app_dir = plyer.storagepath.get_home_dir()+"/.config/occ"
@ -192,21 +170,19 @@ class SidebandCore():
self.cache_dir = self.app_dir+"/cache"
self.rns_configdir = None
core_path = os.path.abspath(__file__)
if "core.pyc" in core_path:
core_path = core_path.replace("core.pyc", "core.py")
if RNS.vendor.platformutils.is_android():
self.app_dir = android_app_dir+"/uk.co.liberatedsystems.occ/files/"
self.cache_dir = self.app_dir+"/cache"
self.rns_configdir = self.app_dir+"/app_storage/reticulum"
self.asset_dir = self.app_dir+"/app/assets"
elif RNS.vendor.platformutils.is_darwin():
core_path = os.path.abspath(__file__)
self.asset_dir = core_path.replace("/occ/core.py", "/assets")
elif RNS.vendor.platformutils.get_platform() == "linux":
core_path = os.path.abspath(__file__)
self.asset_dir = core_path.replace("/occ/core.py", "/assets")
elif RNS.vendor.platformutils.is_windows():
core_path = os.path.abspath(__file__)
self.asset_dir = core_path.replace("\\occ\\core.py", "\\assets")
else:
self.asset_dir = plyer.storagepath.get_application_dir()+"/sbapp/assets"
@ -219,10 +195,6 @@ class SidebandCore():
if not os.path.isdir(self.rec_cache):
os.makedirs(self.rec_cache)
self.share_cache = self.cache_dir+"/share"
if not os.path.isdir(self.share_cache):
os.makedirs(self.share_cache)
self.icon = self.asset_dir+"/icon.png"
self.icon_48 = self.asset_dir+"/icon_48.png"
self.icon_32 = self.asset_dir+"/icon_32.png"
@ -242,14 +214,7 @@ class SidebandCore():
self.log_dir = self.app_dir+"/app_storage/"
self.tmp_dir = self.app_dir+"/app_storage/tmp"
self.exports_dir = self.app_dir+"/exports"
if RNS.vendor.platformutils.is_android():
self.webshare_dir = "./share/"
else:
sideband_dir = os.path.dirname(os.path.abspath(__file__))
self.webshare_dir = os.path.abspath(os.path.join(sideband_dir, "..", "share"))
self.webshare_ssl_key_path = self.app_dir+"/app_storage/ssl_key.pem"
self.webshare_ssl_cert_path = self.app_dir+"/app_storage/ssl_cert.pem"
self.webshare_dir = "./share/"
self.first_run = True
self.saving_configuration = False
@ -288,29 +253,6 @@ class SidebandCore():
if load_config_only:
return
if RNS.vendor.platformutils.is_android():
if self.config["config_template"] != None:
try:
if not os.path.isfile(self.rns_configdir+"/config_template_invalid"):
if self.is_service:
with open(self.rns_configdir+"/config_template_invalid", "w") as invalidation_file:
invalidation_file.write("\n")
ct = self.config["config_template"]
RNS.log(f"Loading modified RNS config template", RNS.LOG_WARNING)
self.config_template = ct
else:
RNS.log("Custom configuration template invalid, using default configuration template", RNS.LOG_WARNING)
self.config_template = rns_config
if self.is_service:
self.setstate("hardware_operation.error", "At the previous start, Sideband could not initialise Reticulum. Custom configuration template loading has been temporarily disabled. Please check and fix any errors in your configuration template.")
except Exception as e:
RNS.log(f"An error occurred while setting RNS configuration template: {e}", RNS.LOG_ERROR)
RNS.log(f"Using default configuration template", RNS.LOG_ERROR)
self.config_template = rns_config
# Initialise Reticulum configuration
if RNS.vendor.platformutils.get_platform() == "android":
try:
@ -321,10 +263,11 @@ class SidebandCore():
RNS.log("Configuring Reticulum instance...")
if self.config["connect_transport"]:
RNS.log("Enabling Reticulum Transport")
generated_config = self.config_template.replace("TRANSPORT_IS_ENABLED", "Yes")
generated_config = rns_config.replace("TRANSPORT_IS_ENABLED", "Yes")
else:
RNS.log("Not enabling Reticulum Transport")
generated_config = self.config_template.replace("TRANSPORT_IS_ENABLED", "No")
generated_config = rns_config.replace("TRANSPORT_IS_ENABLED", "No")
config_file = open(self.rns_configdir+"/config", "wb")
config_file.write(generated_config.encode("utf-8"))
@ -430,7 +373,7 @@ class SidebandCore():
self.config["debug"] = False
self.config["display_name"] = "Anonymous Peer"
self.config["notifications_on"] = True
self.config["dark_ui"] = True
self.config["dark_ui"] = False
self.config["start_announce"] = True
self.config["propagation_by_default"] = False
self.config["home_node_as_broadcast_repeater"] = False
@ -446,9 +389,8 @@ class SidebandCore():
self.config["last_lxmf_propagation_node"] = None
self.config["nn_home_node"] = None
self.config["print_command"] = "lp"
self.config["eink_mode"] = True
self.config["eink_mode"] = False
self.config["lxm_limit_1mb"] = True
self.config["trusted_markup_only"] = False
# Connectivity
self.config["connect_transport"] = False
@ -613,7 +555,7 @@ class SidebandCore():
if not "dark_ui" in self.config:
self.config["dark_ui"] = True
if not "advanced_stats" in self.config:
self.config["advanced_stats"] = True
self.config["advanced_stats"] = False
if not "lxmf_periodic_sync" in self.config:
self.config["lxmf_periodic_sync"] = False
if not "lxmf_ignore_unknown" in self.config:
@ -633,17 +575,13 @@ class SidebandCore():
if not "print_command" in self.config:
self.config["print_command"] = "lp"
if not "eink_mode" in self.config:
self.config["eink_mode"] = True
if not "classic_message_colors" in self.config:
self.config["classic_message_colors"] = False
self.config["eink_mode"] = False
if not "display_style_in_contact_list" in self.config:
self.config["display_style_in_contact_list"] = True
self.config["display_style_in_contact_list"] = False
if not "lxm_limit_1mb" in self.config:
self.config["lxm_limit_1mb"] = True
if not "hq_ptt" in self.config:
self.config["hq_ptt"] = False
if not "trusted_markup_only" in self.config:
self.config["trusted_markup_only"] = False
if not "input_language" in self.config:
self.config["input_language"] = None
@ -652,8 +590,6 @@ class SidebandCore():
if not "block_predictive_text" in self.config:
self.config["block_predictive_text"] = False
if not "config_template" in self.config:
self.config["config_template"] = None
if not "connect_transport" in self.config:
self.config["connect_transport"] = False
if not "connect_rnode" in self.config:
@ -789,11 +725,11 @@ class SidebandCore():
if not "telemetry_bg" in self.config:
self.config["telemetry_bg"] = SidebandCore.DEFAULT_APPEARANCE[2]
if not "telemetry_send_appearance" in self.config:
self.config["telemetry_send_appearance"] = True
self.config["telemetry_send_appearance"] = False
if not "telemetry_display_trusted_only" in self.config:
self.config["telemetry_display_trusted_only"] = False
if not "display_style_from_all" in self.config:
self.config["display_style_from_all"] = True
self.config["display_style_from_all"] = False
if not "telemetry_receive_trusted_only" in self.config:
self.config["telemetry_receive_trusted_only"] = False
@ -904,8 +840,9 @@ class SidebandCore():
time.sleep(0.15)
try:
self.saving_configuration = True
with open(self.config_path, "wb") as config_file:
config_file.write(msgpack.packb(self.config))
config_file = open(self.config_path, "wb")
config_file.write(msgpack.packb(self.config))
config_file.close()
self.saving_configuration = False
except Exception as e:
self.saving_configuration = False
@ -1036,14 +973,13 @@ class SidebandCore():
else:
plyer.notification.notify(title, content, app_icon=self.icon_32)
def log_announce(self, dest, app_data, dest_type, stamp_cost=None, link_stats=None):
def log_announce(self, dest, app_data, dest_type, stamp_cost=None):
try:
if app_data == None:
app_data = b""
if type(app_data) != bytes:
app_data = msgpack.packb([app_data, stamp_cost])
app_data = msgpack.packb([app_data, stamp_cost])
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+str(app_data), RNS.LOG_DEBUG)
self._db_save_announce(dest, app_data, dest_type, link_stats)
self._db_save_announce(dest, app_data, dest_type)
self.setstate("app.flags.new_announces", True)
except Exception as e:
@ -1365,7 +1301,7 @@ class SidebandCore():
else:
return False
def request_latest_telemetry(self, from_addr=None, is_livetrack=False):
def request_latest_telemetry(self, from_addr=None):
if self.allow_service_dispatch and self.is_client:
try:
return self._service_request_latest_telemetry(from_addr)
@ -1399,11 +1335,7 @@ class SidebandCore():
if self.config["telemetry_use_propagation_only"] == True:
desired_method = LXMF.LXMessage.PROPAGATED
else:
if not self.message_router.delivery_link_available(from_addr) and RNS.Identity.current_ratchet_id(from_addr) != None:
RNS.log(f"Have ratchet for {RNS.prettyhexrep(from_addr)}, requesting opportunistic delivery of telemetry request", RNS.LOG_DEBUG)
desired_method = LXMF.LXMessage.OPPORTUNISTIC
else:
desired_method = LXMF.LXMessage.DIRECT
desired_method = LXMF.LXMessage.DIRECT
request_timebase = self.getpersistent(f"telemetry.{RNS.hexrep(from_addr, delimit=False)}.timebase") or now - self.telemetry_request_max_history
lxm_fields = { LXMF.FIELD_COMMANDS: [
@ -1416,7 +1348,7 @@ class SidebandCore():
lxm.register_failed_callback(self.telemetry_request_finished)
if self.message_router.get_outbound_propagation_node() != None:
if self.config["telemetry_try_propagation_on_fail"] and not is_livetrack:
if self.config["telemetry_try_propagation_on_fail"]:
lxm.try_propagation_on_fail = True
RNS.log(f"Sending telemetry request with timebase {request_timebase}", RNS.LOG_DEBUG)
@ -1428,62 +1360,6 @@ class SidebandCore():
else:
return "not_sent"
def _is_tracking(self, object_addr):
return object_addr in self.live_tracked_objects
def is_tracking(self, object_addr, allow_cache=False):
if not RNS.vendor.platformutils.is_android():
return self._is_tracking(object_addr)
else:
if self.is_service:
return self._is_tracking(object_addr)
else:
try:
return self.service_rpc_request({"is_tracking": object_addr})
except Exception as e:
ed = "Error while getting tracking state over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return ed
def _start_tracking(self, object_addr, interval, duration):
RNS.log("Starting tracking of "+RNS.prettyhexrep(object_addr), RNS.LOG_DEBUG)
self.live_tracked_objects[object_addr] = [interval, 0, time.time()+duration]
def start_tracking(self, object_addr, interval, duration, allow_cache=False):
if not RNS.vendor.platformutils.is_android():
return self._start_tracking(object_addr, interval, duration)
else:
if self.is_service:
return self._start_tracking(object_addr, interval, duration)
else:
try:
args = {"object_addr": object_addr, "interval": interval, "duration": duration}
return self.service_rpc_request({"start_tracking": args})
except Exception as e:
ed = "Error while starting tracking over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return ed
def _stop_tracking(self, object_addr):
RNS.log("Stopping tracking of "+RNS.prettyhexrep(object_addr), RNS.LOG_DEBUG)
if object_addr in self.live_tracked_objects:
self.live_tracked_objects.pop(object_addr)
def stop_tracking(self, object_addr, allow_cache=False):
if not RNS.vendor.platformutils.is_android():
return self._stop_tracking(object_addr)
else:
if self.is_service:
return self._stop_tracking(object_addr)
else:
try:
args = {"object_addr": object_addr}
return self.service_rpc_request({"stop_tracking": args})
except Exception as e:
ed = "Error while stopping tracking over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return ed
def _service_send_latest_telemetry(self, to_addr=None, stream=None, is_authorized_telemetry_request=False):
if not RNS.vendor.platformutils.is_android():
return False
@ -1539,11 +1415,7 @@ class SidebandCore():
if self.config["telemetry_use_propagation_only"] == True:
desired_method = LXMF.LXMessage.PROPAGATED
else:
if not self.message_router.delivery_link_available(to_addr) and RNS.Identity.current_ratchet_id(to_addr) != None:
RNS.log(f"Have ratchet for {RNS.prettyhexrep(to_addr)}, requesting opportunistic delivery of telemetry", RNS.LOG_DEBUG)
desired_method = LXMF.LXMessage.OPPORTUNISTIC
else:
desired_method = LXMF.LXMessage.DIRECT
desired_method = LXMF.LXMessage.DIRECT
lxm_fields = self.get_message_fields(to_addr, is_authorized_telemetry_request=is_authorized_telemetry_request, signal_already_sent=True)
if lxm_fields == False and stream == None:
@ -1954,14 +1826,6 @@ class SidebandCore():
elif "get_lxm_stamp_cost" in call:
args = call["get_lxm_stamp_cost"]
connection.send(self.get_lxm_stamp_cost(args["lxm_hash"]))
elif "is_tracking" in call:
connection.send(self.is_tracking(call["is_tracking"]))
elif "start_tracking" in call:
args = call["start_tracking"]
connection.send(self.start_tracking(object_addr=args["object_addr"], interval=args["interval"], duration=args["duration"]))
elif "stop_tracking" in call:
args = call["stop_tracking"]
connection.send(self.stop_tracking(object_addr=args["object_addr"]))
else:
connection.send(None)
@ -2055,10 +1919,10 @@ class SidebandCore():
# TODO: Remove this again at some point in the future
db = self.__db_connect()
dbc = db.cursor()
dbc.execute("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'announce' AND sql LIKE '%extra%'")
dbc.execute("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'lxm' AND sql LIKE '%extra%'")
result = dbc.fetchall()
if len(result) == 0:
dbc.execute("ALTER TABLE announce ADD COLUMN extra BLOB")
dbc.execute("ALTER TABLE lxm ADD COLUMN extra BLOB")
db.commit()
def _db_initstate(self):
@ -2615,29 +2479,13 @@ class SidebandCore():
for entry in result:
try:
if not entry[2] in added_dests:
app_data = entry[3]
dest_type = entry[4]
if entry[5] != None:
try:
extras = msgpack.unpackb(entry[5])
except Exception as e:
RNS.log(f"Error while unpacking extras from announce: {e}", RNS.LOG_ERROR)
extras = None
else:
extras = None
if dest_type == "lxmf.delivery":
announced_name = LXMF.display_name_from_app_data(app_data)
announced_cost = self.message_router.get_outbound_stamp_cost(entry[2])
else:
announced_name = None
announced_cost = None
app_data = entry[3]
announce = {
"dest" : entry[2],
"name" : announced_name,
"cost" : announced_cost,
"time" : entry[1],
"type" : dest_type,
"extras": extras,
"dest": entry[2],
"name": LXMF.display_name_from_app_data(app_data),
"cost": LXMF.stamp_cost_from_app_data(app_data),
"time": entry[1],
"type": entry[4]
}
added_dests.append(entry[2])
announces.append(announce)
@ -3051,7 +2899,7 @@ class SidebandCore():
self.__event_conversation_changed(context_dest)
def _db_save_announce(self, destination_hash, app_data, dest_type="lxmf.delivery", link_stats = None):
def _db_save_announce(self, destination_hash, app_data, dest_type="lxmf.delivery"):
with self.db_lock:
db = self.__db_connect()
dbc = db.cursor()
@ -3065,16 +2913,14 @@ class SidebandCore():
now = time.time()
hash_material = str(time).encode("utf-8")+destination_hash+app_data+dest_type.encode("utf-8")
announce_hash = RNS.Identity.full_hash(hash_material)
extras = msgpack.packb({"link_stats": link_stats})
query = "INSERT INTO announce (id, received, source, data, dest_type, extra) values (?, ?, ?, ?, ?, ?)"
query = "INSERT INTO announce (id, received, source, data, dest_type) values (?, ?, ?, ?, ?)"
data = (
announce_hash,
now,
destination_hash,
app_data,
dest_type,
extras,
)
dbc.execute(query, data)
@ -3598,28 +3444,6 @@ class SidebandCore():
except Exception as e:
RNS.log("An error occurred while requesting scheduled telemetry from collector: "+str(e), RNS.LOG_ERROR)
stale_entries = []
if len(self.live_tracked_objects) > 0:
now = time.time()
for object_hash in self.live_tracked_objects:
tracking_entry = self.live_tracked_objects[object_hash]
tracking_int = tracking_entry[0]
tracking_last = tracking_entry[1]
tracking_end = tracking_entry[2]
if now < tracking_end:
if now > tracking_last+tracking_int:
RNS.log("Next live tracking request time reached for "+str(RNS.prettyhexrep(object_hash)))
self.request_latest_telemetry(from_addr=object_hash, is_livetrack=True)
tracking_entry[1] = time.time()
else:
stale_entries.append(object_hash)
for object_hash in stale_entries:
RNS.log("Terminating live tracking for "+RNS.prettyhexrep(object_hash)+", tracking duration reached", RNS.LOG_DEBUG)
self.live_tracked_objects.pop(object_hash)
def __start_jobs_deferred(self):
if self.is_service:
self.service_thread = threading.Thread(target=self._service_jobs, daemon=True)
@ -3664,12 +3488,11 @@ class SidebandCore():
else:
ifac_netkey = self.config["connect_local_ifac_passphrase"]
interface_config = {
"name": "AutoInterface",
"group_id": group_id
}
autointerface = RNS.Interfaces.AutoInterface.AutoInterface(RNS.Transport, interface_config)
autointerface = RNS.Interfaces.AutoInterface.AutoInterface(
RNS.Transport,
name = "AutoInterface",
group_id = group_id
)
autointerface.OUT = True
if RNS.Reticulum.transport_enabled():
@ -3719,6 +3542,7 @@ class SidebandCore():
if self.config["hw_rnode_bluetooth"]:
RNS.log("Allowing RNode bluetooth", RNS.LOG_DEBUG)
rnode_allow_bluetooth = True
ble_dispatcher = RNS.Interfaces.Android.RNodeMultiInterface.AndroidBLEDispatcher()
if self.config["hw_rnode_bt_device"] != None:
bt_device_name = self.config["hw_rnode_bt_device"]
@ -3749,8 +3573,6 @@ class SidebandCore():
else:
atl_long = self.config["hw_rnode_atl_long"]
interface_config = None
if self.config["hw_rnode_secondary_modem"]:
if self.config["hw_rnode_sec_atl_short"] == "":
sec_atl_short = None
@ -3790,46 +3612,36 @@ class SidebandCore():
subint_config[0][9] = sec_atl_long
subint_config[1][10] = True # outgoing
interface_config = {
"name": "RNodeMultiInterface",
"port": target_port,
"subint_config": subint_config,
"flow_control": False,
"id_interval": self.config["hw_rnode_beaconinterval"],
"id_callsign": self.config["hw_rnode_beacondata"],
"st_alock": atl_short,
"lt_alock": atl_long,
"allow_bluetooth": False,
"target_device_name": None,
"force_ble": True,
"ble_name": bt_device_name,
"ble_addr": None,
}
rnodeinterface = RNS.Interfaces.Android.RNodeMultiInterface.RNodeMultiInterface(
RNS.Transport,
"RNodeInterface",
target_port,
subint_config,
ble_dispatcher = ble_dispatcher,
allow_bluetooth = rnode_allow_bluetooth,
target_device_name = bt_device_name,
)
rnodeinterface = RNS.Interfaces.Android.RNodeMultiInterface.RNodeMultiInterface(RNS.Transport, interface_config)
rnodeinterface.start()
else:
interface_config = {
"name": "RNodeInterface",
"port": target_port,
"frequency": self.config["hw_rnode_frequency"],
"bandwidth": self.config["hw_rnode_bandwidth"],
"txpower": self.config["hw_rnode_tx_power"],
"spreadingfactor": self.config["hw_rnode_spreading_factor"],
"codingrate": self.config["hw_rnode_coding_rate"],
"flow_control": False,
"id_interval": self.config["hw_rnode_beaconinterval"],
"id_callsign": self.config["hw_rnode_beacondata"],
"st_alock": atl_short,
"lt_alock": atl_long,
"allow_bluetooth": False,
"target_device_name": bt_device_name,
"force_ble": True,
"ble_name": None,
"ble_addr": None,
}
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface(
RNS.Transport,
"RNodeInterface",
target_port,
frequency = self.config["hw_rnode_frequency"],
bandwidth = self.config["hw_rnode_bandwidth"],
txpower = self.config["hw_rnode_tx_power"],
sf = self.config["hw_rnode_spreading_factor"],
cr = self.config["hw_rnode_coding_rate"],
flow_control = None,
id_interval = self.config["hw_rnode_beaconinterval"],
id_callsign = self.config["hw_rnode_beacondata"],
allow_bluetooth = rnode_allow_bluetooth,
target_device_name = bt_device_name,
st_alock = atl_short,
lt_alock = atl_long,
)
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface(RNS.Transport, interface_config)
rnodeinterface.OUT = True
if RNS.Reticulum.transport_enabled():
@ -3864,7 +3676,6 @@ class SidebandCore():
except Exception as e:
RNS.log("Error while adding RNode Interface. The contained exception was: "+str(e))
RNS.trace_exception(e)
self.interface_rnode = None
def _reticulum_log_debug(self, debug=False):
@ -3878,14 +3689,6 @@ class SidebandCore():
if self.is_client:
self.service_rpc_set_debug(debug)
def _log_handler(self, message):
self.log_deque.append(message)
print(message)
# TODO: Get service log on Android
def get_log(self):
return "\n".join(self.log_deque)
def __start_jobs_immediate(self):
if self.log_verbose:
selected_level = 7 # debugging purposes
@ -3893,20 +3696,7 @@ class SidebandCore():
selected_level = 2
self.setstate("init.loadingstate", "Substantiating Reticulum")
try:
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler)
if RNS.vendor.platformutils.is_android():
if self.is_service:
if os.path.isfile(self.rns_configdir+"/config_template_invalid"):
os.unlink(self.rns_configdir+"/config_template_invalid")
else:
pass
except Exception as e:
RNS.log(f"Error while instantiating Reticulum: {e}", RNS.LOG_ERROR)
RNS.log(f"Local configuration template changes will be ignored on next start", RNS.LOG_ERROR)
exit(255)
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level)
if self.is_service:
self.__start_rpc_listener()
@ -3960,14 +3750,15 @@ class SidebandCore():
else:
ifac_size = None
interface_config = {
"name": "TCPClientInterface",
"target_host": tcp_host,
"target_port": tcp_port,
"kiss_framing": False,
"i2p_tunneled": False,
}
tcpinterface = RNS.Interfaces.TCPInterface.TCPClientInterface(RNS.Transport, interface_config)
tcpinterface = RNS.Interfaces.TCPInterface.TCPClientInterface(
RNS.Transport,
"TCPClientInterface",
tcp_host,
tcp_port,
kiss_framing = False,
i2p_tunneled = False
)
tcpinterface.OUT = True
if RNS.Reticulum.transport_enabled():
@ -4011,14 +3802,13 @@ class SidebandCore():
else:
ifac_size = None
interface_config = {
"name": "I2PInterface",
"storagepath": RNS.Reticulum.storagepath,
"peers": [self.config["connect_i2p_b32"]],
"connectable": False,
}
i2pinterface = RNS.Interfaces.I2PInterface.I2PInterface(RNS.Transport, interface_config)
i2pinterface = RNS.Interfaces.I2PInterface.I2PInterface(
RNS.Transport,
"I2PInterface",
RNS.Reticulum.storagepath,
[self.config["connect_i2p_b32"]],
connectable = False,
)
i2pinterface.OUT = True
@ -4071,15 +3861,16 @@ class SidebandCore():
else:
ifac_netkey = self.config["connect_serial_ifac_passphrase"]
interface_config = {
"name": "SerialInterface",
"port": target_device["port"],
"speed": self.config["hw_serial_baudrate"],
"databits": self.config["hw_serial_databits"],
"parity": self.config["hw_serial_parity"],
"stopbits": self.config["hw_serial_stopbits"],
}
serialinterface = RNS.Interfaces.Android.SerialInterface.SerialInterface(RNS.Transport, interface_config)
serialinterface = RNS.Interfaces.Android.SerialInterface.SerialInterface(
RNS.Transport,
"SerialInterface",
target_device["port"],
self.config["hw_serial_baudrate"],
self.config["hw_serial_databits"],
self.config["hw_serial_parity"],
self.config["hw_serial_stopbits"],
)
serialinterface.OUT = True
if RNS.Reticulum.transport_enabled():
@ -4123,22 +3914,23 @@ class SidebandCore():
else:
ifac_netkey = self.config["connect_modem_ifac_passphrase"]
interface_config = {
"name": "ModemInterface",
"port": target_device["port"],
"speed": self.config["hw_modem_baudrate"],
"databits": self.config["hw_modem_databits"],
"parity": self.config["hw_modem_parity"],
"stopbits": self.config["hw_modem_stopbits"],
"preamble": self.config["hw_modem_preamble"],
"txtail": self.config["hw_modem_tail"],
"persistence": self.config["hw_modem_persistence"],
"slottime": self.config["hw_modem_slottime"],
"flow_control": False,
"beacon_interval": self.config["hw_modem_beaconinterval"],
"beacon_data": self.config["hw_modem_beacondata"],
}
modeminterface = RNS.Interfaces.Android.KISSInterface.KISSInterface(RNS.Transport, interface_config)
modeminterface = RNS.Interfaces.Android.KISSInterface.KISSInterface(
RNS.Transport,
"ModemInterface",
target_device["port"],
self.config["hw_modem_baudrate"],
self.config["hw_modem_databits"],
self.config["hw_modem_parity"],
self.config["hw_modem_stopbits"],
self.config["hw_modem_preamble"],
self.config["hw_modem_tail"],
self.config["hw_modem_persistence"],
self.config["hw_modem_slottime"],
False, # flow control
self.config["hw_modem_beaconinterval"],
self.config["hw_modem_beacondata"],
)
modeminterface.OUT = True
if RNS.Reticulum.transport_enabled():
@ -4535,11 +4327,7 @@ class SidebandCore():
try:
addr_b = bytes.fromhex(dest_str)
if addr_b == self.lxmf_destination.hash:
RNS.log("Cannot create conversation with own LXMF address", RNS.LOG_ERROR)
return False
else:
self._db_create_conversation(addr_b, name, trusted)
self._db_create_conversation(addr_b, name, trusted)
except Exception as e:
RNS.log("Error while creating conversation: "+str(e), RNS.LOG_ERROR)
@ -4648,11 +4436,7 @@ class SidebandCore():
if not originator and LXMF.FIELD_AUDIO in message.fields and ptt_enabled:
self.ptt_event(message)
if self.gui_conversation() != context_dest:
if not RNS.vendor.platformutils.is_android():
should_notify = True
else:
should_notify = False
should_notify = False
if self.is_client:
should_notify = False
@ -4790,7 +4574,6 @@ class SidebandCore():
from http import server
import socketserver
import json
import ssl
webshare_dir = self.webshare_dir
port = 4444
@ -4811,7 +4594,7 @@ class SidebandCore():
self.send_response(200)
self.send_header("Content-type", "text/json")
self.end_headers()
json_result = json.dumps(sorted(os.listdir(serve_root+"/pkg")))
json_result = json.dumps(os.listdir(serve_root+"/pkg"))
self.wfile.write(json_result.encode("utf-8"))
except Exception as e:
self.send_response(500)
@ -4826,8 +4609,6 @@ class SidebandCore():
self.send_response(200)
if path.lower().endswith(".apk"):
self.send_header("Content-type", "application/vnd.android.package-archive")
elif path.lower().endswith(".js"):
self.send_header("Content-type", "text/javascript")
self.end_headers()
self.wfile.write(data)
except Exception as e:
@ -4837,36 +4618,7 @@ class SidebandCore():
es = "Error"
self.wfile.write(es.encode("utf-8"))
#######################################################
# Override BaseHTTPRequestHandler method to squelch
# excessive exception logging when client signals
# invalid certificate to the server. This will always
# happen from some clients when using a self-signed
# certificate, so we don't care.
if not hasattr(server.BaseHTTPRequestHandler, "handle_orig"):
server.BaseHTTPRequestHandler.handle_orig = server.BaseHTTPRequestHandler.handle
def handle(self):
try:
self.handle_orig()
except ssl.SSLError:
pass
except Exception as e:
RNS.log("HTTP server exception: "+str(e), RNS.LOG_ERROR)
server.BaseHTTPRequestHandler.handle = handle
#######################################################
socketserver.TCPServer.allow_reuse_address = True
class ThreadedHTTPServer(socketserver.ThreadingMixIn, server.HTTPServer):
daemon_threads = True
with ThreadedHTTPServer(("", port), RequestHandler) as webserver:
from sideband.certgen import ensure_certificate
ensure_certificate(self.webshare_ssl_key_path, self.webshare_ssl_cert_path)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(certfile=self.webshare_ssl_cert_path, keyfile=self.webshare_ssl_key_path)
webserver.socket = ssl_context.wrap_socket(webserver.socket, do_handshake_on_connect=False, server_side=True)
with socketserver.TCPServer(("", port), RequestHandler) as webserver:
self.webshare_server = webserver
webserver.serve_forever()
self.webshare_server = None
@ -5071,41 +4823,15 @@ class SidebandCore():
if not self.reticulum.is_connected_to_shared_instance:
RNS.Transport.detach_interfaces()
rns_config = """# This template is used to generate a
# running configuration for Sideband's
# internal RNS instance. Incorrect changes
# or addition here may cause Sideband to
# fail starting up or working properly.
#
# If Sideband detects that Reticulum
# aborts at startup, due to an error in
# configuration, any template changes
# will be reset to this default.
rns_config = """
[reticulum]
# Don't change this line, use the UI
# setting for selecting whether RNS
# transport is enabled or disabled
enable_transport = TRANSPORT_IS_ENABLED
enable_transport = TRANSPORT_IS_ENABLED
share_instance = Yes
shared_instance_port = 37428
instance_control_port = 37429
panic_on_interface_error = No
# Changing this setting will cause
# Sideband to not work.
share_instance = Yes
# Changing these options should only
# be done if you know what you're doing.
shared_instance_port = 37428
instance_control_port = 37429
panic_on_interface_error = No
# Logging is controlled by settings
# in the UI, so this section is mostly
# not relevant in Sideband.
[logging]
loglevel = 3
loglevel = 3
# No additional interfaces are currently
# defined, but you can use this section
# to do so.
[interfaces]
"""

View File

@ -744,8 +744,7 @@ class Location(Sensor):
if "altitude" in self._raw:
self.altitude = self._raw["altitude"]
if "speed" in self._raw:
# Android GPS reports speed in m/s, convert to km/h
self.speed = self._raw["speed"]*3.6
self.speed = self._raw["speed"]
if self.speed < 0:
self.speed = 0
if "bearing" in self._raw:
@ -778,9 +777,9 @@ class Location(Sensor):
return [
struct.pack("!i", int(round(d["latitude"], 6)*1e6)),
struct.pack("!i", int(round(d["longitude"], 6)*1e6)),
struct.pack("!i", int(round(d["altitude"], 2)*1e2)),
struct.pack("!I", int(round(d["altitude"], 2)*1e2)),
struct.pack("!I", int(round(d["speed"], 2)*1e2)),
struct.pack("!i", int(round(d["bearing"], 2)*1e2)),
struct.pack("!I", int(round(d["bearing"], 2)*1e2)),
struct.pack("!H", int(round(d["accuracy"], 2)*1e2)),
d["last_update"],
]
@ -796,9 +795,9 @@ class Location(Sensor):
return {
"latitude": struct.unpack("!i", packed[0])[0]/1e6,
"longitude": struct.unpack("!i", packed[1])[0]/1e6,
"altitude": struct.unpack("!i", packed[2])[0]/1e2,
"altitude": struct.unpack("!I", packed[2])[0]/1e2,
"speed": struct.unpack("!I", packed[3])[0]/1e2,
"bearing": struct.unpack("!i", packed[4])[0]/1e2,
"bearing": struct.unpack("!I", packed[4])[0]/1e2,
"accuracy": struct.unpack("!H", packed[5])[0]/1e2,
"last_update": packed[6],
}

View File

@ -18,9 +18,9 @@ from kivy.lang.builder import Builder
from kivy.utils import escape_markup
if RNS.vendor.platformutils.get_platform() == "android":
from ui.helpers import multilingual_markup, sig_icon_for_q
from ui.helpers import multilingual_markup
else:
from .helpers import multilingual_markup, sig_icon_for_q
from .helpers import multilingual_markup
if RNS.vendor.platformutils.get_platform() == "android":
from ui.helpers import ts_format
@ -92,25 +92,6 @@ class Announces():
a_name = announce["name"]
a_cost = announce["cost"]
dest_type = announce["type"]
a_rssi = None
a_snr = None
a_q = None
link_extras_str = ""
link_extras_full = ""
if "extras" in announce and announce["extras"] != None:
extras = announce["extras"]
if "link_stats" in extras:
link_stats = extras["link_stats"]
if "rssi" in link_stats and "snr" in link_stats and "q" in link_stats:
a_rssi = link_stats["rssi"]
a_snr = link_stats["snr"]
a_q = link_stats["q"]
if a_rssi != None and a_snr != None and a_q != None:
link_extras_str = f" ([b]RSSI[/b] {a_rssi} [b]SNR[/b] {a_snr})"
link_extras_full = f"\n[b]Link Quality[/b] {a_q}%[/b]\n[b]RSSI[/b] {a_rssi}\n[b]SNR[/b] {a_snr}"
sig_icon = multilingual_markup(sig_icon_for_q(a_q).encode("utf-8")).decode("utf-8")
if not context_dest in self.added_item_dests:
if self.app.sideband.is_trusted(context_dest):
@ -118,16 +99,16 @@ class Announces():
else:
trust_icon = "account-question"
def gen_info(ts, dest, name, cost, dtype, link_extras):
def gen_info(ts, dest, name, cost, dtype):
name = multilingual_markup(escape_markup(str(name)).encode("utf-8")).decode("utf-8")
cost = str(cost)
def x(sender):
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
if dtype == "lxmf.delivery":
ad_text = "[size=22dp]LXMF Peer[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)+"\n[b]Name[/b] "+name+"\n[b]Stamp Cost[/b] "+cost+link_extras
ad_text = "[size=22dp]LXMF Peer[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)+"\n[b]Name[/b] "+name+"\n[b]Stamp Cost[/b] "+cost
if dtype == "lxmf.propagation":
ad_text = "[size=22dp]LXMF Propagation Node[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)+link_extras
ad_text = "[size=22dp]LXMF Propagation Node[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)
dialog = MDDialog(
text=ad_text,
@ -142,8 +123,7 @@ class Announces():
dialog.open()
return x
time_string = sig_icon + " " + time.strftime(ts_format, time.localtime(ts)) + link_extras_str
time_string_plain = time.strftime(ts_format, time.localtime(ts))
time_string = time.strftime(ts_format, time.localtime(ts))
if dest_type == "lxmf.delivery":
disp_name = multilingual_markup(escape_markup(str(self.app.sideband.peer_display_name(context_dest))).encode("utf-8")).decode("utf-8")
@ -157,7 +137,7 @@ class Announces():
disp_name = "Unknown Announce"
iconl = IconLeftWidget(icon="progress-question")
item = TwoLineAvatarIconListItem(text=time_string, secondary_text=disp_name, on_release=gen_info(time_string_plain, context_dest, a_name, a_cost, dest_type, link_extras_full))
item = TwoLineAvatarIconListItem(text=time_string, secondary_text=disp_name, on_release=gen_info(time_string, context_dest, a_name, a_cost, dest_type))
item.add_widget(iconl)
item.sb_uid = context_dest
item.ts = ts

View File

@ -133,7 +133,6 @@ class Conversations():
unread = conv["unread"]
last_activity = conv["last_activity"]
trusted = conv["trust"] == 1
appearance_from_all = self.app.sideband.config["display_style_from_all"]
appearance = self.app.sideband.peer_appearance(context_dest, conv=conv)
is_object = self.app.sideband.is_object(context_dest, conv_data=conv)
da = self.app.sideband.DEFAULT_APPEARANCE
@ -142,7 +141,7 @@ class Conversations():
conv_icon = self.trust_icon(conv)
fg = None; bg = None; ti_color = None
if (trusted or appearance_from_all) and self.app.sideband.config["display_style_in_contact_list"] and appearance != None and appearance != da:
if trusted and self.app.sideband.config["display_style_in_contact_list"] and appearance != None and appearance != da:
fg = appearance[1] or da[1]; bg = appearance[2] or da[2]
ti_color = "Custom"
else:
@ -525,8 +524,8 @@ Builder.load_string("""
id: n_address_field
max_text_length: 32
hint_text: "Address"
helper_text: ""
helper_text_mode: "on_focus"
helper_text: "Error, check your input"
helper_text_mode: "on_error"
text: ""
font_size: dp(24)
@ -653,10 +652,6 @@ Builder.load_string("""
padding: [0, 0, 0, dp(16)]
height: self.minimum_height+dp(24)
MDLabel:
id: node_info
text: "Unknown propagation node"
MDProgressBar:
id: sync_progress
type: "determinate"
@ -664,6 +659,7 @@ Builder.load_string("""
MDLabel:
id: sync_status
hint_text: "Name"
text: "Initiating sync..."

View File

@ -4,7 +4,6 @@ from kivy.uix.screenmanager import ScreenManager, Screen
from kivymd.theming import ThemableBehavior
from kivymd.uix.list import OneLineIconListItem, MDList, IconLeftWidget, IconRightWidget
from kivy.properties import StringProperty
import re
ts_format = "%Y-%m-%d %H:%M:%S"
file_ts_format = "%Y_%m_%d_%H_%M_%S"
@ -26,19 +25,6 @@ intensity_msgs_light = "500"
intensity_play_dark = "600"
intensity_play_light = "300"
intensity_msgs_dark_alt = "800"
intensity_msgs_light_alt = "400"
intensity_delivered_alt_dark = "800"
color_received_alt = "BlueGray"
color_received_alt_light = "BlueGray"
color_delivered_alt = "Indigo"
color_propagated_alt = "DeepPurple"
color_paper_alt = "DeepPurple"
color_playing_alt = "Amber"
color_failed_alt = "Red"
color_unknown_alt = "Gray"
class ContentNavigationDrawer(Screen):
pass
@ -59,12 +45,13 @@ def strip_emojis(str_input):
return output
def multilingual_markup(data):
# TODO: Remove
# import time
# ts = time.time()
do = ""
rfont = "default"
ds = data.decode("utf-8")
di = 0
persistent_regions = [(m.start(), m.end()) for m in re.finditer("(?s)\[font=(?:nf|term)\].*?\[/font\]", ds)]
for cp in ds:
match = False
switch = False
@ -76,10 +63,6 @@ def multilingual_markup(data):
switch = True
rfont = "emoji"
in_persistent = False
if any(x[0] < di and x[1] > di for x in persistent_regions):
in_persistent = True
if not match:
for range_start in codepoint_map:
range_end = codepoint_map[range_start][0]
@ -88,9 +71,8 @@ def multilingual_markup(data):
if range_end >= ord(cp) >= range_start:
match = True
if rfont != mapped_font:
if not in_persistent:
rfont = mapped_font
switch = True
rfont = mapped_font
switch = True
break
if (not match) and rfont != "default":
@ -104,30 +86,15 @@ def multilingual_markup(data):
do += "[font="+str(rfont)+"]"
do += cp
di += 1
if rfont != "default":
do += "[/font]"
# TODO: Remove
# print(do+"\n\n"+str(time.time()-ts))
return do.encode("utf-8")
def sig_icon_for_q(q):
if q == None:
return "󰴽"
elif q > 90:
return "󰣺"
elif q > 70:
return "󰣸"
elif q > 50:
return "󰣶"
elif q > 30:
return "󰣴"
elif q > 10:
return "󰣾"
persistent_fonts = ["nf", "term"]
nf_mapped = "nf"
codepoint_map = {
0x0590: [0x05ff, "hebrew"],
0x2e3a: [0x2e3b, "chinese"],
@ -161,29 +128,6 @@ codepoint_map = {
0xac00: [0xd7af, "korean"],
0xd7b0: [0xd7ff, "korean"],
0x0900: [0x097f, "combined"], # Devanagari
0xe5fa: [0xe6b7, nf_mapped], # Seti-UI + Custom
0xe700: [0xe8ef, nf_mapped], # Devicons
0xed00: [0xf2ff, nf_mapped], # Font Awesome
0xe200: [0xe2a9, nf_mapped], # Font Awesome Extension
0xf0001: [0xf1af0, nf_mapped], # Material Design Icons
0xe300: [0xe3e3, nf_mapped], # Weather
0xf400: [0xf533, nf_mapped], # Octicons
0x2665: [0x2665, nf_mapped], # Octicons
0x26a1: [0x26a1, nf_mapped], # Octicons
0xe0a0: [0xe0a2, nf_mapped], # Powerline Symbols
0xe0b0: [0xe0b3, nf_mapped], # Powerline Symbols
0xe0a3: [0xe0a3, nf_mapped], # Powerline Extra Symbols
0xe0b4: [0xe0c8, nf_mapped], # Powerline Extra Symbols
0xe0ca: [0xe0ca, nf_mapped], # Powerline Extra Symbols
0xe0cc: [0xe0d7, nf_mapped], # Powerline Extra Symbols
0x23fb: [0x23fe, nf_mapped], # IEC Power Symbols
0x2b58: [0x2b58, nf_mapped], # IEC Power Symbols
0xf300: [0xf381, nf_mapped], # Font logos
0xe000: [0xe00a, nf_mapped], # Pomicons
0xea60: [0xec1e, nf_mapped], # Codicons
0x276c: [0x2771, nf_mapped], # Heavy Angle Brackets
0x2500: [0x259f, nf_mapped], # Box Drawing
0xee00: [0xee0b, nf_mapped], # Progress
}
emoji_lookup = [

View File

@ -80,15 +80,6 @@ MDNavigationLayout:
on_release: root.ids.screen_manager.app.map_action(self)
# OneLineIconListItem:
# text: "Overview"
# on_release: root.ids.screen_manager.app.overview_action(self)
# IconLeftWidget:
# icon: "view-dashboard-outline"
# on_release: root.ids.screen_manager.app.overview_action(self)
OneLineIconListItem:
text: "Announce Stream"
on_release: root.ids.screen_manager.app.announces_action(self)
@ -116,15 +107,6 @@ MDNavigationLayout:
on_release: root.ids.screen_manager.app.telemetry_action(self)
OneLineIconListItem:
text: "Utilities"
on_release: root.ids.screen_manager.app.utilities_action(self)
IconLeftWidget:
icon: "tools"
on_release: root.ids.screen_manager.app.utilities_action(self)
OneLineIconListItem:
text: "Preferences"
on_release: root.ids.screen_manager.app.settings_action(self)
@ -1278,28 +1260,6 @@ MDScreen:
"""
layout_settings_screen = """
<UIScaling>
orientation: "vertical"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height+dp(0)
MDLabel:
id: scaling_info
markup: True
text: "You can scale the entire Sideband UI by specifying a scaling factor in the field below. After setting it, restart sideband for the scaling to take effect.\\n\\nSet to 0.0 to disable scaling adjustments.\\n\\n[b]Please note![/b] On some devices, the default scaling factor will be higher than 1.0, and setting a smaller value will result in miniscule UI elements."
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
MDTextField:
id: scaling_factor
hint_text: "Scaling Factor"
helper_text: "From 0.3 to 5.0"
helper_text_mode: "on_focus"
text: ""
font_size: dp(24)
MDScreen:
name: "settings_screen"
@ -1439,21 +1399,11 @@ MDScreen:
size_hint_y: None
height: self.texture_size[1]
MDRectangleFlatIconButton:
id: appearance_ui_scaling
icon: "relative-scale"
text: "Configure UI Scaling"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.app.configure_ui_scaling_action(self)
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,dp(14),dp(24),dp(0)]
height: dp(62)
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Notifications"
@ -1494,21 +1444,6 @@ MDScreen:
pos_hint: {"center_y": 0.3}
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Classic message colors"
font_style: "H6"
MDSwitch:
id: settings_classic_message_colors
pos_hint: {"center_y": 0.3}
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
@ -1583,7 +1518,7 @@ MDScreen:
height: dp(48)
MDLabel:
text: "Announce automatically"
text: "Announce Automatically"
font_style: "H6"
MDSwitch:
@ -1598,7 +1533,7 @@ MDScreen:
height: dp(48)
MDLabel:
text: "Try propagation automatically"
text: "Try propagation on direct delivery failure"
font_style: "H6"
MDSwitch:
@ -1639,22 +1574,6 @@ MDScreen:
disabled: False
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Only render markup from trusted"
font_style: "H6"
MDSwitch:
id: settings_trusted_markup_only
pos_hint: {"center_y": 0.3}
disabled: False
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
@ -1783,21 +1702,21 @@ MDScreen:
disabled: False
active: False
# MDBoxLayout:
# orientation: "horizontal"
# size_hint_y: None
# padding: [0,0,dp(24),dp(0)]
# height: dp(48)
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
# MDLabel:
# text: "Use Home Node as Broadcast Repeater"
# font_style: "H6"
MDLabel:
text: "Use Home Node as Broadcast Repeater"
font_style: "H6"
# MDSwitch:
# id: settings_home_node_as_broadcast_repeater
# pos_hint: {"center_y": 0.3}
# active: False
# disabled: True
MDSwitch:
id: settings_home_node_as_broadcast_repeater
pos_hint: {"center_y": 0.3}
active: False
disabled: True
MDBoxLayout:
orientation: "horizontal"
@ -2684,6 +2603,21 @@ MDScreen:
pos_hint: {"center_y": 0.3}
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Device requires BLE"
font_style: "H6"
MDSwitch:
id: hardware_rnode_ble
pos_hint: {"center_y": 0.3}
active: False
MDLabel:
id: hardware_rnode_info
markup: True

View File

@ -35,13 +35,11 @@ if RNS.vendor.platformutils.get_platform() == "android":
from sideband.sense import Telemeter, Commands
from ui.helpers import ts_format, file_ts_format, mdc
from ui.helpers import color_playing, color_received, color_delivered, color_propagated, color_paper, color_failed, color_unknown, intensity_msgs_dark, intensity_msgs_light, intensity_play_dark, intensity_play_light
from ui.helpers import color_received_alt, color_received_alt_light, color_delivered_alt, color_propagated_alt, color_paper_alt, color_failed_alt, color_unknown_alt, color_playing_alt, intensity_msgs_dark_alt, intensity_msgs_light_alt, intensity_delivered_alt_dark
else:
import sbapp.plyer as plyer
from sbapp.sideband.sense import Telemeter, Commands
from .helpers import ts_format, file_ts_format, mdc
from .helpers import color_playing, color_received, color_delivered, color_propagated, color_paper, color_failed, color_unknown, intensity_msgs_dark, intensity_msgs_light, intensity_play_dark, intensity_play_light
from .helpers import color_received_alt, color_received_alt_light, color_delivered_alt, color_propagated_alt, color_paper_alt, color_failed_alt, color_unknown_alt, color_playing_alt, intensity_msgs_dark_alt, intensity_msgs_light_alt, intensity_delivered_alt_dark
if RNS.vendor.platformutils.is_darwin():
from PIL import Image as PilImage
@ -205,23 +203,6 @@ class Messages():
self.ids.message_text.input_type = "text"
self.ids.message_text.keyboard_suggestions = True
if not self.app.sideband.config["classic_message_colors"]:
c_delivered = color_delivered_alt
c_received = color_received_alt
c_propagated = color_propagated_alt
c_playing = color_playing_alt
c_paper = color_paper_alt
c_unknown = color_unknown_alt
c_failed = color_failed_alt
else:
c_delivered = color_delivered
c_received = color_received
c_propagated = color_propagated
c_playing = color_playing
c_paper = color_paper
c_unknown = color_unknown
c_failed = color_failed
for new_message in self.app.sideband.list_messages(self.context_dest, after=self.latest_message_timestamp,limit=limit):
self.new_messages.append(new_message)
@ -260,24 +241,12 @@ class Messages():
if (len(self.added_item_hashes) < self.db_message_count) and not self.load_more_button in self.list.children:
self.list.add_widget(self.load_more_button, len(self.list.children))
if self.app.sideband.config["classic_message_colors"]:
if self.app.sideband.config["dark_ui"]:
intensity_msgs = intensity_msgs_dark
intensity_play = intensity_play_dark
intensity_delivered = intensity_msgs
else:
intensity_msgs = intensity_msgs_light
intensity_play = intensity_play_light
intensity_delivered = intensity_msgs
if self.app.sideband.config["dark_ui"]:
intensity_msgs = intensity_msgs_dark
intensity_play = intensity_play_dark
else:
if self.app.sideband.config["dark_ui"]:
intensity_msgs = intensity_msgs_dark_alt
intensity_play = intensity_play_dark
intensity_delivered = intensity_delivered_alt_dark
else:
intensity_msgs = intensity_msgs_light_alt
intensity_play = intensity_play_light
intensity_delivered = intensity_msgs
intensity_msgs = intensity_msgs_light
intensity_play = intensity_play_light
for w in self.widgets:
m = w.m
@ -302,7 +271,7 @@ class Messages():
delivery_syms = multilingual_markup(delivery_syms.encode("utf-8")).decode("utf-8")
if msg["state"] == LXMF.LXMessage.OUTBOUND or msg["state"] == LXMF.LXMessage.SENDING or msg["state"] == LXMF.LXMessage.SENT:
w.md_bg_color = msg_color = mdc(c_unknown, intensity_msgs)
w.md_bg_color = msg_color = mdc(color_unknown, intensity_msgs)
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
prgstr = ""
@ -336,7 +305,7 @@ class Messages():
if msg["state"] == LXMF.LXMessage.DELIVERED:
w.md_bg_color = msg_color = mdc(c_delivered, intensity_delivered)
w.md_bg_color = msg_color = mdc(color_delivered, intensity_msgs)
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
@ -348,7 +317,7 @@ class Messages():
m["state"] = msg["state"]
if msg["method"] == LXMF.LXMessage.PAPER:
w.md_bg_color = msg_color = mdc(c_paper, intensity_msgs)
w.md_bg_color = msg_color = mdc(color_paper, intensity_msgs)
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
@ -357,7 +326,7 @@ class Messages():
m["state"] = msg["state"]
if msg["method"] == LXMF.LXMessage.PROPAGATED and msg["state"] == LXMF.LXMessage.SENT:
w.md_bg_color = msg_color = mdc(c_propagated, intensity_msgs)
w.md_bg_color = msg_color = mdc(color_propagated, intensity_msgs)
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
@ -369,7 +338,7 @@ class Messages():
m["state"] = msg["state"]
if msg["state"] == LXMF.LXMessage.FAILED:
w.md_bg_color = msg_color = mdc(c_failed, intensity_msgs)
w.md_bg_color = msg_color = mdc(color_failed, intensity_msgs)
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
@ -392,49 +361,14 @@ class Messages():
wid.height, wid.size_hint_y, wid.opacity, wid.disabled = 0, None, 0, True
def update_widget(self):
if self.app.sideband.config["classic_message_colors"]:
if self.app.sideband.config["dark_ui"]:
intensity_msgs = intensity_msgs_dark
intensity_play = intensity_play_dark
intensity_delivered = intensity_msgs
mt_color = [1.0, 1.0, 1.0, 0.8]
else:
intensity_msgs = intensity_msgs_light
intensity_play = intensity_play_light
intensity_delivered = intensity_msgs
mt_color = [1.0, 1.0, 1.0, 0.95]
if self.app.sideband.config["dark_ui"]:
intensity_msgs = intensity_msgs_dark
intensity_play = intensity_play_dark
mt_color = [1.0, 1.0, 1.0, 0.8]
else:
if self.app.sideband.config["dark_ui"]:
intensity_msgs = intensity_msgs_dark_alt
intensity_play = intensity_play_dark
intensity_delivered = intensity_delivered_alt_dark
mt_color = [1.0, 1.0, 1.0, 0.8]
else:
intensity_msgs = intensity_msgs_light_alt
intensity_play = intensity_play_light
intensity_delivered = intensity_msgs
mt_color = [1.0, 1.0, 1.0, 0.95]
if not self.app.sideband.config["classic_message_colors"]:
if self.app.sideband.config["dark_ui"]:
c_received = color_received_alt
else:
c_received = color_received_alt_light
c_delivered = color_delivered_alt
c_propagated = color_propagated_alt
c_playing = color_playing_alt
c_paper = color_paper_alt
c_unknown = color_unknown_alt
c_failed = color_failed_alt
else:
c_delivered = color_delivered
c_received = color_received
c_propagated = color_propagated
c_playing = color_playing
c_paper = color_paper
c_unknown = color_unknown
c_failed = color_failed
intensity_msgs = intensity_msgs_light
intensity_play = intensity_play_light
mt_color = [1.0, 1.0, 1.0, 0.95]
self.ids.message_text.font_name = self.app.input_font
@ -444,7 +378,7 @@ class Messages():
for m in self.new_messages:
if not m["hash"] in self.added_item_hashes:
try:
if self.app.sideband.config["trusted_markup_only"] and not self.is_trusted:
if not self.is_trusted:
message_input = str( escape_markup(m["content"].decode("utf-8")) ).encode("utf-8")
else:
message_input = m["content"]
@ -590,31 +524,31 @@ class Messages():
if m["source"] == self.app.sideband.lxmf_destination.hash:
if m["state"] == LXMF.LXMessage.DELIVERED:
msg_color = mdc(c_delivered, intensity_delivered)
msg_color = mdc(color_delivered, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+delivery_syms+"\n[b]State[/b] Delivered"
elif m["method"] == LXMF.LXMessage.PROPAGATED and m["state"] == LXMF.LXMessage.SENT:
msg_color = mdc(c_propagated, intensity_msgs)
msg_color = mdc(color_propagated, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+delivery_syms+"\n[b]State[/b] On Propagation Net"
elif m["method"] == LXMF.LXMessage.PAPER:
msg_color = mdc(c_paper, intensity_msgs)
msg_color = mdc(color_paper, intensity_msgs)
heading_str = titlestr+"[b]Created[/b] "+txstr+"\n[b]State[/b] Paper Message"
elif m["state"] == LXMF.LXMessage.FAILED:
msg_color = mdc(c_failed, intensity_msgs)
msg_color = mdc(color_failed, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Failed"
elif m["state"] == LXMF.LXMessage.OUTBOUND or m["state"] == LXMF.LXMessage.SENDING:
msg_color = mdc(c_unknown, intensity_msgs)
msg_color = mdc(color_unknown, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Sending "
else:
msg_color = mdc(c_unknown, intensity_msgs)
msg_color = mdc(color_unknown, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Unknown"
else:
msg_color = mdc(c_received, intensity_msgs)
msg_color = mdc(color_received, intensity_msgs)
heading_str = titlestr
if phy_stats_str != "" and self.app.sideband.config["advanced_stats"]:
heading_str += phy_stats_str+"\n"
@ -664,9 +598,9 @@ class Messages():
self.app.play_audio_field(sender.audio_field)
stored_color = sender.md_bg_color
if sender.lsource == self.app.sideband.lxmf_destination.hash:
sender.md_bg_color = mdc(c_delivered, intensity_play)
sender.md_bg_color = mdc(color_delivered, intensity_play)
else:
sender.md_bg_color = mdc(c_received, intensity_play)
sender.md_bg_color = mdc(color_received, intensity_play)
def cb(dt):
sender.md_bg_color = stored_color
@ -719,19 +653,6 @@ class Messages():
item.ids.content_text.owner = item
item.ids.content_text.bind(texture_size=check_textures)
def cbf(w):
def x(dt):
if w.texture_size[0] == 0 and w.texture_size[1] == 0:
w.markup = False
escaped_content = escape_markup(w.text)
def deferred(dt):
w.text = "[i]This message could not be rendered correctly, likely due to an error in its markup. Falling back to plain-text rendering.[/i]\n\n"+escaped_content
w.markup = True
Clock.schedule_once(deferred, 0.1)
return x
Clock.schedule_once(cbf(item.ids.content_text), 0.25)
if not RNS.vendor.platformutils.is_android():
item.radius = dp(5)

View File

@ -148,15 +148,6 @@ class ObjectDetails():
else:
self.from_objects = False
if self.viewing_self:
self.screen.ids.track_button.disabled = True
else:
self.screen.ids.track_button.disabled = False
if self.app.sideband.is_tracking(source_dest):
self.screen.ids.track_button.text = "Stop Live Tracking"
else:
self.screen.ids.track_button.text = "Start Live Tracking"
self.coords = None
self.telemetry_list.data = []
pds = multilingual_markup(escape_markup(str(self.app.sideband.peer_display_name(source_dest))).encode("utf-8")).decode("utf-8")
@ -227,15 +218,6 @@ class ObjectDetails():
self.clear_widget()
self.update()
def live_tracking(self, sender):
if not self.viewing_self:
if not self.app.sideband.is_tracking(self.object_hash):
self.app.sideband.start_tracking(self.object_hash, interval=59, duration=7*24*60*60)
self.screen.ids.track_button.text = "Stop Live Tracking"
else:
self.app.sideband.stop_tracking(self.object_hash)
self.screen.ids.track_button.text = "Start Live Tracking"
def send_update(self):
if not self.viewing_self:
result = self.app.sideband.send_latest_telemetry(to_addr=self.object_hash)
@ -661,9 +643,10 @@ class RVDetails(MDRecycleView):
alt_str = RNS.prettydistance(alt)
formatted_values = f"Coordinates [b]{fcoords}[/b], altitude [b]{alt_str}[/b]"
if speed != None:
if speed > 0.1:
if speed > 0.02:
speed_formatted_values = f"Speed [b]{speed} Km/h[/b], heading [b]{heading}°[/b]"
else:
# speed_formatted_values = f"Speed [b]0 Km/h[/b]"
speed_formatted_values = f"Object is [b]stationary[/b]"
else:
speed_formatted_values = None
@ -989,22 +972,22 @@ MDScreen:
on_release: root.delegate.request_update()
disabled: False
MDBoxLayout:
orientation: "horizontal"
spacing: dp(16)
size_hint_y: None
height: self.minimum_height
padding: [dp(24), dp(0), dp(24), dp(24)]
# MDBoxLayout:
# orientation: "horizontal"
# spacing: dp(16)
# size_hint_y: None
# height: self.minimum_height
# padding: [dp(24), dp(16), dp(24), dp(24)]
MDRectangleFlatIconButton:
id: track_button
icon: "crosshairs-gps"
text: "Start Live Tracking"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.live_tracking(self)
disabled: False
# MDRectangleFlatIconButton:
# id: delete_button
# icon: "trash-can-outline"
# text: "Delete All Telemetry"
# padding: [dp(0), dp(14), dp(0), dp(14)]
# icon_size: dp(24)
# font_size: dp(16)
# size_hint: [1.0, None]
# on_release: root.delegate.copy_telemetry(self)
# disabled: False
"""

View File

@ -1,441 +0,0 @@
import time
import RNS
from typing import Union
from kivy.metrics import dp,sp
from kivy.lang.builder import Builder
from kivy.core.clipboard import Clipboard
from kivy.utils import escape_markup
from kivymd.uix.recycleview import MDRecycleView
from kivymd.uix.list import OneLineIconListItem
from kivymd.uix.pickers import MDColorPicker
from kivymd.uix.button import MDRectangleFlatButton
from kivymd.uix.dialog import MDDialog
from kivymd.icon_definitions import md_icons
from kivymd.toast import toast
from kivy.properties import StringProperty, BooleanProperty
from kivy.effects.scroll import ScrollEffect
from kivy.clock import Clock
from sideband.sense import Telemeter
import threading
from datetime import datetime
if RNS.vendor.platformutils.get_platform() == "android":
from ui.helpers import ts_format
from android.permissions import request_permissions, check_permission
else:
from .helpers import ts_format
class Utilities():
def __init__(self, app):
self.app = app
self.screen = None
self.rnstatus_screen = None
self.rnstatus_instance = None
self.logviewer_screen = None
if not self.app.root.ids.screen_manager.has_screen("utilities_screen"):
self.screen = Builder.load_string(layout_utilities_screen)
self.screen.app = self.app
self.screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.screen)
self.screen.ids.telemetry_scrollview.effect_cls = ScrollEffect
info = "This section contains various utilities and diagnostics tools, "
info += "that can be helpful while using Sideband and Reticulum."
if self.app.theme_cls.theme_style == "Dark":
info = "[color=#"+self.app.dark_theme_text_color+"]"+info+"[/color]"
self.screen.ids.utilities_info.text = info
### RNode Flasher
######################################
def flasher_action(self, sender=None):
yes_button = MDRectangleFlatButton(text="Launch",font_size=dp(18), theme_text_color="Custom", line_color=self.app.color_accept, text_color=self.app.color_accept)
no_button = MDRectangleFlatButton(text="Back",font_size=dp(18))
dialog = MDDialog(
title="RNode Flasher",
text="You can use the included web-based RNode flasher, by starting Sideband's built-in repository server, and accessing the RNode Flasher page.",
buttons=[ no_button, yes_button ],
# elevation=0,
)
def dl_yes(s):
dialog.dismiss()
self.app.sideband.start_webshare()
def cb(dt):
self.app.repository_action()
Clock.schedule_once(cb, 0.6)
def dl_no(s):
dialog.dismiss()
yes_button.bind(on_release=dl_yes)
no_button.bind(on_release=dl_no)
dialog.open()
### rnstatus screen
######################################
def rnstatus_action(self, sender=None):
if not self.app.root.ids.screen_manager.has_screen("rnstatus_screen"):
self.rnstatus_screen = Builder.load_string(layout_rnstatus_screen)
self.rnstatus_screen.app = self.app
self.rnstatus_screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.rnstatus_screen)
self.app.root.ids.screen_manager.transition.direction = "left"
self.app.root.ids.screen_manager.current = "rnstatus_screen"
self.app.sideband.setstate("app.displaying", self.app.root.ids.screen_manager.current)
self.update_rnstatus()
def update_rnstatus(self, sender=None):
threading.Thread(target=self.update_rnstatus_job, daemon=True).start()
def update_rnstatus_job(self, sender=None):
if self.rnstatus_instance == None:
import RNS.Utilities.rnstatus as rnstatus
self.rnstatus_instance = rnstatus
import io
from contextlib import redirect_stdout
output = "None"
with io.StringIO() as buffer, redirect_stdout(buffer):
with RNS.logging_lock:
self.rnstatus_instance.main(rns_instance=RNS.Reticulum.get_instance())
output = buffer.getvalue()
def cb(dt):
self.rnstatus_screen.ids.rnstatus_output.text = f"[font=RobotoMono-Regular][size={int(dp(12))}]{output}[/size][/font]"
Clock.schedule_once(cb, 0.2)
if self.app.root.ids.screen_manager.current == "rnstatus_screen":
Clock.schedule_once(self.update_rnstatus, 1)
### Advanced Configuration screen
######################################
def advanced_action(self, sender=None):
if not self.app.root.ids.screen_manager.has_screen("advanced_screen"):
self.advanced_screen = Builder.load_string(layout_advanced_screen)
self.advanced_screen.app = self.app
self.advanced_screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.advanced_screen)
self.app.root.ids.screen_manager.transition.direction = "left"
self.app.root.ids.screen_manager.current = "advanced_screen"
self.app.sideband.setstate("app.displaying", self.app.root.ids.screen_manager.current)
self.update_advanced()
def update_advanced(self, sender=None):
if RNS.vendor.platformutils.is_android():
ct = self.app.sideband.config["config_template"]
self.advanced_screen.ids.config_template.text = f"[font=RobotoMono-Regular][size={int(dp(12))}]{ct}[/size][/font]"
else:
self.advanced_screen.ids.config_template.text = f"[font=RobotoMono-Regular][size={int(dp(12))}]On this platform, Reticulum configuration is managed by the system. You can change the configuration by editing the file located at:\n\n{self.app.sideband.reticulum.configpath}[/size][/font]"
def copy_config(self, sender=None):
if RNS.vendor.platformutils.is_android():
Clipboard.copy(self.app.sideband.config_template)
def paste_config(self, sender=None):
if RNS.vendor.platformutils.is_android():
self.app.sideband.config_template = Clipboard.paste()
self.app.sideband.config["config_template"] = self.app.sideband.config_template
self.app.sideband.save_configuration()
self.update_advanced()
### Log viewer screen
######################################
def logviewer_action(self, sender=None):
if not self.app.root.ids.screen_manager.has_screen("logviewer_screen"):
self.logviewer_screen = Builder.load_string(layout_logviewer_screen)
self.logviewer_screen.app = self.app
self.logviewer_screen.delegate = self
self.app.root.ids.screen_manager.add_widget(self.logviewer_screen)
self.app.root.ids.screen_manager.transition.direction = "left"
self.app.root.ids.screen_manager.current = "logviewer_screen"
self.app.sideband.setstate("app.displaying", self.app.root.ids.screen_manager.current)
self.update_logviewer()
def update_logviewer(self, sender=None):
threading.Thread(target=self.update_logviewer_job, daemon=True).start()
def update_logviewer_job(self, sender=None):
try:
output = self.app.sideband.get_log()
except Exception as e:
output = f"An error occurred while retrieving log entries:\n{e}"
self.logviewer_screen.log_contents = output
def cb(dt):
self.logviewer_screen.ids.logviewer_output.text = f"[font=RobotoMono-Regular][size={int(dp(12))}]{output}[/size][/font]"
Clock.schedule_once(cb, 0.2)
if self.app.root.ids.screen_manager.current == "logviewer_screen":
Clock.schedule_once(self.update_logviewer, 1)
def logviewer_copy(self, sender=None):
Clipboard.copy(self.logviewer_screen.log_contents)
if True or RNS.vendor.platformutils.is_android():
toast("Log copied to clipboard")
layout_utilities_screen = """
MDScreen:
name: "utilities_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
title: "Utilities"
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
right_action_items:
[
['close', lambda x: root.app.close_any_action(self)],
]
ScrollView:
id: telemetry_scrollview
MDBoxLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
padding: [dp(28), dp(32), dp(28), dp(16)]
# MDLabel:
# text: "Utilities & Tools"
# font_style: "H6"
MDLabel:
id: utilities_info
markup: True
text: ""
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
MDBoxLayout:
orientation: "vertical"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(35), dp(0), dp(35)]
MDRectangleFlatIconButton:
id: rnstatus_button
icon: "wifi-check"
text: "Reticulum Status"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.rnstatus_action(self)
disabled: False
MDRectangleFlatIconButton:
id: logview_button
icon: "list-box-outline"
text: "Log Viewer"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.logviewer_action(self)
disabled: False
MDRectangleFlatIconButton:
id: flasher_button
icon: "radio-handheld"
text: "RNode Flasher"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.flasher_action(self)
disabled: False
MDRectangleFlatIconButton:
id: advanced_button
icon: "network-pos"
text: "Advanced RNS Configuration"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.advanced_action(self)
disabled: False
"""
layout_rnstatus_screen = """
MDScreen:
name: "rnstatus_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
id: top_bar
title: "Reticulum Status"
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
right_action_items:
[
# ['refresh', lambda x: root.delegate.update_rnstatus()],
['close', lambda x: root.app.close_sub_utilities_action(self)],
]
MDScrollView:
id: rnstatus_scrollview
size_hint_x: 1
size_hint_y: None
size: [root.width, root.height-root.ids.top_bar.height]
do_scroll_x: False
do_scroll_y: True
MDGridLayout:
cols: 1
padding: [dp(28), dp(14), dp(28), dp(28)]
size_hint_y: None
height: self.minimum_height
MDLabel:
id: rnstatus_output
markup: True
text: ""
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
"""
layout_logviewer_screen = """
MDScreen:
name: "logviewer_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
id: top_bar
title: "Log Viewer"
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
right_action_items:
[
['content-copy', lambda x: root.delegate.logviewer_copy()],
['close', lambda x: root.app.close_sub_utilities_action(self)],
]
MDScrollView:
id: logviewer_scrollview
size_hint_x: 1
size_hint_y: None
size: [root.width, root.height-root.ids.top_bar.height]
do_scroll_x: False
do_scroll_y: True
MDGridLayout:
cols: 1
padding: [dp(28), dp(14), dp(28), dp(28)]
size_hint_y: None
height: self.minimum_height
MDLabel:
id: logviewer_output
markup: True
text: ""
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
"""
layout_advanced_screen = """
MDScreen:
name: "advanced_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
id: top_bar
title: "RNS Configuration"
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
right_action_items:
[
# ['refresh', lambda x: root.delegate.update_rnstatus()],
['close', lambda x: root.app.close_sub_utilities_action(self)],
]
MDScrollView:
id: advanced_scrollview
size_hint_x: 1
size_hint_y: None
size: [root.width, root.height-root.ids.top_bar.height]
do_scroll_x: False
do_scroll_y: True
MDGridLayout:
cols: 1
padding: [dp(28), dp(14), dp(28), dp(28)]
size_hint_y: None
height: self.minimum_height
MDBoxLayout:
orientation: "horizontal"
spacing: dp(24)
size_hint_y: None
height: self.minimum_height
padding: [dp(0), dp(14), dp(0), dp(24)]
MDRectangleFlatIconButton:
id: telemetry_button
icon: "content-copy"
text: "Copy Configuration"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.copy_config(self)
disabled: False
MDRectangleFlatIconButton:
id: coordinates_button
icon: "download"
text: "Paste Configuration"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.delegate.paste_config(self)
disabled: False
MDLabel:
id: config_template
markup: True
text: ""
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
"""

View File

@ -47,20 +47,6 @@ def glob_paths(pattern):
return out_files
def glob_share():
out_files = []
src_path = os.path.join(os.path.dirname(__file__), "sbapp/share")
print(src_path)
for root, dirs, files in os.walk(src_path):
for file in files:
filepath = os.path.join(str(Path(*Path(root).parts[1:])), file)
if not "mirrors/unsigned.io" in str(filepath):
out_files.append(filepath.split(f"sbapp{os.sep}")[1])
return out_files
packages = setuptools.find_packages(
exclude=[
"sbapp.plyer.platforms.android",
@ -77,7 +63,6 @@ package_data = {
"kivymd/images/*",
"kivymd/*",
"mapview/icons/*",
*glob_share(),
*glob_paths(".kv")
]
}
@ -114,8 +99,8 @@ setuptools.setup(
]
},
install_requires=[
"rns>=0.8.8",
"lxmf>=0.5.8",
"rns>=0.8.4",
"lxmf>=0.5.7",
"kivy>=2.3.0",
"pillow>=10.2.0",
"qrcode",
@ -123,10 +108,11 @@ setuptools.setup(
"ffpyplayer",
"sh",
"numpy<=1.26.4",
"pycodec2;sys.platform!='Windows' and sys.platform!='win32' and sys.platform!='darwin'",
"pycodec2;platform_system!='Windows'",
"pyaudio;sys.platform=='linux'",
"pyobjus;sys.platform=='darwin'",
"pyogg;sys.platform=='Windows' and sys.platform!='win32'",
"pyogg;sys.platform=='darwin'",
"pyogg;platform_system=='Windows'",
],
python_requires='>=3.7',
)

View File

@ -1,68 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
from kivy_deps import sdl2, glew
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
def extra_datas(mydir):
def rec_glob(p, files):
import os
import glob
for d in glob.glob(p):
if os.path.isfile(d):
files.append(d)
rec_glob("%s/*" % d, files)
files = []
rec_glob("%s/*" % mydir, files)
extra_datas = []
for f in files:
extra_datas.append((f, f, 'DATA'))
return extra_datas
a.datas += extra_datas('sbapp')
a.datas += extra_datas('RNS')
a.datas += extra_datas('LXMF')
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='Sideband',
icon="sbapp\\assets\\icon.png",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
upx_exclude=[],
name='main',
)