From f51f781c3bfbb782509239f7a8801b8345f234fe Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Sun, 15 Oct 2023 09:55:09 +1300 Subject: [PATCH] implement sigchat chat menu items [register, link, close] --- apps/sigchat/README.md | 2 ++ apps/sigchat/locales/i18n.json | 11 +++++++++++ apps/sigchat/src/main.rs | 28 ++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/apps/sigchat/README.md b/apps/sigchat/README.md index e625e07d4..41f2d0e52 100644 --- a/apps/sigchat/README.md +++ b/apps/sigchat/README.md @@ -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 diff --git a/apps/sigchat/locales/i18n.json b/apps/sigchat/locales/i18n.json index bb74ec45c..638ec62f4 100644 --- a/apps/sigchat/locales/i18n.json +++ b/apps/sigchat/locales/i18n.json @@ -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", diff --git a/apps/sigchat/src/main.rs b/apps/sigchat/src/main.rs index fe619419c..197cd3988 100644 --- a/apps/sigchat/src/main.rs +++ b/apps/sigchat/src/main.rs @@ -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(), _ => (), } });