mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add basic submenu support to vault app
This commit is contained in:
parent
551258b18d
commit
37b2ee444d
4 changed files with 118 additions and 6 deletions
|
|
@ -136,5 +136,29 @@
|
|||
"ja": "FIDOリクエスト",
|
||||
"zh": "FIDO 请求",
|
||||
"en-tts": "FIDO Request"
|
||||
},
|
||||
"vault.menu_autotype": {
|
||||
"en": "Autotype",
|
||||
"ja": "自動的に入力",
|
||||
"zh": "自动输入",
|
||||
"en-tts": "Autotype"
|
||||
},
|
||||
"vault.menu_edit": {
|
||||
"en": "Edit item",
|
||||
"ja": "アイテムを編集する",
|
||||
"zh": "编辑项目",
|
||||
"en-tts": "Edit item"
|
||||
},
|
||||
"vault.menu_delete": {
|
||||
"en": "Delete item",
|
||||
"ja": "アイテムを削除",
|
||||
"zh": "删除项目",
|
||||
"en-tts": "Delete item"
|
||||
},
|
||||
"vault.menu_close": {
|
||||
"en": "Close submenu",
|
||||
"ja": "メニューを閉じる",
|
||||
"zh": "关闭功能表",
|
||||
"en-tts": "Close submenu"
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ use ctap::CtapState;
|
|||
mod shims;
|
||||
use shims::*;
|
||||
mod icontray;
|
||||
mod submenu;
|
||||
|
||||
// CTAP2 testing notes:
|
||||
// run our branch and use this to forward the prompts on to the device:
|
||||
|
|
@ -73,6 +74,12 @@ pub(crate) enum VaultOp {
|
|||
Redraw,
|
||||
/// change focus
|
||||
ChangeFocus,
|
||||
|
||||
/// Menu items
|
||||
MenuAutotype,
|
||||
MenuEdit,
|
||||
MenuDelete,
|
||||
|
||||
/// exit the application
|
||||
Quit,
|
||||
}
|
||||
|
|
@ -144,6 +151,10 @@ fn main() -> ! {
|
|||
}
|
||||
});
|
||||
|
||||
let conn = xous::connect(sid).unwrap();
|
||||
let menu_sid = xous::create_server().unwrap();
|
||||
let menu_mgr = submenu::create_submenu(conn, menu_sid);
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let mut repl = Repl::new(&xns, sid);
|
||||
let mut update_repl = true;
|
||||
|
|
@ -156,9 +167,36 @@ fn main() -> ! {
|
|||
Some(VaultOp::Line) => {
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let s = buffer.as_flat::<xous_ipc::String<4000>, _>().unwrap();
|
||||
log::info!("repl got input line: {}", s.as_str());
|
||||
// TODO: decode the input line here to catch F1-F4 keys and select the right app/mode
|
||||
repl.input(s.as_str()).expect("Vault couldn't accept input string");
|
||||
log::debug!("repl got input line: {}", s.as_str());
|
||||
match s.as_str() {
|
||||
"\u{0011}" => {
|
||||
log::info!("fido");
|
||||
}
|
||||
"\u{0012}" => {
|
||||
log::info!("totp");
|
||||
}
|
||||
"\u{0013}" => {
|
||||
log::info!("passwords");
|
||||
}
|
||||
"\u{0014}" => {
|
||||
repl.raise_menu();
|
||||
}
|
||||
"↓" => {
|
||||
log::info!("down arrow");
|
||||
}
|
||||
"↑" => {
|
||||
log::info!("up arrow");
|
||||
}
|
||||
"←" => {
|
||||
log::info!("left arrow");
|
||||
}
|
||||
"→" => {
|
||||
log::info!("right arrow");
|
||||
}
|
||||
_ => {
|
||||
repl.input(s.as_str()).expect("Vault couldn't accept input string");
|
||||
}
|
||||
}
|
||||
update_repl = true; // set a flag, instead of calling here, so message can drop and calling server is released
|
||||
was_callback = false;
|
||||
}
|
||||
|
|
@ -179,6 +217,15 @@ fn main() -> ! {
|
|||
}
|
||||
repl.redraw().ok();
|
||||
}),
|
||||
Some(VaultOp::MenuAutotype) => {
|
||||
log::info!("got autotype");
|
||||
},
|
||||
Some(VaultOp::MenuDelete) => {
|
||||
log::info!("got delete");
|
||||
},
|
||||
Some(VaultOp::MenuEdit) => {
|
||||
log::info!("got edit");
|
||||
}
|
||||
Some(VaultOp::Quit) => {
|
||||
log::error!("got Quit");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ impl Repl{
|
|||
pub(crate) fn new(xns: &xous_names::XousNames, sid: xous::SID) -> Self {
|
||||
let gam = gam::Gam::new(xns).expect("can't connect to GAM");
|
||||
|
||||
#[cfg(not(test))]
|
||||
let app_name_ref = gam::APP_NAME_VAULT;
|
||||
#[cfg(test)]
|
||||
let app_name_ref = "test name";
|
||||
let token = gam.register_ux(UxRegistration {
|
||||
app_name: xous_ipc::String::<128>::from_str(app_name_ref),
|
||||
ux_type: gam::UxType::Chat,
|
||||
|
|
@ -89,4 +86,8 @@ impl Repl{
|
|||
self.gam.redraw().expect("couldn't redraw screen");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn raise_menu(&self) {
|
||||
self.gam.raise_menu(gam::APP_MENU_0_VAULT).expect("couldn't raise our submenu");
|
||||
}
|
||||
}
|
||||
40
apps/vault/src/submenu.rs
Normal file
40
apps/vault/src/submenu.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use gam::*;
|
||||
use num_traits::*;
|
||||
|
||||
use locales::t;
|
||||
use crate::VaultOp;
|
||||
|
||||
pub fn create_submenu(vault_conn: xous::CID, menu_mgr: xous::SID) -> MenuMatic {
|
||||
let mut menu_items = Vec::<MenuItem>::new();
|
||||
|
||||
/* menu_items.push(MenuItem {
|
||||
name: xous_ipc::String::from_str(t!("vault.menu_autotype", xous::LANG)),
|
||||
action_conn: Some(vault_conn),
|
||||
action_opcode: VaultOp::MenuAutotype.to_u32().unwrap(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
}); */
|
||||
menu_items.push(MenuItem {
|
||||
name: xous_ipc::String::from_str(t!("vault.menu_edit", xous::LANG)),
|
||||
action_conn: Some(vault_conn),
|
||||
action_opcode: VaultOp::MenuEdit.to_u32().unwrap(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
});
|
||||
menu_items.push(MenuItem {
|
||||
name: xous_ipc::String::from_str(t!("vault.menu_delete", xous::LANG)),
|
||||
action_conn: Some(vault_conn),
|
||||
action_opcode: VaultOp::MenuDelete.to_u32().unwrap(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
});
|
||||
menu_items.push(MenuItem {
|
||||
name: xous_ipc::String::from_str(t!("vault.menu_close", xous::LANG)),
|
||||
action_conn: None,
|
||||
action_opcode: 0,
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
});
|
||||
|
||||
menu_matic(menu_items, gam::APP_MENU_0_VAULT, Some(menu_mgr)).expect("couldn't create MenuMatic manager")
|
||||
}
|
||||
Loading…
Reference in a new issue