implement sigchat chat menu items [register, link, close]

This commit is contained in:
nworbnhoj 2023-10-15 09:55:09 +13:00
parent 7b26c04fb0
commit f51f781c3b
3 changed files with 39 additions and 2 deletions

View file

@ -30,6 +30,8 @@ The `sigchat` code is primarily concerned with the Signal specific protocols, wh
The Chat library provides the UI to display a series of Signal post (Posts) in a Signal group (Dialogue) stored in the pddb. Each Dialogue is stored in the `pddb:dict` `sigchat.dialogue` under a descriptive `pddb:key` (ie ``).
`sigchat` passes a menu to the Chat UI:
* `register` to register a new Signal account with a phone number
* `link` this device to an existing Signal account.
The `sigchat` servers is set to receive:
* `SigchatOp::Post` A memory msg containing an outbount user post

View file

@ -15,6 +15,17 @@
"en": "Setup Signal on this device.",
"en-tts": "Setup Signal on this device."
},
"sigchat.menu.close": {
"en": "Close menu",
"en-tts": "Close menu"
},
"sigchat.register": {
"en": "Register",
"en-tts": "Register"
},
"sigchat.link": {
"en": "Link",
"en-tts": "Link"
},
"sigchat.number": {
"en": "Number",

View file

@ -61,6 +61,30 @@ fn wrapped_main() -> ! {
);
let cid = xous::connect(sid).unwrap();
chat.menu_add(MenuItem {
name: xous_ipc::String::from_str(t!("sigchat.register", locales::LANG)),
action_conn: Some(cid),
action_opcode: SigchatOp::Menu as u32,
action_payload: MenuPayload::Scalar([MenuOp::Register as u32, 0, 0, 0]),
close_on_select: true,
})
.expect("failed add menu");
chat.menu_add(MenuItem {
name: xous_ipc::String::from_str(t!("sigchat.link", locales::LANG)),
action_conn: Some(cid),
action_opcode: SigchatOp::Menu as u32,
action_payload: MenuPayload::Scalar([MenuOp::Link as u32, 0, 0, 0]),
close_on_select: true,
})
.expect("failed add menu");
chat.menu_add(MenuItem {
name: xous_ipc::String::from_str(t!("sigchat.menu.close", locales::LANG)),
action_conn: Some(cid),
action_opcode: SigchatOp::Menu as u32,
action_payload: MenuPayload::Scalar([MenuOp::Noop as u32, 0, 0, 0]),
close_on_select: true,
})
.expect("failed add menu");
let mut sigchat = SigChat::new(&chat);
let mut first_focus = true;
@ -88,9 +112,9 @@ fn wrapped_main() -> ! {
log::info!("got Chat Menu Click");
xous::msg_scalar_unpack!(msg, menu_code, _, _, _, {
match FromPrimitive::from_usize(menu_code) {
Some(MenuOp::Link) => {}
Some(MenuOp::Link) => sigchat.account_link(),
Some(MenuOp::Noop) => {}
Some(MenuOp::Register) => {}
Some(MenuOp::Register) => sigchat.account_register(),
_ => (),
}
});