Compare commits

...

17 Commits
0.1.9 ... 0.2.0

Author SHA1 Message Date
Mark Qvist
d35e23c74f Updated version and dependencies 2022-07-05 00:08:21 +02:00
Mark Qvist
a83db96b22 Added printing to guide 2022-07-04 23:17:29 +02:00
Mark Qvist
6da537176b Added printing support 2022-07-04 23:03:50 +02:00
Mark Qvist
850f56cac3 Change storage limit specification to megabytes. Added storage stat to node info. 2022-07-04 20:05:17 +02:00
Mark Qvist
247db32033 Added LXMF link support 2022-07-04 19:25:17 +02:00
Mark Qvist
d8a35be14d Updated guide 2022-07-04 17:41:28 +02:00
Mark Qvist
d1c66aa7cd Fixed missing error handling in URL dialog 2022-07-04 17:37:13 +02:00
Mark Qvist
726ee8873e Added fullscreen mode to browser and conversations 2022-07-04 17:34:12 +02:00
Mark Qvist
3c7b8511d7 Updated frame sizing 2022-07-04 17:07:54 +02:00
Mark Qvist
f699c61a64 Improved missing keys description 2022-07-04 16:48:40 +02:00
Mark Qvist
1002a89ad5 Improved sync dialog text 2022-07-04 16:38:43 +02:00
Mark Qvist
87c810fdd0 Added save connected node functionality 2022-07-04 16:31:01 +02:00
Mark Qvist
4e50e0f076 Added keyboard shortcuts to guide 2022-07-04 16:30:40 +02:00
Mark Qvist
f75b4d0b57 Improved dialog navigation 2022-07-04 14:34:34 +02:00
Mark Qvist
27dc1b5fb5 Set and restore IXON tty settings 2022-07-04 12:48:24 +02:00
Mark Qvist
1b1558c769 Updated guide 2022-07-02 08:56:11 +02:00
Mark Qvist
681efb422d Prepared for 128-bit destinations 2022-06-30 13:51:46 +02:00
12 changed files with 585 additions and 111 deletions

View File

@@ -61,7 +61,7 @@ For a native Android application with a graphical user interface, have a look at
### Docker Images ### Docker Images
Nomad Network is automatically published as a docker image on Github Packages. Image tags are one of either `master` (for the very latest commit) or the version number (eg `0.1.8`) for a specific release. Nomad Network is automatically published as a docker image on Github Packages. Image tags are one of either `master` (for the very latest commit) or the version number (eg `0.2.0`) for a specific release.
```sh ```sh
$ docker pull ghcr.io/markqvist/nomadnet:master $ docker pull ghcr.io/markqvist/nomadnet:master

View File

@@ -239,10 +239,11 @@ class Conversation:
def __str__(self): def __str__(self):
string = self.source_hash string = self.source_hash
if self.source_identity: # TODO: Remove this
if self.source_identity.app_data: # if self.source_identity:
# TODO: Sanitise for viewing # if self.source_identity.app_data:
string += " | "+self.source.source_identity.app_data.decode("utf-8") # # TODO: Sanitise for viewing, or just clean this
# string += " | "+self.source_identity.app_data.decode("utf-8")
return string return string

View File

@@ -60,6 +60,7 @@ class Directory:
entries = {} entries = {}
for e in unpacked_list: for e in unpacked_list:
if len(e) > 3: if len(e) > 3:
hosts_node = e[3] hosts_node = e[3]
else: else:
@@ -132,7 +133,11 @@ class Directory:
return "<"+RNS.hexrep(source_hash, delimit=False)+">" return "<"+RNS.hexrep(source_hash, delimit=False)+">"
else: else:
if source_hash in self.directory_entries: if source_hash in self.directory_entries:
return self.directory_entries[source_hash].display_name dn = self.directory_entries[source_hash].display_name
if dn == None:
return RNS.prettyhexrep(source_hash)
else:
return dn
else: else:
return "<"+RNS.hexrep(source_hash, delimit=False)+">" return "<"+RNS.hexrep(source_hash, delimit=False)+">"
@@ -242,9 +247,12 @@ class DirectoryEntry:
def __init__(self, source_hash, display_name=None, trust_level=UNKNOWN, hosts_node=False, preferred_delivery=None, identify_on_connect=False): def __init__(self, source_hash, display_name=None, trust_level=UNKNOWN, hosts_node=False, preferred_delivery=None, identify_on_connect=False):
if len(source_hash) == RNS.Identity.TRUNCATED_HASHLENGTH//8: if len(source_hash) == RNS.Identity.TRUNCATED_HASHLENGTH//8:
self.source_hash = source_hash self.source_hash = source_hash
# TODO: Clean
# if display_name == None:
# display_name = source_hash
self.display_name = display_name self.display_name = display_name
if display_name == None:
display_name = source_hash
if preferred_delivery == None: if preferred_delivery == None:
self.preferred_delivery = DirectoryEntry.DIRECT self.preferred_delivery = DirectoryEntry.DIRECT

View File

@@ -2,9 +2,11 @@ import os
import io import io
import sys import sys
import time import time
import shlex
import atexit import atexit
import threading import threading
import traceback import traceback
import subprocess
import contextlib import contextlib
import RNS import RNS
@@ -12,6 +14,7 @@ import LXMF
import nomadnet import nomadnet
from nomadnet.Directory import DirectoryEntry from nomadnet.Directory import DirectoryEntry
from datetime import datetime
import RNS.vendor.umsgpack as msgpack import RNS.vendor.umsgpack as msgpack
@@ -32,6 +35,15 @@ class NomadNetworkApp:
RNS.log("Saving directory...", RNS.LOG_VERBOSE) RNS.log("Saving directory...", RNS.LOG_VERBOSE)
self.directory.save_to_disk() self.directory.save_to_disk()
if hasattr(self.ui, "restore_ixon"):
if self.ui.restore_ixon:
try:
os.system("stty ixon")
except Exception as e:
RNS.log("Could not restore flow control sequences. The contained exception was: "+str(e), RNS.LOG_WARNING)
RNS.log("Nomad Network Client exiting now", RNS.LOG_VERBOSE) RNS.log("Nomad Network Client exiting now", RNS.LOG_VERBOSE)
def exception_handler(self, e_type, e_value, e_traceback): def exception_handler(self, e_type, e_value, e_traceback):
@@ -254,7 +266,7 @@ class NomadNetworkApp:
RNS.log("LXMF Router ready to receive on: "+RNS.prettyhexrep(self.lxmf_destination.hash)) RNS.log("LXMF Router ready to receive on: "+RNS.prettyhexrep(self.lxmf_destination.hash))
if self.enable_node: if self.enable_node:
self.message_router.set_message_storage_limit(gigabytes=self.message_storage_limit) self.message_router.set_message_storage_limit(megabytes=self.message_storage_limit)
for dest_str in self.prioritised_lxmf_destinations: for dest_str in self.prioritised_lxmf_destinations:
try: try:
dest_hash = bytes.fromhex(dest_str) dest_hash = bytes.fromhex(dest_str)
@@ -471,6 +483,69 @@ class NomadNetworkApp:
nomadnet.Conversation.ingest(message, self) nomadnet.Conversation.ingest(message, self)
if self.should_print(message):
self.print_message(message)
def should_print(self, message):
if self.print_messages:
if self.print_all_messages:
return True
else:
source_hash_text = RNS.hexrep(message.source_hash, delimit=False)
if self.print_trusted_messages:
trust_level = self.directory.trust_level(message.source_hash)
if trust_level == DirectoryEntry.TRUSTED:
return True
if type(self.allowed_message_print_destinations) is list:
if source_hash_text in self.allowed_message_print_destinations:
return True
return False
def print_message(self, message, received = None):
try:
template = self.printing_template_msg
if received == None:
received = time.time()
g = self.ui.glyphs
m_rtime = datetime.fromtimestamp(message.timestamp)
stime = m_rtime.strftime(self.time_format)
message_time = datetime.fromtimestamp(received)
rtime = message_time.strftime(self.time_format)
display_name = self.directory.simplest_display_str(message.source_hash)
title = message.title_as_string()
if title == "":
title = "None"
output = template.format(
origin=display_name,
stime=stime,
rtime=rtime,
mtitle=title,
mbody=message.content_as_string(),
)
filename = "/tmp/"+RNS.hexrep(RNS.Identity.full_hash(output.encode("utf-8")), delimit=False)
with open(filename, "wb") as f:
f.write(output.encode("utf-8"))
f.close()
print_command = "lp -d thermal -o cpi=16 -o lpi=8 "+filename
return_code = subprocess.call(shlex.split(print_command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.unlink(filename)
except Exception as e:
RNS.log("Error while printing incoming LXMF message. The contained exception was: "+str(e))
def conversations(self): def conversations(self):
return nomadnet.Conversation.conversation_list(self) return nomadnet.Conversation.conversation_list(self)
@@ -670,13 +745,62 @@ class NomadNetworkApp:
self.prioritised_lxmf_destinations = [] self.prioritised_lxmf_destinations = []
if not "message_storage_limit" in self.config["node"]: if not "message_storage_limit" in self.config["node"]:
self.message_storage_limit = 2 self.message_storage_limit = 2000
else: else:
value = self.config["node"].as_float("message_storage_limit") value = self.config["node"].as_float("message_storage_limit")
if value < 0.064: if value < 0.005:
value = 0.064 value = 0.005
self.message_storage_limit = value self.message_storage_limit = value
self.print_command = "lp"
self.print_messages = False
self.print_all_messages = False
self.print_trusted_messages = False
if "printing" in self.config:
if not "print_messages" in self.config["printing"]:
self.print_messages = False
else:
self.print_messages = self.config["printing"].as_bool("print_messages")
if "print_command" in self.config["printing"]:
self.print_command = self.config["printing"]["print_command"]
if self.print_messages:
if not "print_from" in self.config["printing"]:
self.allowed_message_print_destinations = None
else:
if type(self.config["printing"]["print_from"]) == str:
self.allowed_message_print_destinations = []
if self.config["printing"]["print_from"].lower() == "everywhere":
self.print_all_messages = True
if self.config["printing"]["print_from"].lower() == "trusted":
self.print_all_messages = False
self.print_trusted_messages = True
if len(self.config["printing"]["print_from"]) == (RNS.Identity.TRUNCATED_HASHLENGTH//8)*2:
self.allowed_message_print_destinations.append(self.config["printing"]["print_from"])
if type(self.config["printing"]["print_from"]) == list:
self.allowed_message_print_destinations = self.config["printing"].as_list("print_from")
for allowed_entry in self.allowed_message_print_destinations:
if allowed_entry.lower() == "trusted":
self.print_trusted_messages = True
if not "message_template" in self.config["printing"]:
self.printing_template_msg = __printing_template_msg__
else:
mt_path = os.path.expanduser(self.config["printing"]["message_template"])
if os.path.isfile(mt_path):
template_file = open(mt_path, "rb")
self.printing_template_msg = template_file.read().decode("utf-8")
else:
template_file = open(mt_path, "wb")
template_file.write(__printing_template_msg__.encode("utf-8"))
self.printing_template_msg = __printing_template_msg__
@staticmethod @staticmethod
def get_shared_instance(): def get_shared_instance():
@@ -808,14 +932,14 @@ announce_at_start = Yes
# The maximum amount of storage to use for # The maximum amount of storage to use for
# the LXMF Propagation Node message store, # the LXMF Propagation Node message store,
# specified in gigabytes. When this limit # specified in megabytes. When this limit
# is reached, LXMF will periodically remove # is reached, LXMF will periodically remove
# messages in its message store. By default, # messages in its message store. By default,
# LXMF prioritises keeping messages that are # LXMF prioritises keeping messages that are
# new and small. Large and old messages will # new and small. Large and old messages will
# be removed first. This setting is optional # be removed first. This setting is optional
# and defaults to 2 gigabytes. # and defaults to 2 gigabytes.
# message_storage_limit = 2 # message_storage_limit = 2000
# You can tell the LXMF message router to # You can tell the LXMF message router to
# prioritise storage for one or more # prioritise storage for one or more
@@ -824,6 +948,62 @@ announce_at_start = Yes
# keeping messages for destinations specified # keeping messages for destinations specified
# with this option. This setting is optional, # with this option. This setting is optional,
# and generally you do not need to use it. # and generally you do not need to use it.
# prioritise_destinations = 10bc7624c27032a18639, ba780a6dff4cc1391db8 # prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf
[printing]
# You can configure Nomad Network to print
# various kinds of information and messages.
# Printing messages is disabled by default
print_messages = No
# You can configure a custom template for
# message printing. If you uncomment this
# option, set a path to the template and
# restart Nomad Network, a default template
# will be created that you can edit.
# message_template = ~/.nomadnetwork/print_template_msg.txt
# You can configure Nomad Network to only
# print messages from trusted destinations.
# print_from = trusted
# Or specify the source LXMF addresses that
# will automatically have messages printed
# on arrival.
# print_from = 76fe5751a56067d1e84eef3e88eab85b, 0e70b5848eb57c13154154feaeeb89b7
# Or allow printing from anywhere, if you
# are feeling brave and adventurous.
# print_from = everywhere
# You can configure the printing command.
# This will use the default CUPS printer on
# your system.
print_command = lp
# You can specify what printer to use
# print_command = lp -d PRINTER_NAME
# Or specify more advanced options. This
# example works well for small thermal-
# roll printers.
# print_command = lp -d PRINTER_NAME -o cpi=16 -o lpi=8
# This one is more suitable for full-sheet
# printers.
# print_command = lp -d PRINTER_NAME -o page-left=36 -o page-top=36 -o page-right=36 -o page-bottom=36
'''.splitlines() '''.splitlines()
__printing_template_msg__ = """
---------------------------
From: {origin}
Sent: {stime}
Rcvd: {rtime}
Title: {mtitle}
{mbody}
---------------------------
"""

View File

@@ -1 +1 @@
__version__ = "0.1.9" __version__ = "0.2.0"

View File

@@ -127,6 +127,21 @@ GLYPHS = {
class TextUI: class TextUI:
def __init__(self): def __init__(self):
self.restore_ixon = False
try:
rval = os.system("stty -a | grep \"\\-ixon\"")
if rval == 0:
pass
else:
os.system("stty -ixon")
self.restore_ixon = True
except Exception as e:
RNS.log("Could not configure terminal flow control sequences, some keybindings may not work.", RNS.LOG_WARNING)
RNS.log("The contained exception was: "+str(e))
self.app = NomadNetworkApp.get_shared_instance() self.app = NomadNetworkApp.get_shared_instance()
self.app.ui = self self.app.ui = self
self.loop = None self.loop = None
@@ -164,7 +179,7 @@ class TextUI:
else: else:
initial_widget = self.main_display.widget initial_widget = self.main_display.widget
self.loop = urwid.MainLoop(initial_widget, screen=self.screen, handle_mouse=mouse_enabled) self.loop = urwid.MainLoop(initial_widget, unhandled_input=self.unhandled_input, screen=self.screen, handle_mouse=mouse_enabled)
if intro_timeout > 0: if intro_timeout > 0:
self.loop.set_alarm_in(intro_timeout, self.display_main) self.loop.set_alarm_in(intro_timeout, self.display_main)
@@ -194,5 +209,9 @@ class TextUI:
self.screen.set_terminal_properties(colormode) self.screen.set_terminal_properties(colormode)
self.screen.reset_default_terminal_palette() self.screen.reset_default_terminal_palette()
def unhandled_input(self, key):
if key == "ctrl q":
raise urwid.ExitMainLoop
def display_main(self, loop, user_data): def display_main(self, loop, user_data):
self.loop.widget = self.main_display.widget self.loop.widget = self.main_display.widget

View File

@@ -6,6 +6,7 @@ import nomadnet
import subprocess import subprocess
import threading import threading
from .MicronParser import markup_to_attrmaps from .MicronParser import markup_to_attrmaps
from nomadnet.Directory import DirectoryEntry
from nomadnet.vendor.Scrollable import * from nomadnet.vendor.Scrollable import *
class BrowserFrame(urwid.Frame): class BrowserFrame(urwid.Frame):
@@ -20,6 +21,10 @@ class BrowserFrame(urwid.Frame):
self.delegate.reload() self.delegate.reload()
elif key == "ctrl u": elif key == "ctrl u":
self.delegate.url_dialog() self.delegate.url_dialog()
elif key == "ctrl s":
self.delegate.save_node_dialog()
elif key == "ctrl g":
nomadnet.NomadNetworkApp.get_shared_instance().ui.main_display.sub_displays.network_display.toggle_fullscreen()
elif self.get_focus() == "body": elif self.get_focus() == "body":
return super(BrowserFrame, self).keypress(size, key) return super(BrowserFrame, self).keypress(size, key)
# if key == "up" and self.delegate.messagelist.top_is_visible: # if key == "up" and self.delegate.messagelist.top_is_visible:
@@ -128,17 +133,82 @@ class Browser:
self.browser_footer = urwid.AttrMap(urwid.Pile([urwid.Divider(self.g["divider1"]), urwid.Text("Link to: "+str(link_target))]), "browser_controls") self.browser_footer = urwid.AttrMap(urwid.Pile([urwid.Divider(self.g["divider1"]), urwid.Text("Link to: "+str(link_target))]), "browser_controls")
self.frame.contents["footer"] = (self.browser_footer, self.frame.options()) self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
def handle_link(self, link_target): def expand_shorthands(self, destination_type):
if self.status >= Browser.DISCONECTED: if destination_type == "nnn":
RNS.log("Browser handling link to: "+str(link_target), RNS.LOG_DEBUG) return "nomadnetwork.node"
try: elif destination_type == "lxmf":
self.retrieve_url(link_target) return "lxmf.delivery"
except Exception as e:
self.browser_footer = urwid.Text("Could not open link: "+str(e))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
else: else:
RNS.log("Browser aleady hadling link, cannot handle link to: "+str(link_target), RNS.LOG_DEBUG) return destination_type
def handle_link(self, link_target):
components = link_target.split("@")
destination_type = None
if len(components) == 2:
destination_type = self.expand_shorthands(components[0])
link_target = components[1]
else:
destination_type = "nomadnetwork.node"
link_target = components[0]
if destination_type == "nomadnetwork.node":
if self.status >= Browser.DISCONECTED:
RNS.log("Browser handling link to: "+str(link_target), RNS.LOG_DEBUG)
try:
self.retrieve_url(link_target)
except Exception as e:
self.browser_footer = urwid.Text("Could not open link: "+str(e))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
else:
RNS.log("Browser already handling link, cannot handle link to: "+str(link_target), RNS.LOG_DEBUG)
elif destination_type == "lxmf.delivery":
RNS.log("Passing LXMF link to handler", RNS.LOG_DEBUG)
self.handle_lxmf_link(link_target)
else:
RNS.log("No known handler for destination type "+str(destination_type), RNS.LOG_DEBUG)
self.browser_footer = urwid.Text("Could not open link: "+"No known handler for destination type "+str(destination_type))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
def handle_lxmf_link(self, link_target):
try:
if not type(link_target) is str:
raise ValueError("Invalid data type for LXMF link")
if len(link_target) != (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
raise ValueError("Invalid length for LXMF link")
try:
bytes.fromhex(link_target)
except Exception as e:
raise ValueError("Could not decode destination hash from LXMF link")
existing_conversations = nomadnet.Conversation.conversation_list(self.app)
source_hash_text = link_target
display_name_data = RNS.Identity.recall_app_data(bytes.fromhex(source_hash_text))
display_name = None
if display_name_data != None:
display_name = display_name_data.decode("utf-8")
if not source_hash_text in [c[0] for c in existing_conversations]:
entry = DirectoryEntry(bytes.fromhex(source_hash_text), display_name=display_name)
self.app.directory.remember(entry)
new_conversation = nomadnet.Conversation(source_hash_text, nomadnet.NomadNetworkApp.get_shared_instance(), initiator=True)
self.app.ui.main_display.sub_displays.conversations_display.update_conversation_list()
self.app.ui.main_display.sub_displays.conversations_display.display_conversation(None, source_hash_text)
self.app.ui.main_display.show_conversations(None)
except Exception as e:
RNS.log("Error while starting conversation from link. The contained exception was: "+str(e), RNS.LOG_ERROR)
self.browser_footer = urwid.Text("Could not open LXMF link: "+str(e))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
def micron_released_focus(self): def micron_released_focus(self):
@@ -279,7 +349,7 @@ class Browser:
components = url.split(":") components = url.split(":")
if len(components) == 1: if len(components) == 1:
if len(components[0]) == 20: if len(components[0]) == (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
try: try:
destination_hash = bytes.fromhex(components[0]) destination_hash = bytes.fromhex(components[0])
except Exception as e: except Exception as e:
@@ -288,7 +358,7 @@ class Browser:
else: else:
raise ValueError("Malformed URL") raise ValueError("Malformed URL")
elif len(components) == 2: elif len(components) == 2:
if len(components[0]) == 20: if len(components[0]) == (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
try: try:
destination_hash = bytes.fromhex(components[0]) destination_hash = bytes.fromhex(components[0])
except Exception as e: except Exception as e:
@@ -481,7 +551,12 @@ class Browser:
self.close_dialogs() self.close_dialogs()
def confirmed(sender): def confirmed(sender):
self.retrieve_url(e_url.get_edit_text()) try:
self.retrieve_url(e_url.get_edit_text())
except Exception as e:
self.browser_footer = urwid.Text("Could not open link: "+str(e))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
self.close_dialogs() self.close_dialogs()
dialog = UrlDialogLineBox( dialog = UrlDialogLineBox(
@@ -501,6 +576,40 @@ class Browser:
self.delegate.columns.contents[1] = (overlay, options) self.delegate.columns.contents[1] = (overlay, options)
self.delegate.columns.focus_position = 1 self.delegate.columns.focus_position = 1
def save_node_dialog(self):
def dismiss_dialog(sender):
self.close_dialogs()
display_name = RNS.Identity.recall_app_data(self.destination_hash)
disp_str = ""
if display_name != None:
display_name = display_name.decode("utf-8")
disp_str = " \""+display_name+"\""
def confirmed(sender):
node_entry = DirectoryEntry(self.destination_hash, display_name=display_name, hosts_node=True)
self.app.directory.remember(node_entry)
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
self.close_dialogs()
dialog = UrlDialogLineBox(
urwid.Pile([
urwid.Text("Save connected node"+disp_str+" "+RNS.prettyhexrep(self.destination_hash)+" to Known Nodes?\n"),
urwid.Columns([("weight", 0.45, urwid.Button("Cancel", on_press=dismiss_dialog)), ("weight", 0.1, urwid.Text("")), ("weight", 0.45, urwid.Button("Save", on_press=confirmed))])
]), title="Save Node"
)
dialog.confirmed = confirmed
dialog.delegate = self
bottom = self.display_widget
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 50), valign="middle", height="pack", left=2, right=2)
options = self.delegate.columns.options("weight", self.delegate.right_area_width)
self.delegate.columns.contents[1] = (overlay, options)
self.delegate.columns.focus_position = 1
def load_page(self): def load_page(self):
cached = self.get_cached(self.current_url()) cached = self.get_cached(self.current_url())

View File

@@ -14,7 +14,7 @@ class ConversationListDisplayShortcuts():
def __init__(self, app): def __init__(self, app):
self.app = app self.app = app
self.widget = urwid.AttrMap(urwid.Text("[Enter] Open [C-e] Peer Info [C-x] Delete [C-r] Sync [C-n] New"), "shortcutbar") self.widget = urwid.AttrMap(urwid.Text("[C-e] Peer Info [C-x] Delete [C-r] Sync [C-n] New [C-g] Fullscreen"), "shortcutbar")
class ConversationDisplayShortcuts(): class ConversationDisplayShortcuts():
def __init__(self, app): def __init__(self, app):
@@ -32,6 +32,8 @@ class ConversationsArea(urwid.LineBox):
self.delegate.new_conversation() self.delegate.new_conversation()
elif key == "ctrl r": elif key == "ctrl r":
self.delegate.sync_conversations() self.delegate.sync_conversations()
elif key == "ctrl g":
self.delegate.toggle_fullscreen()
elif key == "tab": elif key == "tab":
self.delegate.app.ui.main_display.frame.set_focus("header") self.delegate.app.ui.main_display.frame.set_focus("header")
elif key == "up" and (self.delegate.ilb.first_item_is_selected() or self.delegate.ilb.body_is_empty()): elif key == "up" and (self.delegate.ilb.first_item_is_selected() or self.delegate.ilb.body_is_empty()):
@@ -48,6 +50,7 @@ class DialogLineBox(urwid.LineBox):
class ConversationsDisplay(): class ConversationsDisplay():
list_width = 0.33 list_width = 0.33
given_list_width = 52
cached_conversation_widgets = {} cached_conversation_widgets = {}
def __init__(self, app): def __init__(self, app):
@@ -64,8 +67,10 @@ class ConversationsDisplay():
self.columns_widget = urwid.Columns( self.columns_widget = urwid.Columns(
[ [
("weight", ConversationsDisplay.list_width, self.listbox), # ("weight", ConversationsDisplay.list_width, self.listbox),
("weight", 1-ConversationsDisplay.list_width, self.make_conversation_widget(None)) # ("weight", 1-ConversationsDisplay.list_width, self.make_conversation_widget(None))
(ConversationsDisplay.given_list_width, self.listbox),
("weight", 1, self.make_conversation_widget(None))
], ],
dividechars=0, focus_column=0, box_columns=[0] dividechars=0, focus_column=0, box_columns=[0]
) )
@@ -126,7 +131,8 @@ class ConversationsDisplay():
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2) overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
options = self.columns_widget.options("weight", ConversationsDisplay.list_width) # options = self.columns_widget.options("weight", ConversationsDisplay.list_width)
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
self.columns_widget.contents[0] = (overlay, options) self.columns_widget.contents[0] = (overlay, options)
def edit_selected_in_directory(self): def edit_selected_in_directory(self):
@@ -226,7 +232,7 @@ class ConversationsDisplay():
(urwid.Button("OK", on_press=dismiss_dialog), options) (urwid.Button("OK", on_press=dismiss_dialog), options)
] ]
query_button = urwid.Button("Query network for keys", on_press=query_action, user_data=source_hash_text) query_button = urwid.Button("Query network for keys", on_press=query_action, user_data=source_hash_text)
known_section = urwid.Pile([urwid.Divider(g["divider1"]), urwid.Text(g["info"]+"\n", align="center"), urwid.Text("The identity of this peer is not known, and you cannot currently communicate.\n", align="center"), query_button, urwid.Divider(g["divider1"])]) known_section = urwid.Pile([urwid.Divider(g["divider1"]), urwid.Text(g["info"]+"\n", align="center"), urwid.Text("The identity of this peer is not known, and you cannot currently send messages to it. You can query the network to obtain the identity.\n", align="center"), query_button, urwid.Divider(g["divider1"])])
dialog_pile = urwid.Pile([ dialog_pile = urwid.Pile([
selected_id_widget, selected_id_widget,
@@ -249,7 +255,8 @@ class ConversationsDisplay():
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2) overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
options = self.columns_widget.options("weight", ConversationsDisplay.list_width) # options = self.columns_widget.options("weight", ConversationsDisplay.list_width)
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
self.columns_widget.contents[0] = (overlay, options) self.columns_widget.contents[0] = (overlay, options)
def new_conversation(self): def new_conversation(self):
@@ -318,7 +325,8 @@ class ConversationsDisplay():
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2) overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
options = self.columns_widget.options("weight", ConversationsDisplay.list_width) # options = self.columns_widget.options("weight", ConversationsDisplay.list_width)
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
self.columns_widget.contents[0] = (overlay, options) self.columns_widget.contents[0] = (overlay, options)
def delete_conversation(self, source_hash): def delete_conversation(self, source_hash):
@@ -326,6 +334,15 @@ class ConversationsDisplay():
conversation = ConversationsDisplay.cached_conversation_widgets[source_hash] conversation = ConversationsDisplay.cached_conversation_widgets[source_hash]
self.close_conversation(conversation) self.close_conversation(conversation)
def toggle_fullscreen(self):
if ConversationsDisplay.given_list_width != 0:
self.saved_list_width = ConversationsDisplay.given_list_width
ConversationsDisplay.given_list_width = 0
else:
ConversationsDisplay.given_list_width = self.saved_list_width
self.update_conversation_list()
def sync_conversations(self): def sync_conversations(self):
g = self.app.ui.glyphs g = self.app.ui.glyphs
self.dialog_open = True self.dialog_open = True
@@ -398,7 +415,8 @@ class ConversationsDisplay():
dialog = DialogLineBox( dialog = DialogLineBox(
urwid.Pile([ urwid.Pile([
urwid.Text(""), urwid.Text(""),
urwid.Text("No trusted nodes found, cannot sync", align="center"), urwid.Text("No trusted nodes found, cannot sync!\n", align="center"),
urwid.Text("To syncronise messages from the network, one or more nodes must be marked as trusted in the Known Nodes list. Nomad Network will then automatically sync from the nearest trusted node.", align="left"),
urwid.Text(""), urwid.Text(""),
button_columns button_columns
]), title="Message Sync" ]), title="Message Sync"
@@ -416,7 +434,8 @@ class ConversationsDisplay():
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2) overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
options = self.columns_widget.options("weight", ConversationsDisplay.list_width) # options = self.columns_widget.options("weight", ConversationsDisplay.list_width)
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
self.columns_widget.contents[0] = (overlay, options) self.columns_widget.contents[0] = (overlay, options)
def update_sync_dialog(self, loop = None, sender = None): def update_sync_dialog(self, loop = None, sender = None):
@@ -437,7 +456,8 @@ class ConversationsDisplay():
def update_conversation_list(self): def update_conversation_list(self):
ilb_position = self.ilb.get_selected_position() ilb_position = self.ilb.get_selected_position()
self.update_listbox() self.update_listbox()
options = self.columns_widget.options("weight", ConversationsDisplay.list_width) # options = self.columns_widget.options("weight", ConversationsDisplay.list_width)
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
if not (self.dialog_open and self.sync_dialog != None): if not (self.dialog_open and self.sync_dialog != None):
self.columns_widget.contents[0] = (self.listbox, options) self.columns_widget.contents[0] = (self.listbox, options)
else: else:
@@ -468,7 +488,8 @@ class ConversationsDisplay():
self.app.mark_conversation_read(self.currently_displayed_conversation) self.app.mark_conversation_read(self.currently_displayed_conversation)
self.currently_displayed_conversation = source_hash self.currently_displayed_conversation = source_hash
options = self.widget.options("weight", 1-ConversationsDisplay.list_width) # options = self.widget.options("weight", 1-ConversationsDisplay.list_width)
options = self.widget.options("weight", 1)
self.widget.contents[1] = (self.make_conversation_widget(source_hash), options) self.widget.contents[1] = (self.make_conversation_widget(source_hash), options)
if source_hash == None: if source_hash == None:
self.widget.set_focus_column(0) self.widget.set_focus_column(0)
@@ -753,7 +774,7 @@ class ConversationWidget(urwid.WidgetWrap):
if allowed: if allowed:
self.frame.contents["footer"] = (self.minimal_editor, None) self.frame.contents["footer"] = (self.minimal_editor, None)
else: else:
warning = urwid.AttrMap(urwid.Padding(urwid.Text(g["info"]+" You cannot currently communicate with this peer, since it's identity keys are not known", align="center")), "msg_header_caution") warning = urwid.AttrMap(urwid.Padding(urwid.Text("\n"+g["info"]+"\n\nYou cannot currently message this peer, since it's identity keys are not known.\n\nWait for an announce to arrive from the peer, or query the network for it.\n\nTo query the network, select this conversation in the conversation list, press Ctrl-E, and use the query button.\n", align="center")), "msg_header_caution")
self.frame.contents["footer"] = (warning, None) self.frame.contents["footer"] = (warning, None)
def toggle_focus_area(self): def toggle_focus_area(self):
@@ -780,6 +801,8 @@ class ConversationWidget(urwid.WidgetWrap):
self.toggle_editor() self.toggle_editor()
elif key == "ctrl x": elif key == "ctrl x":
self.clear_history_dialog() self.clear_history_dialog()
elif key == "ctrl g":
nomadnet.NomadNetworkApp.get_shared_instance().ui.main_display.sub_displays.conversations_display.toggle_fullscreen()
elif key == "ctrl o": elif key == "ctrl o":
self.sort_by_timestamp ^= True self.sort_by_timestamp ^= True
self.conversation_changed(None) self.conversation_changed(None)

View File

@@ -17,45 +17,3 @@ class IntroDisplay():
self.widget = urwid.Filler(intro) self.widget = urwid.Filler(intro)
class DemoDisplay():
def __init__(self, ui, app):
import urwid
def color_mono(btn):
ui.set_colormode(nomadnet.ui.COLORMODE_MONO)
def color_16(btn):
ui.set_colormode(nomadnet.ui.COLORMODE_16)
def color_88(btn):
ui.set_colormode(nomadnet.ui.COLORMODE_88)
def color_8bit(btn):
ui.set_colormode(nomadnet.ui.COLORMODE_256)
def color_true(btn):
ui.set_colormode(nomadnet.ui.COLORMODE_TRUE)
# pile = urwid.Pile([
# urwid.Text(("heading", "This is a heading")),
# urwid.Text(("body_text", "Hello World \U0001F332")),
# urwid.Button(("buttons", "Monochrome"), color_mono),
# urwid.Button(("buttons", "16 color"), color_16),
# urwid.Button(("buttons", "88 color"), color_88),
# urwid.Button(("buttons", "256 color"), color_8bit),
# urwid.Button(("buttons", "True color"), color_true),
# ])
gf = urwid.GridFlow([
urwid.Text(("heading", "This is a heading")),
urwid.Text(("body_text", "Hello World \U0001F332")),
urwid.Button(("buttons", "Monochrome"), color_mono),
urwid.Button(("buttons", "16 color"), color_16),
urwid.Button(("buttons", "88 color"), color_88),
urwid.Button(("buttons", "256 color"), color_8bit),
urwid.Button(("buttons", "True color"), color_true),
], cell_width=20, h_sep=0, v_sep=0, align="left")
self.widget = urwid.Filler(urwid.Padding((urwid.Text("Test"),urwid.Text("Test 2"))), 'top')
#self.widget = urwid.Filler(pile, 'top')

View File

@@ -111,6 +111,7 @@ class TopicList(urwid.WidgetWrap):
GuideEntry(self.app, self, guide_display, "Concepts & Terminology"), GuideEntry(self.app, self, guide_display, "Concepts & Terminology"),
GuideEntry(self.app, self, guide_display, "Hosting a Node"), GuideEntry(self.app, self, guide_display, "Hosting a Node"),
GuideEntry(self.app, self, guide_display, "Configuration Options"), GuideEntry(self.app, self, guide_display, "Configuration Options"),
GuideEntry(self.app, self, guide_display, "Keyboard Shortcuts"),
GuideEntry(self.app, self, guide_display, "Markup"), GuideEntry(self.app, self, guide_display, "Markup"),
self.first_run_entry, self.first_run_entry,
GuideEntry(self.app, self, guide_display, "Network Configuration"), GuideEntry(self.app, self, guide_display, "Network Configuration"),
@@ -194,6 +195,48 @@ The current version of the program should be considered a beta release. The prog
''' '''
TOPIC_SHORTCUTS = '''>Keyboard Shortcuts
The different sections of the program has a number of keyboard shortcuts mapped, that makes operating and navigating the program easier. The following lists details all mapped shortcuts.
>>`!Conversations Window`!
>>>Conversation List
- Ctrl-N Start a new conversation
- Ctrl-E Display and edit selected peer info
- Ctrl-X Delete conversation
- Ctrl-R Open LXMF syncronisation dialog
>>>Conversation Display
- Ctrl-D Send message
- Ctrl-K Clear input fields
- Ctrl-T Toggle message title field
- Ctrl-O Toggle sort mode
- Ctrl-P Purge failed messages
- Ctrl-X Clear conversation history
- Ctrl-G Toggle fullscreen conversation
- Ctrl-W Close conversation
>>`!Network Window`!
>>>Announce Stream
- Ctrl-L Switch to Known Nodes list
- Ctrl-X Delete selected announce
- Ctrl-P Display peered LXMF Propagation Nodes
>>>Known Nodes
- Ctrl-L Switch to Announce Stream
- Ctrl-X Delete selected node entry
- Ctrl-P Display peered LXMF Propagation Nodes
>>>Browser
- Ctrl-D Back
- Ctrl-F Forward
- Ctrl-R Reload page
- Ctrl-U Open URL entry dialog
- Ctrl-S Save connected node
- Ctrl-G Toggle fullscreen browser window
- Ctrl-W Disconnect from node
'''
TOPIC_CONCEPTS = '''>Concepts and Terminology TOPIC_CONCEPTS = '''>Concepts and Terminology
The following section will briefly introduce various concepts and terms used in the program. The following section will briefly introduce various concepts and terms used in the program.
@@ -202,9 +245,9 @@ The following section will briefly introduce various concepts and terms used in
A `*peer`* refers to another Nomad Network client, which will generally be operated by another person. But since Nomad Network is a general LXMF client, it could also be any other LXMF client, program, automated system or machine that can communicate over LXMF. A `*peer`* refers to another Nomad Network client, which will generally be operated by another person. But since Nomad Network is a general LXMF client, it could also be any other LXMF client, program, automated system or machine that can communicate over LXMF.
All peers (and nodes) are identified by their `*address`* (which is, technically speaking, a Reticulum destination hash). An address consist of 20 hexadecimal characters, and looks like this: All peers (and nodes) are identified by their `*address`* (which is, technically speaking, a Reticulum destination hash). An address consist of 32 hexadecimal characters (16 bytes), and looks like this:
`c<b8ea8f92541c9a275f0e> `c<e9eafceea9e3664a5c55611c5e8c420a>
`l `l
Anyone can choose whatever display name they want, but addresses are always unique, and generated from the unique cryptographic keys of the peer. This is an important point to understand. Since there is not anyone controlling naming or address spaces in Nomad Network, you can easily come across another user with the same display name as you. Anyone can choose whatever display name they want, but addresses are always unique, and generated from the unique cryptographic keys of the peer. This is an important point to understand. Since there is not anyone controlling naming or address spaces in Nomad Network, you can easily come across another user with the same display name as you.
@@ -235,7 +278,7 @@ For propagated delivery to work, one or more nodes must be available on the netw
To select a node manually, go to the `![ Network ]`! part of the program, choose the desired node in the `*Known Nodes`* list, and select the `!< Info >`! button. In the `!Node Info`! dialog, you can specify the selected node as the default propagation node. To select a node manually, go to the `![ Network ]`! part of the program, choose the desired node in the `*Known Nodes`* list, and select the `!< Info >`! button. In the `!Node Info`! dialog, you can specify the selected node as the default propagation node.
By default, Nomad Network will check in with propagation nodes, and download any available messages every 6 hours. You can change this interval, or disable automatic synchronisation completely, by editing the configuration file. By default, Nomad Network will check in with propagation nodes, and download any available messages every 6 hours. You can change this interval, or disable automatic syncronisation completely, by editing the configuration file.
You can always initiate a sync manually, by pressing `!Ctrl-R`! in the `![ Conversations ]`! part of the program, which will open the syncronisation window. You can always initiate a sync manually, by pressing `!Ctrl-R`! in the `![ Conversations ]`! part of the program, which will open the syncronisation window.
@@ -245,7 +288,7 @@ A Nomad Network `*node`* is an instance of the Nomad Network program that has be
Nodes can host pages (similar to webpages) written in a markup-language called `*micron`*, as well as make files and other resources available for download for peers on the network. Nodes also form a distributed message store for offline users, and allows messages to be exchanged between peers that are not online at the same time. Nodes can host pages (similar to webpages) written in a markup-language called `*micron`*, as well as make files and other resources available for download for peers on the network. Nodes also form a distributed message store for offline users, and allows messages to be exchanged between peers that are not online at the same time.
If no nodes exist on a network, all peers will still be able to communicate directly peer-to-peer, but both endpoints of a conversation will need to be available at the same time to converse. When nodes exist on the network, messages will be held and syncronised between nodes for deferred delivery if the destination peer is unavailable. Nodes will automatically discover and peer with each other, and handle synchronisation of message stores. If no nodes exist on a network, all peers will still be able to communicate directly peer-to-peer, but both endpoints of a conversation will need to be available at the same time to converse. When nodes exist on the network, messages will be held and syncronised between nodes for deferred delivery if the destination peer is unavailable. Nodes will automatically discover and peer with each other, and handle syncronisation of message stores.
To learn how to host your own node, read the `*Hosting a Node`* section of this guide. To learn how to host your own node, read the `*Hosting a Node`* section of this guide.
@@ -535,9 +578,9 @@ Determines whether your node is automatically announced on the network when the
< <
>>> >>>
`!announce_interval = 720`! `!announce_interval = 360`!
>>>> >>>>
Determines how often, in minutes, your node is announced on the network. Defaults to 12 hours. Determines how often, in minutes, your node is announced on the network. Defaults to 6 hours.
< <
>>> >>>
@@ -553,20 +596,48 @@ Determines where the node server will look for downloadable files. Must be a rea
< <
>>> >>>
`!message_storage_limit = 2`! `!message_storage_limit = 2000`!
>>>> >>>>
Configures the maximum amount of storage, in gigabytes, the LXMF Propagation Node will use to store messages. Configures the maximum amount of storage, in megabytes, that the LXMF Propagation Node will use to store messages.
< <
>>> >>>
`!prioritise_destinations = 10bc7624c27032a18639, ba780a6dff4cc1391db8`! `!prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf`!
>>>> >>>>
Configures the LXMF Propagation Node to prioritise storing messages for certain destinations. If the message store reaches the specified limit, LXMF will prioritise keeping messages for destinations specified with this option. This setting is optional, and generally you do not need to use it. Configures the LXMF Propagation Node to prioritise storing messages for certain destinations. If the message store reaches the specified limit, LXMF will prioritise keeping messages for destinations specified with this option. This setting is optional, and generally you do not need to use it.
< <
>> Printing Section
This section holds configuration directives related to printing. It is delimited by the `![printing]`! header in the configuration file. Available directives, along with example values, are as follows:
>>>
`!print_messages = no`!
>>>>
Determines whether messages should be printed upon arrival. Must be a boolean value, and is turned off by default.
<
>>>
`!message_template = ~/.nomadnetwork/print_template_msg.txt`!
>>>>
Determines where the template for printed messages is found. Must be a filesystem path. If you set this path to a non-existing file, an example will be generated in the specified location.
<
>>>
`!print_from = 76fe5751a56067d1e84eef3e88eab85b, trusted`!
>>>>
Determines from which destinations messages are printed. Can be a list of destinations hashes, the keyword "trusted", or "everywhere".
<
>>>
`!print_command = lp -d PRINTER_NAME -o cpi=16 -o lpi=8`!
>>>>
Specifies the command that Nomad Network uses to print the message. Defaults to "lp". The above example works well for small thermal-roll printers.
<
>Ignoring Destinations >Ignoring Destinations
If you encounter peers or nodes on the network, that you would rather not see in your client, you can add them to the `!~/.nomadnetwork/ignored`! file. To ignore nodes or peers, add one 20-character hexadecimal destination hash per line to the file. To unignore one again, simply remove the corresponding entry from the file and restart Nomad Network. If you encounter peers or nodes on the network, that you would rather not see in your client, you can add them to the `!~/.nomadnetwork/ignored`! file. To ignore nodes or peers, add one 32-character hexadecimal destination hash per line to the file. To unignore one again, simply remove the corresponding entry from the file and restart Nomad Network.
''' '''
TOPIC_NETWORKS = '''>Network Configuration TOPIC_NETWORKS = '''>Network Configuration
@@ -706,7 +777,7 @@ While micron can output formatted text to even the most basic terminal, there's
Formatting such as `_underline`_, `!bold`! or `*italics`* will be displayed if your terminal supports it. Formatting such as `_underline`_, `!bold`! or `*italics`* will be displayed if your terminal supports it.
If you are having trouble getting micron output to display correctly, try using `*gnome-terminal`*, which should work with all formatting options out of the box. Most other terminals will work fine as well, but you might have to change some settings to get certain formatting to display correctly. If you are having trouble getting micron output to display correctly, try using `*gnome-terminal`* or `*alacritty`*, which should work with all formatting options out of the box. Most other terminals will work fine as well, but you might have to change some settings to get certain formatting to display correctly.
>>>Encoding >>>Encoding
@@ -886,11 +957,11 @@ Here's a few examples:
`Faaa `Faaa
`= `=
Here is a link without any label: `[1385edace36466a6b3dd:/page/index.mu] Here is a link without any label: `[72914442a3689add83a09a767963f57c:/page/index.mu]
This is a `[labeled link`1385edace36466a6b3dd:/page/index.mu] to the same page, but it's hard to see if you don't know it This is a `[labeled link`72914442a3689add83a09a767963f57c:/page/index.mu] to the same page, but it's hard to see if you don't know it
Here is `F00a`_`[a more visible link`1385edace36466a6b3dd:/page/index.mu]`_`f Here is `F00a`_`[a more visible link`72914442a3689add83a09a767963f57c:/page/index.mu]`_`f
`= `=
`` ``
@@ -898,11 +969,11 @@ The above markup produces the following output:
`Faaa`B333 `Faaa`B333
Here is a link without any label: `[1385edace36466a6b3dd:/page/index.mu] Here is a link without any label: `[72914442a3689add83a09a767963f57c:/page/index.mu]
This is a `[labeled link`1385edace36466a6b3dd:/page/index.mu] to the same page, but it's hard to see if you don't know it This is a `[labeled link`72914442a3689add83a09a767963f57c:/page/index.mu] to the same page, but it's hard to see if you don't know it
Here is `F00f`_`[a more visible link`1385edace36466a6b3dd:/page/index.mu]`_`f Here is `F00f`_`[a more visible link`72914442a3689add83a09a767963f57c:/page/index.mu]`_`f
`` ``
@@ -949,6 +1020,7 @@ TOPICS = {
"Conversations": TOPIC_CONVERSATIONS, "Conversations": TOPIC_CONVERSATIONS,
"Hosting a Node": TOPIC_HOSTING, "Hosting a Node": TOPIC_HOSTING,
"Configuration Options": TOPIC_CONFIG, "Configuration Options": TOPIC_CONFIG,
"Keyboard Shortcuts": TOPIC_SHORTCUTS,
"Markup": TOPIC_MARKUP, "Markup": TOPIC_MARKUP,
"Display Test": TOPIC_DISPLAYTEST, "Display Test": TOPIC_DISPLAYTEST,
"Network Configuration": TOPIC_NETWORKS, "Network Configuration": TOPIC_NETWORKS,

View File

@@ -13,7 +13,7 @@ class NetworkDisplayShortcuts():
self.app = app self.app = app
g = app.ui.glyphs g = app.ui.glyphs
self.widget = urwid.AttrMap(urwid.Text("[C-l] Nodes/Announces [C-x] Remove [C-w] Disconnect [C-d] Back [C-f] Forward [C-r] Reload [C-u] URL"), "shortcutbar") self.widget = urwid.AttrMap(urwid.Text("[C-l] Nodes/Announces [C-x] Remove [C-w] Disconnect [C-d] Back [C-f] Forward [C-r] Reload [C-u] URL [C-g] Fullscreen"), "shortcutbar")
# "[C-"+g["arrow_u"]+g["arrow_d"]+"] Navigate Lists" # "[C-"+g["arrow_u"]+g["arrow_d"]+"] Navigate Lists"
@@ -51,6 +51,13 @@ class ListEntry(urwid.Text):
class AnnounceInfo(urwid.WidgetWrap): class AnnounceInfo(urwid.WidgetWrap):
def keypress(self, size, key):
if key == "esc":
options = self.parent.left_pile.options(height_type="weight", height_amount=1)
self.parent.left_pile.contents[0] = (self.parent.announce_stream_display, options)
else:
return super(AnnounceInfo, self).keypress(size, key)
def __init__(self, announce, parent, app): def __init__(self, announce, parent, app):
self.app = nomadnet.NomadNetworkApp.get_shared_instance() self.app = nomadnet.NomadNetworkApp.get_shared_instance()
self.parent = self.app.ui.main_display.sub_displays.network_display self.parent = self.app.ui.main_display.sub_displays.network_display
@@ -387,6 +394,13 @@ class ListDialogLineBox(urwid.LineBox):
return super(ListDialogLineBox, self).keypress(size, key) return super(ListDialogLineBox, self).keypress(size, key)
class KnownNodeInfo(urwid.WidgetWrap): class KnownNodeInfo(urwid.WidgetWrap):
def keypress(self, size, key):
if key == "esc":
options = self.parent.left_pile.options(height_type="weight", height_amount=1)
self.parent.left_pile.contents[0] = (self.parent.known_nodes_display, options)
else:
return super(KnownNodeInfo, self).keypress(size, key)
def __init__(self, node_hash): def __init__(self, node_hash):
self.app = nomadnet.NomadNetworkApp.get_shared_instance() self.app = nomadnet.NomadNetworkApp.get_shared_instance()
self.parent = self.app.ui.main_display.sub_displays.network_display self.parent = self.app.ui.main_display.sub_displays.network_display
@@ -406,6 +420,9 @@ class KnownNodeInfo(urwid.WidgetWrap):
addr_str = "<"+RNS.hexrep(source_hash, delimit=False)+">" addr_str = "<"+RNS.hexrep(source_hash, delimit=False)+">"
if display_str == None:
display_str = addr_str
if node_ident != None: if node_ident != None:
lxmf_addr_str = g["sent"]+" LXMF Propagation Node Address is "+RNS.prettyhexrep(RNS.Destination.hash_from_name_and_identity("lxmf.propagation", node_ident)) lxmf_addr_str = g["sent"]+" LXMF Propagation Node Address is "+RNS.prettyhexrep(RNS.Destination.hash_from_name_and_identity("lxmf.propagation", node_ident))
else: else:
@@ -568,6 +585,10 @@ class KnownNodeInfo(urwid.WidgetWrap):
pile = urwid.Pile(pile_widgets) pile = urwid.Pile(pile_widgets)
pile.focus_position = len(pile.contents)-1
button_columns.focus_position = 0
self.display_widget = urwid.Filler(pile, valign="top", height="pack") self.display_widget = urwid.Filler(pile, valign="top", height="pack")
urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Node Info")) urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Node Info"))
@@ -806,7 +827,7 @@ class NodeAnnounceTime(urwid.WidgetWrap):
if self.app.peer_settings["node_last_announce"] != None: if self.app.peer_settings["node_last_announce"] != None:
self.last_announce_string = pretty_date(int(self.app.peer_settings["node_last_announce"])) self.last_announce_string = pretty_date(int(self.app.peer_settings["node_last_announce"]))
self.display_widget.set_text("Last Announce : "+self.last_announce_string) self.display_widget.set_text("Last Announce : "+self.last_announce_string)
def update_time_callback(self, loop=None, user_data=None): def update_time_callback(self, loop=None, user_data=None):
self.update_time() self.update_time()
@@ -837,7 +858,7 @@ class NodeActiveConnections(urwid.WidgetWrap):
if self.app.node != None: if self.app.node != None:
self.stat_string = str(len(self.app.node.destination.links)) self.stat_string = str(len(self.app.node.destination.links))
self.display_widget.set_text("Connections Now : "+self.stat_string) self.display_widget.set_text("Conneced Now : "+self.stat_string)
def update_stat_callback(self, loop=None, user_data=None): def update_stat_callback(self, loop=None, user_data=None):
self.update_stat() self.update_stat()
@@ -853,6 +874,48 @@ class NodeActiveConnections(urwid.WidgetWrap):
def stop(self): def stop(self):
self.started = False self.started = False
class NodeStorageStats(urwid.WidgetWrap):
def __init__(self, app):
self.started = False
self.app = app
self.timeout = self.app.config["textui"]["animation_interval"]
self.display_widget = urwid.Text("")
self.update_stat()
urwid.WidgetWrap.__init__(self, self.display_widget)
def update_stat(self):
self.stat_string = "None"
if self.app.node != None:
limit = self.app.message_router.message_storage_limit
used = self.app.message_router.message_storage_size()
if limit != None:
pct = round((used/limit)*100, 1)
pct_str = str(pct)+"%, "
limit_str = " of "+RNS.prettysize(limit)
else:
limit_str = ""
pct_str = ""
self.stat_string = pct_str+RNS.prettysize(used)+limit_str
self.display_widget.set_text("LXMF Storage : "+self.stat_string)
def update_stat_callback(self, loop=None, user_data=None):
self.update_stat()
if self.started:
self.app.ui.loop.set_alarm_in(self.timeout, self.update_stat_callback)
def start(self):
was_started = self.started
self.started = True
if not was_started:
self.update_stat_callback()
def stop(self):
self.started = False
class NodeTotalConnections(urwid.WidgetWrap): class NodeTotalConnections(urwid.WidgetWrap):
def __init__(self, app): def __init__(self, app):
@@ -869,7 +932,7 @@ class NodeTotalConnections(urwid.WidgetWrap):
if self.app.node != None: if self.app.node != None:
self.stat_string = str(self.app.peer_settings["node_connects"]) self.stat_string = str(self.app.peer_settings["node_connects"])
self.display_widget.set_text("Total Connections : "+self.stat_string) self.display_widget.set_text("Total Connects : "+self.stat_string)
def update_stat_callback(self, loop=None, user_data=None): def update_stat_callback(self, loop=None, user_data=None):
self.update_stat() self.update_stat()
@@ -901,7 +964,7 @@ class NodeTotalPages(urwid.WidgetWrap):
if self.app.node != None: if self.app.node != None:
self.stat_string = str(self.app.peer_settings["served_page_requests"]) self.stat_string = str(self.app.peer_settings["served_page_requests"])
self.display_widget.set_text("Served Pages : "+self.stat_string) self.display_widget.set_text("Served Pages : "+self.stat_string)
def update_stat_callback(self, loop=None, user_data=None): def update_stat_callback(self, loop=None, user_data=None):
self.update_stat() self.update_stat()
@@ -933,7 +996,7 @@ class NodeTotalFiles(urwid.WidgetWrap):
if self.app.node != None: if self.app.node != None:
self.stat_string = str(self.app.peer_settings["served_file_requests"]) self.stat_string = str(self.app.peer_settings["served_file_requests"])
self.display_widget.set_text("Served Files : "+self.stat_string) self.display_widget.set_text("Served Files : "+self.stat_string)
def update_stat_callback(self, loop=None, user_data=None): def update_stat_callback(self, loop=None, user_data=None):
self.update_stat() self.update_stat()
@@ -1050,6 +1113,7 @@ class NodeInfo(urwid.WidgetWrap):
conns_timer = None conns_timer = None
pages_timer = None pages_timer = None
files_timer = None files_timer = None
storage_timer = None
def __init__(self, app, parent): def __init__(self, app, parent):
self.app = app self.app = app
@@ -1123,6 +1187,13 @@ class NodeInfo(urwid.WidgetWrap):
self.t_active_links = NodeInfo.links_timer self.t_active_links = NodeInfo.links_timer
self.t_active_links.update_stat() self.t_active_links.update_stat()
if NodeInfo.storage_timer == None:
self.t_storage_stats = NodeStorageStats(self.app)
NodeInfo.storage_timer = self.t_storage_stats
else:
self.t_active_links = NodeInfo.links_timer
self.t_active_links.update_stat()
if NodeInfo.conns_timer == None: if NodeInfo.conns_timer == None:
self.t_total_connections = NodeTotalConnections(self.app) self.t_total_connections = NodeTotalConnections(self.app)
NodeInfo.conns_timer = self.t_total_connections NodeInfo.conns_timer = self.t_total_connections
@@ -1158,6 +1229,7 @@ class NodeInfo(urwid.WidgetWrap):
e_lxmf, e_lxmf,
urwid.Divider(g["divider1"]), urwid.Divider(g["divider1"]),
self.t_last_announce, self.t_last_announce,
self.t_storage_stats,
self.t_active_links, self.t_active_links,
self.t_total_connections, self.t_total_connections,
self.t_total_pages, self.t_total_pages,
@@ -1257,6 +1329,10 @@ class NetworkLeftPile(urwid.Pile):
def keypress(self, size, key): def keypress(self, size, key):
if key == "ctrl l": if key == "ctrl l":
self.parent.toggle_list() self.parent.toggle_list()
elif key == "ctrl g":
self.parent.toggle_fullscreen()
elif key == "ctrl e":
self.parent.selected_node_info()
elif key == "ctrl p": elif key == "ctrl p":
self.parent.reinit_lxmf_peers() self.parent.reinit_lxmf_peers()
self.parent.show_peers() self.parent.show_peers()
@@ -1264,12 +1340,16 @@ class NetworkLeftPile(urwid.Pile):
self.parent.browser.disconnect() self.parent.browser.disconnect()
elif key == "ctrl u": elif key == "ctrl u":
self.parent.browser.url_dialog() self.parent.browser.url_dialog()
elif key == "ctrl s":
self.parent.browser.save_node_dialog()
else: else:
return super(NetworkLeftPile, self).keypress(size, key) return super(NetworkLeftPile, self).keypress(size, key)
class NetworkDisplay(): class NetworkDisplay():
list_width = 0.33 list_width = 0.33
given_list_width = 52
def __init__(self, app): def __init__(self, app):
self.app = app self.app = app
@@ -1304,8 +1384,10 @@ class NetworkDisplay():
self.columns = urwid.Columns( self.columns = urwid.Columns(
[ [
("weight", NetworkDisplay.list_width, self.left_area), # ("weight", NetworkDisplay.list_width, self.left_area),
("weight", self.right_area_width, self.right_area) # ("weight", self.right_area_width, self.right_area)
(NetworkDisplay.given_list_width, self.left_area),
("weight", 1, self.right_area)
], ],
dividechars=0, focus_column=0 dividechars=0, focus_column=0
) )
@@ -1323,6 +1405,16 @@ class NetworkDisplay():
self.left_pile.contents[0] = (self.known_nodes_display, options) self.left_pile.contents[0] = (self.known_nodes_display, options)
self.list_display = 1 self.list_display = 1
def toggle_fullscreen(self):
if NetworkDisplay.given_list_width != 0:
self.saved_list_width = NetworkDisplay.given_list_width
NetworkDisplay.given_list_width = 0
else:
NetworkDisplay.given_list_width = self.saved_list_width
options = self.widget.options("given", NetworkDisplay.given_list_width)
self.widget.contents[0] = (self.left_area, options)
def show_peers(self): def show_peers(self):
options = self.left_pile.options(height_type="weight", height_amount=1) options = self.left_pile.options(height_type="weight", height_amount=1)
self.left_pile.contents[0] = (self.lxmf_peers_display, options) self.left_pile.contents[0] = (self.lxmf_peers_display, options)
@@ -1332,6 +1424,18 @@ class NetworkDisplay():
else: else:
self.list_display = 1 self.list_display = 1
def selected_node_info(self):
if self.list_display == 1:
parent = self.app.ui.main_display.sub_displays.network_display
selected_node_entry = parent.known_nodes_display.ilb.get_selected_item()
if selected_node_entry != None:
selected_node_hash = selected_node_entry._get_base_widget().display_widget.source_hash
if selected_node_hash != None:
info_widget = KnownNodeInfo(selected_node_hash)
options = parent.left_pile.options(height_type="weight", height_amount=1)
parent.left_pile.contents[0] = (info_widget, options)
def focus_lists(self): def focus_lists(self):
self.columns.focus_position = 0 self.columns.focus_position = 0
@@ -1464,7 +1568,7 @@ class LXMFPeerEntry(urwid.WidgetWrap):
style = "list_unknown" style = "list_unknown"
focus_style = "list_focus" focus_style = "list_focus"
widget = ListEntry(sym+" "+display_str+"\n "+str(len(peer.unhandled_messages))+" unhandled messages - "+"Last heard "+pretty_date(int(peer.last_heard))) widget = ListEntry(sym+" "+display_str+"\n "+str(len(peer.unhandled_messages))+" unhandled LXMs - "+"Last heard "+pretty_date(int(peer.last_heard)))
# urwid.connect_signal(widget, "click", delegate.connect_node, node) # urwid.connect_signal(widget, "click", delegate.connect_node, node)
self.display_widget = urwid.AttrMap(widget, style, focus_style) self.display_widget = urwid.AttrMap(widget, style, focus_style)

View File

@@ -23,6 +23,6 @@ setuptools.setup(
entry_points= { entry_points= {
'console_scripts': ['nomadnet=nomadnet.nomadnet:main'] 'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
}, },
install_requires=['rns>=0.3.8', 'lxmf>=0.1.7', 'urwid>=2.1.2'], install_requires=['rns>=0.3.9', 'lxmf>=0.1.7', 'urwid>=2.1.2'],
python_requires='>=3.6', python_requires='>=3.6',
) )