Improved announce details display
This commit is contained in:
parent
33d1b7c90d
commit
597f8a28a2
|
@ -110,11 +110,12 @@ class SidebandCore():
|
||||||
# This reformats the new v0.5.0 announce data back to the expected format
|
# This reformats the new v0.5.0 announce data back to the expected format
|
||||||
# for Sidebands database and other handling functions.
|
# for Sidebands database and other handling functions.
|
||||||
dn = LXMF.display_name_from_app_data(app_data)
|
dn = LXMF.display_name_from_app_data(app_data)
|
||||||
|
sc = LXMF.stamp_cost_from_app_data(app_data)
|
||||||
app_data = b""
|
app_data = b""
|
||||||
if dn != None:
|
if dn != None:
|
||||||
app_data = dn.encode("utf-8")
|
app_data = dn.encode("utf-8")
|
||||||
|
|
||||||
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter)
|
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter, stamp_cost=sc)
|
||||||
|
|
||||||
def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False):
|
def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False):
|
||||||
self.is_service = is_service
|
self.is_service = is_service
|
||||||
|
@ -891,11 +892,12 @@ class SidebandCore():
|
||||||
else:
|
else:
|
||||||
plyer.notification.notify(title, content, app_icon=self.icon_32)
|
plyer.notification.notify(title, content, app_icon=self.icon_32)
|
||||||
|
|
||||||
def log_announce(self, dest, app_data, dest_type):
|
def log_announce(self, dest, app_data, dest_type, stamp_cost=None):
|
||||||
try:
|
try:
|
||||||
if app_data == None:
|
if app_data == None:
|
||||||
app_data = b""
|
app_data = b""
|
||||||
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+app_data.decode("utf-8"), RNS.LOG_DEBUG)
|
app_data = msgpack.packb([app_data, stamp_cost])
|
||||||
|
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+str(app_data), RNS.LOG_DEBUG)
|
||||||
self._db_save_announce(dest, app_data, dest_type)
|
self._db_save_announce(dest, app_data, dest_type)
|
||||||
self.setstate("app.flags.new_announces", True)
|
self.setstate("app.flags.new_announces", True)
|
||||||
|
|
||||||
|
@ -1090,9 +1092,11 @@ class SidebandCore():
|
||||||
else:
|
else:
|
||||||
app_data = RNS.Identity.recall_app_data(context_dest)
|
app_data = RNS.Identity.recall_app_data(context_dest)
|
||||||
if app_data != None:
|
if app_data != None:
|
||||||
return LXMF.display_name_from_app_data(app_data)+" "+RNS.prettyhexrep(context_dest)
|
name_str = LXMF.display_name_from_app_data(app_data)
|
||||||
|
addr_str = RNS.prettyhexrep(context_dest)
|
||||||
|
return name_str+" "+addr_str
|
||||||
else:
|
else:
|
||||||
return RNS.prettyhexrep(context_dest)
|
return "Anonymous Peer "+RNS.prettyhexrep(context_dest)
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -2268,9 +2272,11 @@ class SidebandCore():
|
||||||
for entry in result:
|
for entry in result:
|
||||||
try:
|
try:
|
||||||
if not entry[2] in added_dests:
|
if not entry[2] in added_dests:
|
||||||
|
app_data = entry[3]
|
||||||
announce = {
|
announce = {
|
||||||
"dest": entry[2],
|
"dest": entry[2],
|
||||||
"data": entry[3].decode("utf-8"),
|
"name": LXMF.display_name_from_app_data(app_data),
|
||||||
|
"cost": LXMF.stamp_cost_from_app_data(app_data),
|
||||||
"time": entry[1],
|
"time": entry[1],
|
||||||
"type": entry[4]
|
"type": entry[4]
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,8 @@ class Announces():
|
||||||
for announce in self.announces:
|
for announce in self.announces:
|
||||||
context_dest = announce["dest"]
|
context_dest = announce["dest"]
|
||||||
ts = announce["time"]
|
ts = announce["time"]
|
||||||
a_data = announce["data"]
|
a_name = announce["name"]
|
||||||
|
a_cost = announce["cost"]
|
||||||
dest_type = announce["type"]
|
dest_type = announce["type"]
|
||||||
|
|
||||||
if not context_dest in self.added_item_dests:
|
if not context_dest in self.added_item_dests:
|
||||||
|
@ -98,15 +99,16 @@ class Announces():
|
||||||
else:
|
else:
|
||||||
trust_icon = "account-question"
|
trust_icon = "account-question"
|
||||||
|
|
||||||
def gen_info(ts, dest, name, dtype):
|
def gen_info(ts, dest, name, cost, dtype):
|
||||||
name = multilingual_markup(escape_markup(str(name)).encode("utf-8")).decode("utf-8")
|
name = multilingual_markup(escape_markup(str(name)).encode("utf-8")).decode("utf-8")
|
||||||
|
cost = str(cost)
|
||||||
def x(sender):
|
def x(sender):
|
||||||
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
|
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
|
||||||
if dtype == "lxmf.delivery":
|
if dtype == "lxmf.delivery":
|
||||||
ad_text = "[size=22dp]LXMF Peer[/size]\n\nReceived: "+ts+"\nAnnounced Name: "+name+"\nAddress: "+RNS.prettyhexrep(dest)
|
ad_text = "[size=22dp]LXMF Peer[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)+"\n[b]Name[/b] "+name+"\n[b]Stamp Cost[/b] "+cost
|
||||||
|
|
||||||
if dtype == "lxmf.propagation":
|
if dtype == "lxmf.propagation":
|
||||||
ad_text = "[size=22dp]LXMF Propagation Node[/size]\n\nReceived: "+ts+"\nAddress: "+RNS.prettyhexrep(dest)
|
ad_text = "[size=22dp]LXMF Propagation Node[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)
|
||||||
|
|
||||||
dialog = MDDialog(
|
dialog = MDDialog(
|
||||||
text=ad_text,
|
text=ad_text,
|
||||||
|
@ -135,7 +137,7 @@ class Announces():
|
||||||
disp_name = "Unknown Announce"
|
disp_name = "Unknown Announce"
|
||||||
iconl = IconLeftWidget(icon="progress-question")
|
iconl = IconLeftWidget(icon="progress-question")
|
||||||
|
|
||||||
item = TwoLineAvatarIconListItem(text=time_string, secondary_text=disp_name, on_release=gen_info(time_string, context_dest, a_data, dest_type))
|
item = TwoLineAvatarIconListItem(text=time_string, secondary_text=disp_name, on_release=gen_info(time_string, context_dest, a_name, a_cost, dest_type))
|
||||||
item.add_widget(iconl)
|
item.add_widget(iconl)
|
||||||
item.sb_uid = context_dest
|
item.sb_uid = context_dest
|
||||||
item.ts = ts
|
item.ts = ts
|
||||||
|
|
Loading…
Reference in New Issue