mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add basis mount/unmount to pddb shell commands, fix some UX formatting
This commit is contained in:
parent
1ad7c43f81
commit
6ac4ef292b
4 changed files with 83 additions and 20 deletions
|
|
@ -108,11 +108,17 @@
|
||||||
"en-tts": "Enter name of Basis"
|
"en-tts": "Enter name of Basis"
|
||||||
},
|
},
|
||||||
"pddb.password": {
|
"pddb.password": {
|
||||||
"en": "Basis Password:",
|
"en": "Enter Basis password",
|
||||||
"ja": "Basis パスワード",
|
"ja": "Basis パスワード",
|
||||||
"zh": "基础密码",
|
"zh": "基础密码",
|
||||||
"en-tts": "Enter password for Basis"
|
"en-tts": "Enter password for Basis"
|
||||||
},
|
},
|
||||||
|
"pddb.password_for": {
|
||||||
|
"en": "For basis: ",
|
||||||
|
"ja": "Basis 名前: ",
|
||||||
|
"zh": "基础姓名: ",
|
||||||
|
"en-tts": "For basis: "
|
||||||
|
},
|
||||||
"pddb.menu.listbasis": {
|
"pddb.menu.listbasis": {
|
||||||
"en": "List unlocked bases",
|
"en": "List unlocked bases",
|
||||||
"ja": "ロック解除されたベースをー覧表します",
|
"ja": "ロック解除されたベースをー覧表します",
|
||||||
|
|
|
||||||
|
|
@ -649,24 +649,28 @@ fn xmain() -> ! {
|
||||||
basis_cache.basis_add(basis);
|
basis_cache.basis_add(basis);
|
||||||
finished = true;
|
finished = true;
|
||||||
mgmt.code = PddbRequestCode::NoErr;
|
mgmt.code = PddbRequestCode::NoErr;
|
||||||
|
} else {
|
||||||
|
modals.add_list_item(t!("pddb.yes", xous::LANG)).expect("couldn't build radio item list");
|
||||||
|
modals.add_list_item(t!("pddb.no", xous::LANG)).expect("couldn't build radio item list");
|
||||||
|
match modals.get_radiobutton(t!("pddb.badpass", xous::LANG)) {
|
||||||
|
Ok(response) => {
|
||||||
|
if response.as_str() == t!("pddb.yes", xous::LANG) {
|
||||||
|
finished = false;
|
||||||
|
// this will cause just another go-around
|
||||||
|
} else if response.as_str() == t!("pddb.no", xous::LANG) {
|
||||||
|
finished = true;
|
||||||
|
mgmt.code = PddbRequestCode::AccessDenied; // this will cause a return of AccessDenied
|
||||||
|
} else {
|
||||||
|
panic!("Got unexpected return from radiobutton");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => panic!("get_radiobutton failed"),
|
||||||
|
}
|
||||||
|
xous::yield_slice(); // allow a redraw to happen before repeating the request
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
modals.add_list_item(t!("pddb.yes", xous::LANG)).expect("couldn't build radio item list");
|
finished = true;
|
||||||
modals.add_list_item(t!("pddb.no", xous::LANG)).expect("couldn't build radio item list");
|
log::error!("internal error in basis unlock, aborting!");
|
||||||
match modals.get_radiobutton(t!("pddb.badpass", xous::LANG)) {
|
|
||||||
Ok(response) => {
|
|
||||||
if response.as_str() == t!("pddb.yes", xous::LANG) {
|
|
||||||
finished = false;
|
|
||||||
// this will cause just another go-around
|
|
||||||
} else if response.as_str() == t!("pddb.no", xous::LANG) {
|
|
||||||
finished = true;
|
|
||||||
mgmt.code = PddbRequestCode::AccessDenied; // this will cause a return of AccessDenied
|
|
||||||
} else {
|
|
||||||
panic!("Got unexpected return from radiobutton");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => panic!("get_radiobutton failed"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ pub(crate) fn password_ux_manager(
|
||||||
pddb_modal.modify(
|
pddb_modal.modify(
|
||||||
Some(ActionType::TextEntry(password_action)),
|
Some(ActionType::TextEntry(password_action)),
|
||||||
Some(t!("pddb.password", xous::LANG)), false,
|
Some(t!("pddb.password", xous::LANG)), false,
|
||||||
Some(db_name.as_str().unwrap()), false, None
|
Some(format!("{}'{}'", t!("pddb.password_for", xous::LANG), db_name.as_str().unwrap()).as_str()), false, None
|
||||||
);
|
);
|
||||||
pddb_modal.activate();
|
pddb_modal.activate();
|
||||||
dr = Some(msg);
|
dr = Some(msg);
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
let mut ret = String::<1024>::new();
|
let mut ret = String::<1024>::new();
|
||||||
#[cfg(not(feature="pddbtest"))]
|
#[cfg(not(feature="pddbtest"))]
|
||||||
let helpstring = "pddb [basislist] [dictlist] [keylist] [query] [dictdelete] [keydelete]";
|
let helpstring = "pddb [basislist] [basiscreate] [basisunlock] [basislock] [basisdelete] [default]\n[dictlist] [keylist] [query] [dictdelete] [keydelete]";
|
||||||
#[cfg(feature="pddbtest")]
|
#[cfg(feature="pddbtest")]
|
||||||
let helpstring = "pddb [basislist] [dictlist] [keylist] [query] [dictdelete] [keydelete] [test]";
|
let helpstring = "pddb [basislist] [basiscreate] [basisunlock] [basislock] [basisdelete] [default]\n[dictlist] [keylist] [query] [dictdelete] [keydelete]\n[test]";
|
||||||
|
|
||||||
let mut tokens = args.as_str().unwrap().split(' ');
|
let mut tokens = args.as_str().unwrap().split(' ');
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
|
|
@ -43,6 +43,52 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
}})
|
}})
|
||||||
).unwrap();*/
|
).unwrap();*/
|
||||||
}
|
}
|
||||||
|
"default" => {
|
||||||
|
match self.pddb.latest_basis() {
|
||||||
|
Some(latest) => write!(ret, "The current default basis is: {}", latest).unwrap(),
|
||||||
|
None => write!(ret, "No open basis detected").unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"basiscreate" => {
|
||||||
|
if let Some(bname) = tokens.next() {
|
||||||
|
match self.pddb.create_basis(bname) {
|
||||||
|
Ok(_) => write!(ret, "basis {} created successfully", bname).unwrap(),
|
||||||
|
Err(e) => write!(ret, "basis {} could not be created: {:?}", bname, e).unwrap(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write!(ret, "usage: pddb basiscreate [basis name]").unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"basisunlock" => {
|
||||||
|
if let Some(bname) = tokens.next() {
|
||||||
|
match self.pddb.unlock_basis(bname, None) {
|
||||||
|
Ok(_) => write!(ret, "basis {} unlocked successfully", bname).unwrap(),
|
||||||
|
Err(e) => write!(ret, "basis {} could not be unlocked: {:?}", bname, e).unwrap(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write!(ret, "usage: pddb basisunlock [basis name]").unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"basislock" => {
|
||||||
|
if let Some(bname) = tokens.next() {
|
||||||
|
match self.pddb.lock_basis(bname) {
|
||||||
|
Ok(_) => write!(ret, "basis {} locked successfully", bname).unwrap(),
|
||||||
|
Err(e) => write!(ret, "basis {} could not be locked: {:?}", bname, e).unwrap(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write!(ret, "usage: pddb basisunlock [basis name]").unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"basisdelete" => {
|
||||||
|
if let Some(bname) = tokens.next() {
|
||||||
|
match self.pddb.delete_basis(bname) {
|
||||||
|
Ok(_) => write!(ret, "basis {} deleted successfully", bname).unwrap(),
|
||||||
|
Err(e) => write!(ret, "basis {} could not be deleted: {:?}", bname, e).unwrap(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write!(ret, "usage: pddb basisdelete [basis name]").unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
"query" => {
|
"query" => {
|
||||||
if let Some(descriptor) = tokens.next() {
|
if let Some(descriptor) = tokens.next() {
|
||||||
if let Some((dict, keyname)) = descriptor.split_once(':') {
|
if let Some((dict, keyname)) = descriptor.split_once(':') {
|
||||||
|
|
@ -171,6 +217,7 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
// note that this feature only works in hosted mode
|
// note that this feature only works in hosted mode
|
||||||
#[cfg(feature="pddbtest")]
|
#[cfg(feature="pddbtest")]
|
||||||
"test" => {
|
"test" => {
|
||||||
|
let bname = tokens.next();
|
||||||
// zero-length key test
|
// zero-length key test
|
||||||
let mut test_handle = pddb::Pddb::new();
|
let mut test_handle = pddb::Pddb::new();
|
||||||
// build a key, but don't write to it.
|
// build a key, but don't write to it.
|
||||||
|
|
@ -183,6 +230,12 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
).expect("couldn't build empty key");
|
).expect("couldn't build empty key");
|
||||||
self.pddb.sync().unwrap();
|
self.pddb.sync().unwrap();
|
||||||
self.pddb.dbg_remount().unwrap();
|
self.pddb.dbg_remount().unwrap();
|
||||||
|
if let Some(name) = bname {
|
||||||
|
match self.pddb.unlock_basis(name, None) {
|
||||||
|
Ok(_) => log::info!("basis {} unlocked successfully", name),
|
||||||
|
Err(e) => log::info!("basis {} could not be unlocked: {:?}", name, e),
|
||||||
|
}
|
||||||
|
}
|
||||||
self.pddb.dbg_dump("std_test1").unwrap();
|
self.pddb.dbg_dump("std_test1").unwrap();
|
||||||
write!(ret, "dumped std_test1\n").unwrap();
|
write!(ret, "dumped std_test1\n").unwrap();
|
||||||
log::info!("finished zero-length alloc");
|
log::info!("finished zero-length alloc");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue