mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Improved LXMF sync feedback
This commit is contained in:
parent
e59e087475
commit
11439dcabd
@ -648,10 +648,16 @@ class SidebandApp(MDApp):
|
|||||||
self.conversations_view.update()
|
self.conversations_view.update()
|
||||||
|
|
||||||
if self.sideband.getstate("app.flags.lxmf_sync_dialog_open", allow_cache=True) and self.sync_dialog != None:
|
if self.sideband.getstate("app.flags.lxmf_sync_dialog_open", allow_cache=True) and self.sync_dialog != None:
|
||||||
self.sync_dialog.ids.sync_progress.value = self.sideband.get_sync_progress()*100
|
|
||||||
self.sync_dialog.ids.sync_status.text = self.sideband.get_sync_status()
|
|
||||||
|
|
||||||
state = self.sideband.message_router.propagation_transfer_state
|
state = self.sideband.message_router.propagation_transfer_state
|
||||||
|
|
||||||
|
dlg_sp = self.sideband.get_sync_progress()*100; dlg_ss = self.sideband.get_sync_status()
|
||||||
|
if state > LXMF.LXMRouter.PR_IDLE and state <= LXMF.LXMRouter.PR_COMPLETE:
|
||||||
|
self.sync_dialog.ids.sync_progress.value = dlg_sp
|
||||||
|
else:
|
||||||
|
self.sync_dialog.ids.sync_progress.value = 0.1
|
||||||
|
|
||||||
|
self.sync_dialog.ids.sync_status.text = dlg_ss
|
||||||
|
|
||||||
if state > LXMF.LXMRouter.PR_IDLE and state < LXMF.LXMRouter.PR_COMPLETE:
|
if state > LXMF.LXMRouter.PR_IDLE and state < LXMF.LXMRouter.PR_COMPLETE:
|
||||||
self.widget_hide(self.sync_dialog.stop_button, False)
|
self.widget_hide(self.sync_dialog.stop_button, False)
|
||||||
else:
|
else:
|
||||||
@ -797,6 +803,9 @@ class SidebandApp(MDApp):
|
|||||||
self.telemetry_action(self)
|
self.telemetry_action(self)
|
||||||
|
|
||||||
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "r"):
|
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "r"):
|
||||||
|
if self.root.ids.screen_manager.current == "conversations_screen":
|
||||||
|
self.lxmf_sync_action(self)
|
||||||
|
else:
|
||||||
self.conversations_action(self)
|
self.conversations_action(self)
|
||||||
|
|
||||||
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "g"):
|
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "g"):
|
||||||
@ -1112,9 +1121,9 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
if self.sideband.reticulum.is_connected_to_shared_instance:
|
if self.sideband.reticulum.is_connected_to_shared_instance:
|
||||||
connectivity_status = "Sideband is connected via a shared Reticulum instance running on this system. Use the rnstatus utility to obtain full connectivity info."
|
connectivity_status = "Sideband is connected via a shared Reticulum instance running on this system. Use the [b]rnstatus[/b] utility to obtain full connectivity info."
|
||||||
else:
|
else:
|
||||||
connectivity_status = "Sideband is currently running a standalone or master Reticulum instance on this system. Use the rnstatus utility to obtain full connectivity info."
|
connectivity_status = "Sideband is currently running a standalone or master Reticulum instance on this system. Use the [b]rnstatus[/b] utility to obtain full connectivity info."
|
||||||
|
|
||||||
return connectivity_status
|
return connectivity_status
|
||||||
|
|
||||||
@ -1216,12 +1225,10 @@ class SidebandApp(MDApp):
|
|||||||
else:
|
else:
|
||||||
sl = None
|
sl = None
|
||||||
|
|
||||||
self.sideband.setpersistent("lxmf.lastsync", time.time())
|
if not hasattr(self, "message_sync_dialog") or self.message_sync_dialog == None:
|
||||||
self.sideband.setpersistent("lxmf.syncretrying", False)
|
|
||||||
self.sideband.request_lxmf_sync(limit=sl)
|
|
||||||
|
|
||||||
close_button = MDRectangleFlatButton(text="Close",font_size=dp(18))
|
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)
|
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_content = MsgSync()
|
||||||
dialog = MDDialog(
|
dialog = MDDialog(
|
||||||
title="LXMF Sync via "+RNS.prettyhexrep(self.sideband.message_router.get_outbound_propagation_node()),
|
title="LXMF Sync via "+RNS.prettyhexrep(self.sideband.message_router.get_outbound_propagation_node()),
|
||||||
@ -1234,6 +1241,9 @@ class SidebandApp(MDApp):
|
|||||||
def dl_close(s):
|
def dl_close(s):
|
||||||
self.sideband.setstate("app.flags.lxmf_sync_dialog_open", False)
|
self.sideband.setstate("app.flags.lxmf_sync_dialog_open", False)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
self.message_sync_dialog.d_content.ids.sync_progress.value = 0.1
|
||||||
|
self.message_sync_dialog.d_content.ids.sync_status.text = ""
|
||||||
|
|
||||||
# self.sideband.cancel_lxmf_sync()
|
# self.sideband.cancel_lxmf_sync()
|
||||||
|
|
||||||
def dl_stop(s):
|
def dl_stop(s):
|
||||||
@ -1246,12 +1256,30 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
close_button.bind(on_release=dl_close)
|
close_button.bind(on_release=dl_close)
|
||||||
stop_button.bind(on_release=dl_stop)
|
stop_button.bind(on_release=dl_stop)
|
||||||
self.sideband.setstate("app.flags.lxmf_sync_dialog_open", True)
|
|
||||||
|
self.message_sync_dialog = dialog
|
||||||
self.sync_dialog = dialog_content
|
self.sync_dialog = dialog_content
|
||||||
self.sync_dialog.stop_button = stop_button
|
self.sync_dialog.stop_button = stop_button
|
||||||
dialog.open()
|
|
||||||
dialog_content.ids.sync_progress.value = self.sideband.get_sync_progress()*100
|
s_state = self.sideband.message_router.propagation_transfer_state
|
||||||
dialog_content.ids.sync_status.text = self.sideband.get_sync_status()
|
if s_state > LXMF.LXMRouter.PR_PATH_REQUESTED and s_state <= LXMF.LXMRouter.PR_COMPLETE:
|
||||||
|
dsp = self.sideband.get_sync_progress()*100
|
||||||
|
else:
|
||||||
|
dsp = 0
|
||||||
|
|
||||||
|
self.sideband.setstate("app.flags.lxmf_sync_dialog_open", True)
|
||||||
|
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()
|
||||||
|
self.sync_dialog.ids.sync_progress.stop()
|
||||||
|
self.message_sync_dialog.open()
|
||||||
|
|
||||||
|
def sij(dt):
|
||||||
|
self.sideband.setpersistent("lxmf.lastsync", time.time())
|
||||||
|
self.sideband.setpersistent("lxmf.syncretrying", False)
|
||||||
|
self.sideband.request_lxmf_sync(limit=sl)
|
||||||
|
Clock.schedule_once(sij, 0.1)
|
||||||
|
|
||||||
def new_conversation_action(self, sender=None):
|
def new_conversation_action(self, sender=None):
|
||||||
def cb(dt):
|
def cb(dt):
|
||||||
@ -1837,12 +1865,12 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
if self.sideband.reticulum.is_connected_to_shared_instance:
|
if self.sideband.reticulum.is_connected_to_shared_instance:
|
||||||
info = "Sideband is connected via a shared Reticulum instance running on this system.\n\n"
|
info = "Sideband is connected via a shared Reticulum instance running on this system.\n\n"
|
||||||
info += "To get connectivity status, use the rnstatus utility.\n\n"
|
info += "To get connectivity status, use the [b]rnstatus[/b] utility.\n\n"
|
||||||
info += "To configure connectivity, edit the configuration file located at:\n\n"
|
info += "To configure connectivity, edit the configuration file located at:\n\n"
|
||||||
info += str(RNS.Reticulum.configpath)
|
info += str(RNS.Reticulum.configpath)
|
||||||
else:
|
else:
|
||||||
info = "Sideband is currently running a standalone or master Reticulum instance on this system.\n\n"
|
info = "Sideband is currently running a standalone or master Reticulum instance on this system.\n\n"
|
||||||
info += "To get connectivity status, use the rnstatus utility.\n\n"
|
info += "To get connectivity status, use the [b]rnstatus[/b] utility.\n\n"
|
||||||
info += "To configure connectivity, edit the configuration file located at:\n\n"
|
info += "To configure connectivity, edit the configuration file located at:\n\n"
|
||||||
info += str(RNS.Reticulum.configpath)
|
info += str(RNS.Reticulum.configpath)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
__debug_build__ = False
|
__debug_build__ = True
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import RNS
|
import RNS
|
||||||
|
@ -648,6 +648,8 @@ class SidebandCore():
|
|||||||
|
|
||||||
def log_announce(self, dest, app_data, dest_type):
|
def log_announce(self, dest, app_data, dest_type):
|
||||||
try:
|
try:
|
||||||
|
if app_data == None:
|
||||||
|
app_data = b""
|
||||||
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+app_data.decode("utf-8"))
|
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+app_data.decode("utf-8"))
|
||||||
self._db_save_announce(dest, app_data, dest_type)
|
self._db_save_announce(dest, app_data, dest_type)
|
||||||
self.setstate("app.flags.new_announces", True)
|
self.setstate("app.flags.new_announces", True)
|
||||||
@ -2905,7 +2907,7 @@ class SidebandCore():
|
|||||||
threading.Thread(target=webshare_job, daemon=True).start()
|
threading.Thread(target=webshare_job, daemon=True).start()
|
||||||
|
|
||||||
def request_lxmf_sync(self, limit = None):
|
def request_lxmf_sync(self, limit = None):
|
||||||
if self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_IDLE or self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE:
|
if self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_IDLE or self.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
|
||||||
self.message_router.request_messages_from_propagation_node(self.identity, max_messages = limit)
|
self.message_router.request_messages_from_propagation_node(self.identity, max_messages = limit)
|
||||||
RNS.log("LXMF message sync requested from propagation node "+RNS.prettyhexrep(self.message_router.get_outbound_propagation_node())+" for "+str(self.identity))
|
RNS.log("LXMF message sync requested from propagation node "+RNS.prettyhexrep(self.message_router.get_outbound_propagation_node())+" for "+str(self.identity))
|
||||||
return True
|
return True
|
||||||
@ -2917,7 +2919,18 @@ class SidebandCore():
|
|||||||
self.message_router.cancel_propagation_node_requests()
|
self.message_router.cancel_propagation_node_requests()
|
||||||
|
|
||||||
def get_sync_progress(self):
|
def get_sync_progress(self):
|
||||||
return self.message_router.propagation_transfer_progress
|
state = self.message_router.propagation_transfer_state
|
||||||
|
if state == LXMF.LXMRouter.PR_PATH_REQUESTED:
|
||||||
|
state_val = 0.05
|
||||||
|
elif state == LXMF.LXMRouter.PR_LINK_ESTABLISHING:
|
||||||
|
state_val = 0.1
|
||||||
|
elif state == LXMF.LXMRouter.PR_LINK_ESTABLISHED:
|
||||||
|
state_val = 0.15
|
||||||
|
elif state >= LXMF.LXMRouter.PR_REQUEST_SENT:
|
||||||
|
state_val = 0.2
|
||||||
|
else:
|
||||||
|
state_val = 0.0
|
||||||
|
return (self.message_router.propagation_transfer_progress*0.8)+state_val
|
||||||
|
|
||||||
def lxmf_delivery(self, message):
|
def lxmf_delivery(self, message):
|
||||||
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
||||||
@ -2961,6 +2974,18 @@ class SidebandCore():
|
|||||||
return "Receiving messages"
|
return "Receiving messages"
|
||||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_RESPONSE_RECEIVED:
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_RESPONSE_RECEIVED:
|
||||||
return "Messages received"
|
return "Messages received"
|
||||||
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_PATH:
|
||||||
|
return "No path to propagation node"
|
||||||
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_LINK_FAILED:
|
||||||
|
return "Link establisment failed"
|
||||||
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_TRANSFER_FAILED:
|
||||||
|
return "Sync request failed"
|
||||||
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_IDENTITY_RCVD:
|
||||||
|
return "No identity received by remote"
|
||||||
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_ACCESS:
|
||||||
|
return "No access to specified node"
|
||||||
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_FAILED:
|
||||||
|
return "Sync failed"
|
||||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE:
|
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE:
|
||||||
new_msgs = self.message_router.propagation_transfer_last_result
|
new_msgs = self.message_router.propagation_transfer_last_result
|
||||||
if new_msgs == 0:
|
if new_msgs == 0:
|
||||||
|
@ -473,6 +473,7 @@ Builder.load_string("""
|
|||||||
|
|
||||||
MDProgressBar:
|
MDProgressBar:
|
||||||
id: sync_progress
|
id: sync_progress
|
||||||
|
type: "determinate"
|
||||||
value: 0
|
value: 0
|
||||||
|
|
||||||
MDLabel:
|
MDLabel:
|
||||||
|
Loading…
Reference in New Issue
Block a user