|
|
|
@ -1,9 +1,10 @@
|
|
|
|
|
use core::{cmp::Ordering, convert::TryInto};
|
|
|
|
|
use cstr_core::CStr;
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
error::Error,
|
|
|
|
|
micropython::{
|
|
|
|
|
buffer::StrBuffer,
|
|
|
|
|
buffer::{get_buffer, StrBuffer},
|
|
|
|
|
gc::Gc,
|
|
|
|
|
iter::{Iter, IterBuf},
|
|
|
|
|
list::List,
|
|
|
|
@ -28,6 +29,7 @@ use crate::{
|
|
|
|
|
},
|
|
|
|
|
Border, Component, Empty, Timeout, TimeoutMsg,
|
|
|
|
|
},
|
|
|
|
|
display::tjpgd::jpeg_info,
|
|
|
|
|
geometry,
|
|
|
|
|
layout::{
|
|
|
|
|
obj::{ComponentMsgObj, LayoutObj},
|
|
|
|
@ -466,6 +468,38 @@ extern "C" fn new_confirm_properties(n_args: usize, args: *const Obj, kwargs: *m
|
|
|
|
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
|
|
|
|
let block = move |_args: &[Obj], kwargs: &Map| {
|
|
|
|
|
let title: StrBuffer = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
|
|
|
|
|
let data: Obj = kwargs.get(Qstr::MP_QSTR_image)?;
|
|
|
|
|
let buffer = unsafe { get_buffer(data) };
|
|
|
|
|
|
|
|
|
|
if let Ok(buffer) = buffer {
|
|
|
|
|
let info = jpeg_info(buffer);
|
|
|
|
|
if let Some(info) = info {
|
|
|
|
|
let buttons = Button::cancel_confirm_text(None, "CONFIRM");
|
|
|
|
|
let obj = LayoutObj::new(
|
|
|
|
|
Frame::centered(
|
|
|
|
|
theme::label_title(),
|
|
|
|
|
title,
|
|
|
|
|
Dialog::new(painter::jpeg_painter(buffer, info.0, 1), buttons),
|
|
|
|
|
)
|
|
|
|
|
.with_border(theme::borders()),
|
|
|
|
|
)?;
|
|
|
|
|
Ok(obj.into())
|
|
|
|
|
} else {
|
|
|
|
|
let msg = unsafe { CStr::from_bytes_with_nul_unchecked(b"Invalid image.\0") };
|
|
|
|
|
Err(Error::ValueError(msg))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let msg = unsafe { CStr::from_bytes_with_nul_unchecked(b"Buffer error.\0") };
|
|
|
|
|
Err(Error::ValueError(msg))
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" fn new_confirm_reset_device(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
|
|
|
|
let block = move |_args: &[Obj], kwargs: &Map| {
|
|
|
|
|
let title: StrBuffer = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
|
|
|
|
@ -1316,6 +1350,15 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|
|
|
|
/// """Confirm action."""
|
|
|
|
|
Qstr::MP_QSTR_confirm_action => obj_fn_kw!(0, new_confirm_action).as_obj(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// def confirm_homescreen(
|
|
|
|
|
/// *,
|
|
|
|
|
/// title: str,
|
|
|
|
|
/// image: bytes,
|
|
|
|
|
/// ) -> object:
|
|
|
|
|
/// """Confirm homescreen."""
|
|
|
|
|
Qstr::MP_QSTR_confirm_homescreen => obj_fn_kw!(0, new_confirm_homescreen).as_obj(),
|
|
|
|
|
|
|
|
|
|
/// def confirm_blob(
|
|
|
|
|
/// *,
|
|
|
|
|
/// title: str,
|
|
|
|
|