mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02:00
Added daemon mode
This commit is contained in:
parent
1e6b6298e5
commit
468d4145b7
@ -1,4 +1,4 @@
|
||||
__debug_build__ = False
|
||||
__debug_build__ = True
|
||||
__disable_shaders__ = False
|
||||
__version__ = "0.7.0"
|
||||
__variant__ = "beta"
|
||||
@ -7,6 +7,7 @@ import sys
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="Sideband LXMF Client")
|
||||
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="increase logging verbosity")
|
||||
parser.add_argument("-d", "--daemon", action='store_true', default=False, help="run as a daemon, without user interface")
|
||||
parser.add_argument("--version", action="version", version="sideband {version}".format(version=__version__))
|
||||
args = parser.parse_args()
|
||||
sys.argv = [sys.argv[0]]
|
||||
@ -16,11 +17,12 @@ import LXMF
|
||||
import time
|
||||
import os
|
||||
import pathlib
|
||||
import plyer
|
||||
import base64
|
||||
import threading
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
if not args.daemon:
|
||||
import plyer
|
||||
from kivy.logger import Logger, LOG_LEVELS
|
||||
|
||||
# Squelch excessive method signature logging
|
||||
@ -52,7 +54,27 @@ if RNS.vendor.platformutils.get_platform() != "android":
|
||||
local = os.path.dirname(__file__)
|
||||
sys.path.append(local)
|
||||
|
||||
if args.daemon:
|
||||
from .sideband.core import SidebandCore
|
||||
class DaemonElement():
|
||||
pass
|
||||
class DaemonApp():
|
||||
pass
|
||||
|
||||
MDApp = DaemonApp; OneLineIconListItem = DaemonElement; Window = DaemonElement; Clipboard = DaemonElement
|
||||
EventLoop = DaemonElement; Clock = DaemonElement; Builder = DaemonElement; ScrollEffect = DaemonElement;
|
||||
ScreenManager = DaemonElement; FadeTransition = DaemonElement; NoTransition = DaemonElement; OneLineIconListItem = DaemonElement;
|
||||
StringProperty = DaemonElement; BaseButton = DaemonElement; MDIconButton = DaemonElement; MDFileManager = DaemonElement;
|
||||
toast = DaemonElement; dp = DaemonElement; sp = DaemonElement; MDRectangleFlatButton = DaemonElement; MDDialog = DaemonElement;
|
||||
colors = DaemonElement; Telemeter = DaemonElement; CustomMapMarker = DaemonElement; MBTilesMapSource = DaemonElement;
|
||||
MapSource = DaemonElement; webbrowser = DaemonElement; Conversations = DaemonElement; MsgSync = DaemonElement;
|
||||
NewConv = DaemonElement; Telemetry = DaemonElement; ObjectDetails = DaemonElement; Announces = DaemonElement;
|
||||
Messages = DaemonElement; ts_format = DaemonElement; messages_screen_kv = DaemonElement; plyer = DaemonElement;
|
||||
ContentNavigationDrawer = DaemonElement; DrawerList = DaemonElement; IconListItem = DaemonElement;
|
||||
|
||||
else:
|
||||
from kivymd.app import MDApp
|
||||
app_superclass = MDApp
|
||||
from kivy.core.window import Window
|
||||
from kivy.core.clipboard import Clipboard
|
||||
from kivy.base import EventLoop
|
||||
@ -66,12 +88,15 @@ from kivy.properties import StringProperty
|
||||
from kivymd.uix.button import BaseButton, MDIconButton
|
||||
from kivymd.uix.filemanager import MDFileManager
|
||||
from kivymd.toast import toast
|
||||
from kivy.metrics import dp, sp
|
||||
from kivymd.uix.button import MDRectangleFlatButton
|
||||
from kivymd.uix.dialog import MDDialog
|
||||
from kivymd.color_definitions import colors
|
||||
from sideband.sense import Telemeter
|
||||
from mapview import CustomMapMarker
|
||||
from mapview.mbtsource import MBTilesMapSource
|
||||
from mapview.source import MapSource
|
||||
import webbrowser
|
||||
|
||||
import kivy.core.image
|
||||
kivy.core.image.Logger = redirect_log()
|
||||
|
||||
@ -109,11 +134,6 @@ else:
|
||||
from kivy.config import Config
|
||||
Config.set('input', 'mouse', 'mouse,disable_multitouch')
|
||||
|
||||
from kivy.metrics import dp, sp
|
||||
from kivymd.uix.button import MDRectangleFlatButton
|
||||
from kivymd.uix.dialog import MDDialog
|
||||
from kivymd.color_definitions import colors
|
||||
|
||||
dark_theme_text_color = "ddd"
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
@ -3841,6 +3861,7 @@ class CustomOneLineIconListItem(OneLineIconListItem):
|
||||
class MDMapIconButton(MDIconButton):
|
||||
pass
|
||||
|
||||
if not args.daemon:
|
||||
from kivy.base import ExceptionManager, ExceptionHandler
|
||||
class SidebandExceptionHandler(ExceptionHandler):
|
||||
def handle_exception(self, e):
|
||||
@ -3855,6 +3876,13 @@ class SidebandExceptionHandler(ExceptionHandler):
|
||||
return ExceptionManager.RAISE
|
||||
|
||||
def run():
|
||||
if args.daemon:
|
||||
RNS.log("Starting Sideband in daemon mode")
|
||||
sideband = SidebandCore(None, is_client=False, verbose=(args.verbose or __debug_build__))
|
||||
sideband.start()
|
||||
while True:
|
||||
time.sleep(5)
|
||||
else:
|
||||
ExceptionManager.add_handler(SidebandExceptionHandler())
|
||||
SidebandApp().run()
|
||||
|
||||
|
@ -519,6 +519,8 @@ class SidebandCore():
|
||||
self.config["telemetry_send_appearance"] = False
|
||||
if not "telemetry_display_trusted_only" in self.config:
|
||||
self.config["telemetry_display_trusted_only"] = False
|
||||
if not "telemetry_receive_trusted_only" in self.config:
|
||||
self.config["telemetry_receive_trusted_only"] = False
|
||||
|
||||
if not "telemetry_s_location" in self.config:
|
||||
self.config["telemetry_s_location"] = False
|
||||
@ -1824,6 +1826,7 @@ class SidebandCore():
|
||||
|
||||
packed_telemetry = None
|
||||
if not originator and lxm.fields != None:
|
||||
if self.config["telemetry_receive_trusted_only"] == False or (self.config["telemetry_receive_trusted_only"] == True and self.is_trusted(context_dest)):
|
||||
if LXMF.FIELD_ICON_APPEARANCE in lxm.fields:
|
||||
self._db_update_appearance(context_dest, lxm.timestamp, lxm.fields[LXMF.FIELD_ICON_APPEARANCE])
|
||||
|
||||
|
@ -989,11 +989,11 @@ MDScreen:
|
||||
[['menu', lambda x: root.app.nav_drawer.set_state("open")]]
|
||||
right_action_items:
|
||||
[
|
||||
# ['format-list-bulleted-type', lambda x: root.app.map_object_list(self)], # Object List
|
||||
# ['arrow-down-bold-hexagon-outline', lambda x: root.app.telemetry_request_action(self)], # Download telemetry
|
||||
# ['upload-lock', lambda x: root.app.telemetry_send_update(self)], # Send telemetry update
|
||||
['layers', lambda x: root.app.map_layers_action(self)],
|
||||
['format-list-bulleted-type', lambda x: root.app.map_object_list(self)], # Object List
|
||||
['arrow-down-bold-hexagon-outline', lambda x: root.app.telemetry_request_action(self)], # Download telemetry
|
||||
['upload-lock', lambda x: root.app.telemetry_send_update(self)], # Send telemetry update
|
||||
['wrench-cog', lambda x: root.app.map_settings_action(self)],
|
||||
['layers', lambda x: root.app.map_layers_action(self)],
|
||||
['close', lambda x: root.app.close_any_action(self)],
|
||||
]
|
||||
|
||||
|
@ -58,6 +58,9 @@ class Telemetry():
|
||||
self.screen.ids.telemetry_display_trusted_only.active = self.app.sideband.config["telemetry_display_trusted_only"]
|
||||
self.screen.ids.telemetry_display_trusted_only.bind(active=self.telemetry_save)
|
||||
|
||||
self.screen.ids.telemetry_receive_trusted_only.active = self.app.sideband.config["telemetry_receive_trusted_only"]
|
||||
self.screen.ids.telemetry_receive_trusted_only.bind(active=self.telemetry_save)
|
||||
|
||||
self.screen.ids.telemetry_send_appearance.active = self.app.sideband.config["telemetry_send_appearance"]
|
||||
self.screen.ids.telemetry_send_appearance.bind(active=self.telemetry_save)
|
||||
|
||||
@ -212,6 +215,7 @@ class Telemetry():
|
||||
self.app.sideband.config["telemetry_send_to_trusted"] = self.screen.ids.telemetry_send_to_trusted.active
|
||||
self.app.sideband.config["telemetry_display_trusted_only"] = self.screen.ids.telemetry_display_trusted_only.active
|
||||
self.app.sideband.config["telemetry_send_appearance"] = self.screen.ids.telemetry_send_appearance.active
|
||||
self.app.sideband.config["telemetry_receive_trusted_only"] = self.screen.ids.telemetry_receive_trusted_only.active
|
||||
|
||||
self.app.sideband.save_configuration()
|
||||
if run_telemetry_update:
|
||||
@ -545,6 +549,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: "Only receive from trusted"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_receive_trusted_only
|
||||
pos_hint: {"center_y": 0.3}
|
||||
active: False
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
|
Loading…
Reference in New Issue
Block a user