mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-12-17 14:54:26 +01:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be061b1d3a | ||
|
|
b73549179e | ||
|
|
0156bad7fa | ||
|
|
5c3d47fbd2 | ||
|
|
d35e23c74f | ||
|
|
a83db96b22 | ||
|
|
6da537176b | ||
|
|
850f56cac3 | ||
|
|
247db32033 | ||
|
|
d8a35be14d | ||
|
|
d1c66aa7cd | ||
|
|
726ee8873e | ||
|
|
3c7b8511d7 | ||
|
|
f699c61a64 | ||
|
|
1002a89ad5 | ||
|
|
87c810fdd0 | ||
|
|
4e50e0f076 | ||
|
|
f75b4d0b57 | ||
|
|
27dc1b5fb5 | ||
|
|
1b1558c769 | ||
|
|
681efb422d | ||
|
|
8ef9e55a22 | ||
|
|
0a0de599dd | ||
|
|
2767e35a9f | ||
|
|
2b3943eeba | ||
|
|
7a625d677d | ||
|
|
2354ba3412 | ||
|
|
fa2382e34a | ||
|
|
7814712118 | ||
|
|
a6eac0d7ce | ||
|
|
f9259b8173 | ||
|
|
d65d03fe89 | ||
|
|
acb5da89fb | ||
|
|
3fc321e804 |
@@ -16,9 +16,11 @@ FROM python:3.11-rc-alpine3.14
|
||||
LABEL org.opencontainers.image.documentation="https://github.com/markqvist/NomadNet#nomad-network-daemon-with-docker"
|
||||
|
||||
ENV PATH="/opt/venv/bin:$PATH"
|
||||
ENV PYTHONUNBUFFERED="yes"
|
||||
COPY --from=build /opt/venv /opt/venv
|
||||
|
||||
VOLUME /root/.reticulum
|
||||
VOLUME /root/.nomadnetwork
|
||||
|
||||
ENTRYPOINT ["nomadnet", "--daemon"]
|
||||
ENTRYPOINT ["nomadnet"]
|
||||
CMD ["--daemon"]
|
||||
|
||||
48
README.md
48
README.md
@@ -59,26 +59,36 @@ You can install Nomad Network on Android using Termux, but there's a few more co
|
||||
|
||||
For a native Android application with a graphical user interface, have a look at [Sideband](https://unsigned.io/sideband).
|
||||
|
||||
### Nomad Network Daemon with Docker
|
||||
|
||||
Nomad Network is automatically published as a docker image on Github Packages. Image tags are one of either `master` (for the latest release) or the version number (eg `0.1.7`) for the specified version number (as tagged in this git repo).
|
||||
### 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.2.0`) for a specific release.
|
||||
|
||||
```sh
|
||||
$ docker pull ghcr.io/markqvist/nomadnet:master
|
||||
|
||||
# Run nomadnet interactively without installing it (with default config)
|
||||
$ docker run -it ghcr.io/markqvist/nomadnet:master
|
||||
# Run nomadnet interactively in a container
|
||||
$ docker run -it ghcr.io/markqvist/nomadnet:master --textui
|
||||
|
||||
# Run nomadnet as a daemon, using config stored on the host machine in specific
|
||||
# directories, and allowing access to specific numbered ports openned by nomadnet
|
||||
# on the host machine on the same port numbers.
|
||||
# Run nomadnet as a daemon, using config stored on the host machine in specified
|
||||
# directories, and connect the containers network to the host network (which will
|
||||
# allow the default AutoInterface to automatically peer with other discovered
|
||||
# Reticulum instances).
|
||||
$ docker run -d \
|
||||
-v /local/path/nomadnetconfig/:/root/.nomadnetwork/ \
|
||||
-v /local/path/reticulumconfig/:/root/.reticulum/ \
|
||||
-p 37428:37428 \
|
||||
-p 37429:37429 \
|
||||
-v /local/path/nomadnetconfigdir/:/root/.nomadnetwork/ \
|
||||
-v /local/path/reticulumconfigdir/:/root/.reticulum/ \
|
||||
--network host
|
||||
ghcr.io/markqvist/nomadnet:master
|
||||
|
||||
# You can also keep the network of the container isolated from the host, but you
|
||||
# will need to manually configure one or more Reticulum interfaces to reach other
|
||||
# nodes in a network, by editing the Reticulum configuration file.
|
||||
$ docker run -d \
|
||||
-v /local/path/nomadnetconfigdir/:/root/.nomadnetwork/ \
|
||||
-v /local/path/reticulumconfigdir/:/root/.reticulum/ \
|
||||
ghcr.io/markqvist/nomadnet:master
|
||||
|
||||
# Send daemon log output to console instead of file
|
||||
$ docker run -i ghcr.io/markqvist/nomadnet:master --daemon --console
|
||||
```
|
||||
|
||||
## Help & Discussion
|
||||
@@ -88,8 +98,18 @@ For help requests, discussion, sharing ideas or anything else related to Nomad N
|
||||
## Support Nomad Network
|
||||
You can help support the continued development of open, free and private communications systems by donating via one of the following channels:
|
||||
|
||||
- Ethereum: 0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
|
||||
- Bitcoin: 3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
|
||||
- Monero:
|
||||
```
|
||||
84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w
|
||||
```
|
||||
- Ethereum
|
||||
```
|
||||
0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
|
||||
```
|
||||
- Bitcoin
|
||||
```
|
||||
3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
|
||||
```
|
||||
- Ko-Fi: https://ko-fi.com/markqvist
|
||||
|
||||
## Caveat Emptor
|
||||
|
||||
@@ -239,10 +239,11 @@ class Conversation:
|
||||
def __str__(self):
|
||||
string = self.source_hash
|
||||
|
||||
if self.source_identity:
|
||||
if self.source_identity.app_data:
|
||||
# TODO: Sanitise for viewing
|
||||
string += " | "+self.source.source_identity.app_data.decode("utf-8")
|
||||
# TODO: Remove this
|
||||
# if self.source_identity:
|
||||
# if self.source_identity.app_data:
|
||||
# # TODO: Sanitise for viewing, or just clean this
|
||||
# string += " | "+self.source_identity.app_data.decode("utf-8")
|
||||
|
||||
return string
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ class Directory:
|
||||
|
||||
entries = {}
|
||||
for e in unpacked_list:
|
||||
|
||||
if len(e) > 3:
|
||||
hosts_node = e[3]
|
||||
else:
|
||||
@@ -132,7 +133,11 @@ class Directory:
|
||||
return "<"+RNS.hexrep(source_hash, delimit=False)+">"
|
||||
else:
|
||||
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:
|
||||
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):
|
||||
if len(source_hash) == RNS.Identity.TRUNCATED_HASHLENGTH//8:
|
||||
self.source_hash = source_hash
|
||||
|
||||
# TODO: Clean
|
||||
# if display_name == None:
|
||||
# display_name = source_hash
|
||||
|
||||
self.display_name = display_name
|
||||
if display_name == None:
|
||||
display_name = source_hash
|
||||
|
||||
if preferred_delivery == None:
|
||||
self.preferred_delivery = DirectoryEntry.DIRECT
|
||||
|
||||
@@ -2,9 +2,11 @@ import os
|
||||
import io
|
||||
import sys
|
||||
import time
|
||||
import shlex
|
||||
import atexit
|
||||
import threading
|
||||
import traceback
|
||||
import subprocess
|
||||
import contextlib
|
||||
|
||||
import RNS
|
||||
@@ -12,6 +14,7 @@ import LXMF
|
||||
import nomadnet
|
||||
|
||||
from nomadnet.Directory import DirectoryEntry
|
||||
from datetime import datetime
|
||||
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
@@ -32,6 +35,15 @@ class NomadNetworkApp:
|
||||
|
||||
RNS.log("Saving directory...", RNS.LOG_VERBOSE)
|
||||
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)
|
||||
|
||||
def exception_handler(self, e_type, e_value, e_traceback):
|
||||
@@ -46,7 +58,7 @@ class NomadNetworkApp:
|
||||
if issubclass(e_type, KeyboardInterrupt):
|
||||
sys.__excepthook__(e_type, e_value, e_traceback)
|
||||
|
||||
def __init__(self, configdir = None, rnsconfigdir = None, daemon = False):
|
||||
def __init__(self, configdir = None, rnsconfigdir = None, daemon = False, force_console = False):
|
||||
self.version = __version__
|
||||
self.enable_client = False
|
||||
self.enable_node = False
|
||||
@@ -59,6 +71,11 @@ class NomadNetworkApp:
|
||||
else:
|
||||
self.configdir = configdir
|
||||
|
||||
if force_console:
|
||||
self.force_console_log = True
|
||||
else:
|
||||
self.force_console_log = False
|
||||
|
||||
if NomadNetworkApp._shared_instance == None:
|
||||
NomadNetworkApp._shared_instance = self
|
||||
|
||||
@@ -195,6 +212,9 @@ class NomadNetworkApp:
|
||||
"node_last_announce": None,
|
||||
"propagation_node": None,
|
||||
"last_lxmf_sync": 0,
|
||||
"node_connects": 0,
|
||||
"served_page_requests": 0,
|
||||
"served_file_requests": 0
|
||||
}
|
||||
self.save_peer_settings()
|
||||
RNS.log("Created new peer settings file")
|
||||
@@ -246,7 +266,18 @@ class NomadNetworkApp:
|
||||
RNS.log("LXMF Router ready to receive on: "+RNS.prettyhexrep(self.lxmf_destination.hash))
|
||||
|
||||
if self.enable_node:
|
||||
self.message_router.set_message_storage_limit(megabytes=self.message_storage_limit)
|
||||
for dest_str in self.prioritised_lxmf_destinations:
|
||||
try:
|
||||
dest_hash = bytes.fromhex(dest_str)
|
||||
if len(dest_hash) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8:
|
||||
self.message_router.prioritise(dest_hash)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Cannot prioritise "+str(dest_str)+", it is not a valid destination hash", RNS.LOG_ERROR)
|
||||
|
||||
self.message_router.enable_propagation()
|
||||
|
||||
RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
|
||||
self.node = nomadnet.Node(self)
|
||||
else:
|
||||
@@ -344,6 +375,10 @@ class NomadNetworkApp:
|
||||
return "Done, no new messages"
|
||||
else:
|
||||
return "Downloaded "+str(new_msgs)+" new messages"
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_IDENTITY_RCVD:
|
||||
return "Node did not receive identification"
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_ACCESS:
|
||||
return "Node did not allow request"
|
||||
else:
|
||||
return "Unknown"
|
||||
|
||||
@@ -351,13 +386,13 @@ class NomadNetworkApp:
|
||||
if self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_IDLE:
|
||||
return False
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_PATH_REQUESTED:
|
||||
return True
|
||||
return False
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_LINK_ESTABLISHING:
|
||||
return True
|
||||
return False
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_LINK_ESTABLISHED:
|
||||
return True
|
||||
return False
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_REQUEST_SENT:
|
||||
return True
|
||||
return False
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_RECEIVING:
|
||||
return True
|
||||
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_RESPONSE_RECEIVED:
|
||||
@@ -371,7 +406,7 @@ class NomadNetworkApp:
|
||||
return self.message_router.propagation_transfer_progress
|
||||
|
||||
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.peer_settings["last_lxmf_sync"] = time.time()
|
||||
self.save_peer_settings()
|
||||
self.message_router.request_messages_from_propagation_node(self.identity, max_messages = limit)
|
||||
@@ -448,6 +483,69 @@ class NomadNetworkApp:
|
||||
|
||||
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):
|
||||
return nomadnet.Conversation.conversation_list(self)
|
||||
|
||||
@@ -490,7 +588,7 @@ class NomadNetworkApp:
|
||||
if RNS.loglevel > 7:
|
||||
RNS.loglevel = 7
|
||||
if option == "destination":
|
||||
if value.lower() == "file":
|
||||
if value.lower() == "file" and not self.force_console_log:
|
||||
RNS.logdest = RNS.LOG_FILE
|
||||
if "logfile" in self.config["logging"]:
|
||||
self.logfilepath = self.config["logging"]["logfile"]
|
||||
@@ -641,6 +739,68 @@ class NomadNetworkApp:
|
||||
if "files_path" in self.config["node"]:
|
||||
self.filespath = self.config["node"]["files_path"]
|
||||
|
||||
if "prioritise_destinations" in self.config["node"]:
|
||||
self.prioritised_lxmf_destinations = self.config["node"].as_list("prioritise_destinations")
|
||||
else:
|
||||
self.prioritised_lxmf_destinations = []
|
||||
|
||||
if not "message_storage_limit" in self.config["node"]:
|
||||
self.message_storage_limit = 2000
|
||||
else:
|
||||
value = self.config["node"].as_float("message_storage_limit")
|
||||
if value < 0.005:
|
||||
value = 0.005
|
||||
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
|
||||
def get_shared_instance():
|
||||
@@ -751,28 +911,99 @@ editor = editor
|
||||
|
||||
# If you don't want the Guide section to
|
||||
# show up in the menu, you can disable it.
|
||||
|
||||
hide_guide = no
|
||||
|
||||
[node]
|
||||
|
||||
# Whether to enable node hosting
|
||||
|
||||
enable_node = no
|
||||
|
||||
# The node name will be visible to other
|
||||
# peers on the network, and included in
|
||||
# announces.
|
||||
|
||||
node_name = None
|
||||
|
||||
# Automatic announce interval in minutes.
|
||||
# 6 hours by default.
|
||||
|
||||
announce_interval = 360
|
||||
|
||||
# Whether to announce when the node starts
|
||||
|
||||
# Whether to announce when the node starts.
|
||||
announce_at_start = Yes
|
||||
|
||||
# The maximum amount of storage to use for
|
||||
# the LXMF Propagation Node message store,
|
||||
# specified in megabytes. When this limit
|
||||
# is reached, LXMF will periodically remove
|
||||
# messages in its message store. By default,
|
||||
# LXMF prioritises keeping messages that are
|
||||
# new and small. Large and old messages will
|
||||
# be removed first. This setting is optional
|
||||
# and defaults to 2 gigabytes.
|
||||
# message_storage_limit = 2000
|
||||
|
||||
# You can tell the LXMF message router to
|
||||
# prioritise storage for one or more
|
||||
# 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.
|
||||
# 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()
|
||||
|
||||
__printing_template_msg__ = """
|
||||
---------------------------
|
||||
From: {origin}
|
||||
Sent: {stime}
|
||||
Rcvd: {rtime}
|
||||
Title: {mtitle}
|
||||
|
||||
{mbody}
|
||||
---------------------------
|
||||
"""
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.1.8"
|
||||
__version__ = "0.2.1"
|
||||
|
||||
@@ -7,15 +7,22 @@ import argparse
|
||||
import nomadnet
|
||||
|
||||
|
||||
def program_setup(configdir, rnsconfigdir, daemon):
|
||||
app = nomadnet.NomadNetworkApp(configdir = configdir, rnsconfigdir = rnsconfigdir, daemon = daemon)
|
||||
def program_setup(configdir, rnsconfigdir, daemon, console):
|
||||
app = nomadnet.NomadNetworkApp(
|
||||
configdir = configdir,
|
||||
rnsconfigdir = rnsconfigdir,
|
||||
daemon = daemon,
|
||||
force_console = console,
|
||||
)
|
||||
|
||||
def main():
|
||||
try:
|
||||
parser = argparse.ArgumentParser(description="Nomad Network Client")
|
||||
parser.add_argument("--config", action="store", default=None, help="path to alternative Nomad Network config directory", type=str)
|
||||
parser.add_argument("--rnsconfig", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
|
||||
parser.add_argument("-t", "--textui", action="store_true", default=False, help="run Nomad Network in text-UI mode")
|
||||
parser.add_argument("-d", "--daemon", action="store_true", default=False, help="run Nomad Network in daemon mode")
|
||||
parser.add_argument("-c", "--console", action="store_true", default=False, help="in daemon mode, log to console instead of file")
|
||||
parser.add_argument("--version", action="version", version="Nomad Network Client {version}".format(version=__version__))
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -30,7 +37,18 @@ def main():
|
||||
else:
|
||||
rnsconfigarg = None
|
||||
|
||||
program_setup(configarg, rnsconfigarg, args.daemon)
|
||||
console = False
|
||||
if args.daemon:
|
||||
daemon = True
|
||||
if args.console:
|
||||
console = True
|
||||
else:
|
||||
daemon = False
|
||||
|
||||
if args.textui:
|
||||
daemon = False
|
||||
|
||||
program_setup(configarg, rnsconfigarg, daemon, console)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("")
|
||||
|
||||
@@ -10,7 +10,10 @@ class NoneUI:
|
||||
self.app = NomadNetworkApp.get_shared_instance()
|
||||
self.app.ui = self
|
||||
|
||||
if not self.app.force_console_log:
|
||||
RNS.log("Nomad Network started in daemon mode, all further messages are logged to "+str(self.app.logfilepath), RNS.LOG_INFO, _override_destination=True)
|
||||
else:
|
||||
RNS.log("Nomad Network daemon started", RNS.LOG_INFO)
|
||||
|
||||
while True:
|
||||
time.sleep(1)
|
||||
@@ -127,6 +127,21 @@ GLYPHS = {
|
||||
class TextUI:
|
||||
|
||||
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.ui = self
|
||||
self.loop = None
|
||||
@@ -164,7 +179,7 @@ class TextUI:
|
||||
else:
|
||||
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:
|
||||
self.loop.set_alarm_in(intro_timeout, self.display_main)
|
||||
@@ -194,5 +209,9 @@ class TextUI:
|
||||
self.screen.set_terminal_properties(colormode)
|
||||
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):
|
||||
self.loop.widget = self.main_display.widget
|
||||
|
||||
@@ -6,6 +6,7 @@ import nomadnet
|
||||
import subprocess
|
||||
import threading
|
||||
from .MicronParser import markup_to_attrmaps
|
||||
from nomadnet.Directory import DirectoryEntry
|
||||
from nomadnet.vendor.Scrollable import *
|
||||
|
||||
class BrowserFrame(urwid.Frame):
|
||||
@@ -20,6 +21,10 @@ class BrowserFrame(urwid.Frame):
|
||||
self.delegate.reload()
|
||||
elif key == "ctrl u":
|
||||
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":
|
||||
return super(BrowserFrame, self).keypress(size, key)
|
||||
# if key == "up" and self.delegate.messagelist.top_is_visible:
|
||||
@@ -128,7 +133,26 @@ class Browser:
|
||||
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())
|
||||
|
||||
def expand_shorthands(self, destination_type):
|
||||
if destination_type == "nnn":
|
||||
return "nomadnetwork.node"
|
||||
elif destination_type == "lxmf":
|
||||
return "lxmf.delivery"
|
||||
else:
|
||||
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:
|
||||
@@ -137,8 +161,54 @@ class Browser:
|
||||
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 aleady hadling link, cannot handle link to: "+str(link_target), RNS.LOG_DEBUG)
|
||||
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):
|
||||
@@ -279,7 +349,7 @@ class Browser:
|
||||
|
||||
components = url.split(":")
|
||||
if len(components) == 1:
|
||||
if len(components[0]) == 20:
|
||||
if len(components[0]) == (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
|
||||
try:
|
||||
destination_hash = bytes.fromhex(components[0])
|
||||
except Exception as e:
|
||||
@@ -288,7 +358,7 @@ class Browser:
|
||||
else:
|
||||
raise ValueError("Malformed URL")
|
||||
elif len(components) == 2:
|
||||
if len(components[0]) == 20:
|
||||
if len(components[0]) == (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
|
||||
try:
|
||||
destination_hash = bytes.fromhex(components[0])
|
||||
except Exception as e:
|
||||
@@ -481,7 +551,12 @@ class Browser:
|
||||
self.close_dialogs()
|
||||
|
||||
def confirmed(sender):
|
||||
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()
|
||||
|
||||
dialog = UrlDialogLineBox(
|
||||
@@ -501,6 +576,40 @@ class Browser:
|
||||
self.delegate.columns.contents[1] = (overlay, options)
|
||||
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):
|
||||
cached = self.get_cached(self.current_url())
|
||||
|
||||
@@ -14,7 +14,7 @@ class ConversationListDisplayShortcuts():
|
||||
def __init__(self, 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():
|
||||
def __init__(self, app):
|
||||
@@ -32,6 +32,8 @@ class ConversationsArea(urwid.LineBox):
|
||||
self.delegate.new_conversation()
|
||||
elif key == "ctrl r":
|
||||
self.delegate.sync_conversations()
|
||||
elif key == "ctrl g":
|
||||
self.delegate.toggle_fullscreen()
|
||||
elif key == "tab":
|
||||
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()):
|
||||
@@ -48,6 +50,7 @@ class DialogLineBox(urwid.LineBox):
|
||||
|
||||
class ConversationsDisplay():
|
||||
list_width = 0.33
|
||||
given_list_width = 52
|
||||
cached_conversation_widgets = {}
|
||||
|
||||
def __init__(self, app):
|
||||
@@ -64,8 +67,10 @@ class ConversationsDisplay():
|
||||
|
||||
self.columns_widget = urwid.Columns(
|
||||
[
|
||||
("weight", ConversationsDisplay.list_width, self.listbox),
|
||||
("weight", 1-ConversationsDisplay.list_width, self.make_conversation_widget(None))
|
||||
# ("weight", ConversationsDisplay.list_width, self.listbox),
|
||||
# ("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]
|
||||
)
|
||||
@@ -126,7 +131,8 @@ class ConversationsDisplay():
|
||||
|
||||
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)
|
||||
|
||||
def edit_selected_in_directory(self):
|
||||
@@ -226,7 +232,7 @@ class ConversationsDisplay():
|
||||
(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)
|
||||
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([
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
def delete_conversation(self, source_hash):
|
||||
@@ -326,6 +334,15 @@ class ConversationsDisplay():
|
||||
conversation = ConversationsDisplay.cached_conversation_widgets[source_hash]
|
||||
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):
|
||||
g = self.app.ui.glyphs
|
||||
self.dialog_open = True
|
||||
@@ -334,7 +351,7 @@ class ConversationsDisplay():
|
||||
self.dialog_open = False
|
||||
self.sync_dialog = None
|
||||
self.update_conversation_list()
|
||||
if self.app.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE:
|
||||
if self.app.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
|
||||
self.app.cancel_lxmf_sync()
|
||||
|
||||
max_messages_group = []
|
||||
@@ -360,7 +377,7 @@ class ConversationsDisplay():
|
||||
real_sync_button = urwid.Button("Sync Now", on_press=sync_now)
|
||||
hidden_sync_button = urwid.Button("Cancel Sync", on_press=cancel_sync)
|
||||
|
||||
if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE:
|
||||
if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
|
||||
sync_button = real_sync_button
|
||||
else:
|
||||
sync_button = hidden_sync_button
|
||||
@@ -398,7 +415,8 @@ class ConversationsDisplay():
|
||||
dialog = DialogLineBox(
|
||||
urwid.Pile([
|
||||
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(""),
|
||||
button_columns
|
||||
]), title="Message Sync"
|
||||
@@ -416,14 +434,15 @@ class ConversationsDisplay():
|
||||
|
||||
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)
|
||||
|
||||
def update_sync_dialog(self, loop = None, sender = None):
|
||||
if self.dialog_open and self.sync_dialog != None:
|
||||
self.sync_dialog.sync_progress.set_completion(self.app.get_sync_progress())
|
||||
|
||||
if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE:
|
||||
if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
|
||||
self.sync_dialog.bc.contents[0] = (self.sync_dialog.real_sync_button, self.sync_dialog.bc.options("weight", 0.45))
|
||||
else:
|
||||
self.sync_dialog.bc.contents[0] = (self.sync_dialog.hidden_sync_button, self.sync_dialog.bc.options("weight", 0.45))
|
||||
@@ -437,7 +456,8 @@ class ConversationsDisplay():
|
||||
def update_conversation_list(self):
|
||||
ilb_position = self.ilb.get_selected_position()
|
||||
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):
|
||||
self.columns_widget.contents[0] = (self.listbox, options)
|
||||
else:
|
||||
@@ -468,7 +488,8 @@ class ConversationsDisplay():
|
||||
self.app.mark_conversation_read(self.currently_displayed_conversation)
|
||||
|
||||
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)
|
||||
if source_hash == None:
|
||||
self.widget.set_focus_column(0)
|
||||
@@ -753,7 +774,7 @@ class ConversationWidget(urwid.WidgetWrap):
|
||||
if allowed:
|
||||
self.frame.contents["footer"] = (self.minimal_editor, None)
|
||||
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)
|
||||
|
||||
def toggle_focus_area(self):
|
||||
@@ -780,6 +801,8 @@ class ConversationWidget(urwid.WidgetWrap):
|
||||
self.toggle_editor()
|
||||
elif key == "ctrl x":
|
||||
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":
|
||||
self.sort_by_timestamp ^= True
|
||||
self.conversation_changed(None)
|
||||
|
||||
@@ -17,45 +17,3 @@ class IntroDisplay():
|
||||
|
||||
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')
|
||||
@@ -111,6 +111,7 @@ class TopicList(urwid.WidgetWrap):
|
||||
GuideEntry(self.app, self, guide_display, "Concepts & Terminology"),
|
||||
GuideEntry(self.app, self, guide_display, "Hosting a Node"),
|
||||
GuideEntry(self.app, self, guide_display, "Configuration Options"),
|
||||
GuideEntry(self.app, self, guide_display, "Keyboard Shortcuts"),
|
||||
GuideEntry(self.app, self, guide_display, "Markup"),
|
||||
self.first_run_entry,
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
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.
|
||||
|
||||
@@ -514,12 +557,12 @@ What color theme to use. Set it to match your terminal theme. Can be either `!da
|
||||
|
||||
>> Node Section
|
||||
|
||||
This section holds configuration directives related to the node hosting. It is delimited by the `![node]`! header in the configuration file. Available directives, along with their default values, are as follows:
|
||||
This section holds configuration directives related to the node hosting. It is delimited by the `![node]`! header in the configuration file. Available directives, along with example values, are as follows:
|
||||
|
||||
>>>
|
||||
`!enable_node = yes`!
|
||||
`!enable_node = no`!
|
||||
>>>>
|
||||
Determines whether the node server should be started on launch. Must be a boolean value.
|
||||
Determines whether the node server should be started on launch. Must be a boolean value, and is turned off by default.
|
||||
<
|
||||
|
||||
>>>
|
||||
@@ -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.
|
||||
<
|
||||
|
||||
>>>
|
||||
@@ -552,9 +595,49 @@ Determines where the node server will look for hosted pages. Must be a readable
|
||||
Determines where the node server will look for downloadable files. Must be a readable filesystem path.
|
||||
<
|
||||
|
||||
>>>
|
||||
`!message_storage_limit = 2000`!
|
||||
>>>>
|
||||
Configures the maximum amount of storage, in megabytes, that the LXMF Propagation Node will use to store messages.
|
||||
<
|
||||
|
||||
>>>
|
||||
`!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.
|
||||
<
|
||||
|
||||
>> 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
|
||||
|
||||
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
|
||||
@@ -694,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.
|
||||
|
||||
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
|
||||
|
||||
@@ -874,11 +957,11 @@ Here's a few examples:
|
||||
|
||||
`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
|
||||
`=
|
||||
``
|
||||
|
||||
@@ -886,11 +969,11 @@ The above markup produces the following output:
|
||||
|
||||
`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
|
||||
|
||||
``
|
||||
|
||||
@@ -937,6 +1020,7 @@ TOPICS = {
|
||||
"Conversations": TOPIC_CONVERSATIONS,
|
||||
"Hosting a Node": TOPIC_HOSTING,
|
||||
"Configuration Options": TOPIC_CONFIG,
|
||||
"Keyboard Shortcuts": TOPIC_SHORTCUTS,
|
||||
"Markup": TOPIC_MARKUP,
|
||||
"Display Test": TOPIC_DISPLAYTEST,
|
||||
"Network Configuration": TOPIC_NETWORKS,
|
||||
|
||||
@@ -13,7 +13,7 @@ class NetworkDisplayShortcuts():
|
||||
self.app = app
|
||||
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"
|
||||
|
||||
|
||||
@@ -51,6 +51,13 @@ class ListEntry(urwid.Text):
|
||||
|
||||
|
||||
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):
|
||||
self.app = nomadnet.NomadNetworkApp.get_shared_instance()
|
||||
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)
|
||||
|
||||
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):
|
||||
self.app = nomadnet.NomadNetworkApp.get_shared_instance()
|
||||
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)+">"
|
||||
|
||||
if display_str == None:
|
||||
display_str = addr_str
|
||||
|
||||
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))
|
||||
else:
|
||||
@@ -568,6 +585,10 @@ class KnownNodeInfo(urwid.WidgetWrap):
|
||||
|
||||
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")
|
||||
|
||||
urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Node Info"))
|
||||
@@ -837,7 +858,7 @@ class NodeActiveConnections(urwid.WidgetWrap):
|
||||
if self.app.node != None:
|
||||
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):
|
||||
self.update_stat()
|
||||
@@ -853,6 +874,48 @@ class NodeActiveConnections(urwid.WidgetWrap):
|
||||
def stop(self):
|
||||
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):
|
||||
def __init__(self, app):
|
||||
@@ -869,7 +932,7 @@ class NodeTotalConnections(urwid.WidgetWrap):
|
||||
if self.app.node != None:
|
||||
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):
|
||||
self.update_stat()
|
||||
@@ -1050,6 +1113,7 @@ class NodeInfo(urwid.WidgetWrap):
|
||||
conns_timer = None
|
||||
pages_timer = None
|
||||
files_timer = None
|
||||
storage_timer = None
|
||||
|
||||
def __init__(self, app, parent):
|
||||
self.app = app
|
||||
@@ -1123,6 +1187,13 @@ class NodeInfo(urwid.WidgetWrap):
|
||||
self.t_active_links = NodeInfo.links_timer
|
||||
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_storage_stats = NodeInfo.storage_timer
|
||||
self.t_storage_stats.update_stat()
|
||||
|
||||
if NodeInfo.conns_timer == None:
|
||||
self.t_total_connections = NodeTotalConnections(self.app)
|
||||
NodeInfo.conns_timer = self.t_total_connections
|
||||
@@ -1158,6 +1229,7 @@ class NodeInfo(urwid.WidgetWrap):
|
||||
e_lxmf,
|
||||
urwid.Divider(g["divider1"]),
|
||||
self.t_last_announce,
|
||||
self.t_storage_stats,
|
||||
self.t_active_links,
|
||||
self.t_total_connections,
|
||||
self.t_total_pages,
|
||||
@@ -1257,6 +1329,10 @@ class NetworkLeftPile(urwid.Pile):
|
||||
def keypress(self, size, key):
|
||||
if key == "ctrl l":
|
||||
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":
|
||||
self.parent.reinit_lxmf_peers()
|
||||
self.parent.show_peers()
|
||||
@@ -1264,12 +1340,16 @@ class NetworkLeftPile(urwid.Pile):
|
||||
self.parent.browser.disconnect()
|
||||
elif key == "ctrl u":
|
||||
self.parent.browser.url_dialog()
|
||||
elif key == "ctrl s":
|
||||
self.parent.browser.save_node_dialog()
|
||||
|
||||
else:
|
||||
return super(NetworkLeftPile, self).keypress(size, key)
|
||||
|
||||
|
||||
class NetworkDisplay():
|
||||
list_width = 0.33
|
||||
given_list_width = 52
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
@@ -1304,8 +1384,10 @@ class NetworkDisplay():
|
||||
|
||||
self.columns = urwid.Columns(
|
||||
[
|
||||
("weight", NetworkDisplay.list_width, self.left_area),
|
||||
("weight", self.right_area_width, self.right_area)
|
||||
# ("weight", NetworkDisplay.list_width, self.left_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
|
||||
)
|
||||
@@ -1323,6 +1405,16 @@ class NetworkDisplay():
|
||||
self.left_pile.contents[0] = (self.known_nodes_display, options)
|
||||
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):
|
||||
options = self.left_pile.options(height_type="weight", height_amount=1)
|
||||
self.left_pile.contents[0] = (self.lxmf_peers_display, options)
|
||||
@@ -1332,6 +1424,18 @@ class NetworkDisplay():
|
||||
else:
|
||||
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):
|
||||
self.columns.focus_position = 0
|
||||
|
||||
@@ -1464,7 +1568,7 @@ class LXMFPeerEntry(urwid.WidgetWrap):
|
||||
style = "list_unknown"
|
||||
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)
|
||||
|
||||
self.display_widget = urwid.AttrMap(widget, style, focus_style)
|
||||
|
||||
Reference in New Issue
Block a user