aboutsummaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
authordesvox <ofunknowndescent@gmail.com>2018-08-04 08:21:01 -0500
committerdesvox <ofunknowndescent@gmail.com>2018-08-04 08:21:01 -0500
commitbe24ae9dc234e47a632444c7e1c5bbf6c31be09f (patch)
tree5365f91f6ec5c14874943bab0e7b6952709476f7 /clients
parent504ee3fc048c06a9e69c2e32d9fd76c74b060f3d (diff)
downloadbbj-be24ae9dc234e47a632444c7e1c5bbf6c31be09f.tar.gz
Allow server to share configuration info with clients.
Diffstat (limited to 'clients')
-rw-r--r--clients/network_client.py14
-rw-r--r--clients/urwid/main.py23
2 files changed, 26 insertions, 11 deletions
diff --git a/clients/network_client.py b/clients/network_client.py
index 87f870e..c45ef8b 100644
--- a/clients/network_client.py
+++ b/clients/network_client.py
@@ -76,6 +76,7 @@ class BBJ(object):
self.send_auth = True
try:
self.user = self("get_me")["data"]
+ self.update_instance_info()
except URLError:
raise URLError("Cannot connect to %s (is the server down?)" % self.base[0:-2])
@@ -178,6 +179,19 @@ class BBJ(object):
raise e
+ def update_instance_info(self):
+ """
+ Stores configuration info for the connected BBJ server.
+
+ {
+ "instance_name": (string), // a title set by the server owner
+ "allow_anon": (bool) // whether anonymous participation is allowed
+ }
+ """
+ response = self("instance_info")
+ self.instance_info = response["data"]
+
+
def validate(self, key, value, exception=AssertionError):
"""
Uses the server's db_validate method to verify the validty
diff --git a/clients/urwid/main.py b/clients/urwid/main.py
index db3c82b..8e1fec8 100644
--- a/clients/urwid/main.py
+++ b/clients/urwid/main.py
@@ -218,7 +218,8 @@ default_prefs = {
"dramatic_exit": True,
"date": "%Y/%m/%d",
"time": "%H:%M",
- "frame_title": "> > T I L D E T O W N < <",
+ "frame_title": "BBJ",
+ "use_custom_frame_title": False,
"max_text_width": 80,
"confirm_anon": True,
"edit_escapes": {
@@ -278,31 +279,31 @@ pinpath = os.path.join(os.getenv("HOME"), ".bbjpins")
class App(object):
def __init__(self):
self.prefs = bbjrc("load")
-
- self.mode = None
- self.thread = None
- self.usermap = {}
- self.window_split = False
- self.last_index_pos = None
- self.last_alarm = None
self.client_pinned_threads = load_client_pins()
+ self.usermap = {}
self.match_data = {
"query": "",
"matches": [],
"position": 0,
}
- # these can be changed and manipulated by other methods
+ self.mode = None
+ self.thread = None
+ self.window_split = False
+ self.last_index_pos = None
+ self.last_alarm = None
+
self.walker = urwid.SimpleFocusListWalker([])
self.box = ActionBox(self.walker)
self.body = urwid.AttrMap(
urwid.LineBox(
self.box,
- title=self.prefs["frame_title"],
+ title=self.prefs["frame_title"]
+ if self.prefs["use_custom_frame_title"]
+ else network.instance_info["instance_name"],
**frame_theme()),
"default"
)
-
self.loop = urwid.MainLoop(
urwid.Frame(self.body),
palette=colormap,
Un proyecto texto-plano.xyz