Initial RRC protocol support and Channels functionality

This commit is contained in:
zenith 2026-05-11 00:51:26 -04:00
parent 19e5563060
commit e17d9a8cea
7 changed files with 3084 additions and 3 deletions

View file

@ -59,6 +59,13 @@ THEMES = {
("placeholder", "dark gray", "default", "default", "dark gray", "default"),
("placeholder_text", "dark gray", "default", "default", "dark gray", "default"),
("error", "light red,blink", "default", "blink", "#f44,blink", "default"),
("irc_ts", "dark gray", "default", "default", "#888", "default"),
("irc_nick_self", "light green", "default", "default", "#6c5", "default"),
("irc_nick_peer", "light cyan", "default", "default", "#3cd", "default"),
("irc_notice", "yellow", "default", "default", "#fd3", "default"),
("irc_error", "light red", "default", "default", "#f55", "default"),
("irc_system", "dark gray", "default", "default", "#888", "default"),
("irc_mention", "light red,bold", "default", "bold", "#fb4,bold", "default"),
],
},
@ -103,7 +110,14 @@ THEMES = {
("placeholder", "light gray", "default", "default", "#999", "default"),
("placeholder_text", "light gray", "default", "default", "#999", "default"),
("error", "dark red,blink", "default", "blink", "#a22,blink", "default"),
],
("irc_ts", "dark gray", "default", "default", "#888", "default"),
("irc_nick_self", "dark green", "default", "default", "#3a0", "default"),
("irc_nick_peer", "dark cyan", "default", "default", "#077", "default"),
("irc_notice", "brown", "default", "default", "#a70", "default"),
("irc_error", "dark red", "default", "default", "#a22", "default"),
("irc_system", "dark gray", "default", "default", "#888", "default"),
("irc_mention", "dark red,bold", "default", "bold", "#c50,bold", "default"),
],
}
}

View file

@ -192,6 +192,8 @@ class Browser:
return "nomadnetwork.node"
elif destination_type == "lxmf":
return "lxmf.delivery"
elif destination_type == "rrc":
return "rrc.hub.session"
else:
return destination_type
@ -250,6 +252,11 @@ class Browser:
recurse_down(self.attr_maps)
RNS.log("Including request data: "+str(request_data), RNS.LOG_DEBUG)
# rrc://<hex>[:<dest_name>]/<room> URL form
if link_target.startswith("rrc://"):
self.handle_rrc_link(link_target[6:])
return
components = link_target.split("@")
destination_type = None
@ -280,6 +287,10 @@ class Browser:
RNS.log("Passing LXMF link to handler", RNS.LOG_DEBUG)
self.handle_lxmf_link(link_target)
elif destination_type == "rrc.hub.session":
RNS.log("Passing RRC link to handler", RNS.LOG_DEBUG)
self.handle_rrc_link(link_target)
elif destination_type == "partial":
if partial_ids != None and len(partial_ids) > 0: self.handle_partial_updates(partial_ids)
@ -331,6 +342,56 @@ class Browser:
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
def handle_rrc_link(self, link_target):
try:
if not isinstance(link_target, str):
raise ValueError("invalid RRC link payload")
rest = link_target.strip()
if rest.startswith("/"):
rest = rest[1:]
hub_part, _, room = rest.partition("/")
hex_part, _, dest = hub_part.partition(":")
hex_part = hex_part.strip()
dest = dest.strip() or None
try:
hub_hash = bytes.fromhex(hex_part)
except Exception:
raise ValueError("invalid hub hash")
expected_len = RNS.Reticulum.TRUNCATED_HASHLENGTH // 8
if len(hub_hash) != expected_len:
raise ValueError("hub hash must be "+str(expected_len)+" bytes")
room = room.strip().lstrip("#").strip()
room_norm = None
if room:
try:
# validate the room name early; pass the raw value through
from nomadnet.RRC import RRCHub as _RRCHubCls # noqa
room_norm = room.lower()
except Exception:
room_norm = None
existing = self.app.rrc.find_hub(hub_hash, dest_name=dest)
self.app.ui.main_display.show_channels(None)
channels = self.app.ui.main_display.sub_displays.channels_display
if existing is not None:
channels.update_list()
if room_norm:
channels._select_room(None, (existing, room_norm))
else:
channels._select_hub(None, existing)
return
channels.confirm_new_hub_dialog(hub_hash, dest, room_norm)
except Exception as e:
RNS.log("Could not open RRC link: "+str(e), RNS.LOG_ERROR)
self.browser_footer = urwid.Text("Could not open RRC link: "+str(e))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
def micron_released_focus(self):
if self.delegate != None:
self.delegate.focus_lists()

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@ import RNS
from .Network import *
from .Conversations import *
from .Channels import *
from .Directory import *
from .Config import *
from .Interfaces import *
@ -15,6 +16,7 @@ class SubDisplays():
self.app = app
self.network_display = NetworkDisplay(self.app)
self.conversations_display = ConversationsDisplay(self.app)
self.channels_display = ChannelsDisplay(self.app)
self.directory_display = DirectoryDisplay(self.app)
self.config_display = ConfigDisplay(self.app)
self.interface_display = InterfaceDisplay(self.app)
@ -103,6 +105,11 @@ class MainDisplay():
self.sub_displays.active_display = self.sub_displays.conversations_display
self.update_active_sub_display()
def show_channels(self, user_data):
self.sub_displays.active_display = self.sub_displays.channels_display
self.update_active_sub_display()
self.sub_displays.channels_display.start()
def show_directory(self, user_data):
self.sub_displays.active_display = self.sub_displays.directory_display
self.update_active_sub_display()
@ -181,6 +188,7 @@ class MenuDisplay():
menu_text = (urwid.PACK, self.menu_indicator)
button_network = (11, MenuButton("Network", on_press=handler.show_network))
button_conversations = (17, MenuButton("Conversations", on_press=handler.show_conversations))
button_channels = (12, MenuButton("Channels", on_press=handler.show_channels))
button_directory = (13, MenuButton("Directory", on_press=handler.show_directory))
button_map = (7, MenuButton("Map", on_press=handler.show_map))
button_log = (7, MenuButton("Log", on_press=handler.show_log))
@ -191,9 +199,9 @@ class MenuDisplay():
# buttons = [menu_text, button_conversations, button_node, button_directory, button_map]
if self.app.config["textui"]["hide_guide"]:
buttons = [menu_text, button_conversations, button_network, button_log, button_interfaces, button_config, button_quit]
buttons = [menu_text, button_conversations, button_network, button_channels, button_log, button_interfaces, button_config, button_quit]
else:
buttons = [menu_text, button_conversations, button_network, button_log, button_interfaces, button_config, button_guide, button_quit]
buttons = [menu_text, button_conversations, button_network, button_channels, button_log, button_interfaces, button_config, button_guide, button_quit]
columns = MenuColumns(buttons, dividechars=1)
columns.handler = handler