Skip to content

Commit

Permalink
Added write email command.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed Feb 10, 2025
1 parent 8be855f commit 519d35c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 3 deletions.
10 changes: 10 additions & 0 deletions crates/icbsetup/src/create/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,16 @@ fn generate_protocol_data(protocol_data_file: &PathBuf) -> Res<()> {
recv_command: TransferProtocolType::ZModem8k,
});

protocols.push(Protocol {
is_enabled: true,
is_batch: true,
is_bi_directional: false,
char_code: "N".to_string(),
description: "None".to_string(),
send_command: TransferProtocolType::None,
recv_command: TransferProtocolType::None,
});

protocols.save(protocol_data_file)?;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/icbsetup/src/editors/protocols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<'a> Page for ProtocolEditor<'a> {
self.display_insert_table(frame, &area);

if let Some(edit_config) = &mut self.edit_config {
let mut area = area.inner(Margin { vertical: 6, horizontal: 3 });
let area = area.inner(Margin { vertical: 6, horizontal: 3 });
Clear.render(area, frame.buffer_mut());
let block = Block::new()
.title_alignment(Alignment::Center)
Expand Down
5 changes: 5 additions & 0 deletions crates/icy_board_engine/src/icy_board/state/menu_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ impl IcyBoardState {
self.read_email().await?;
}

CommandType::WriteEmail => {
// @W
self.write_email().await?;
}

CommandType::RunPPE => {
// PPE
if !cmd_action.parameter.is_empty() {
Expand Down
1 change: 0 additions & 1 deletion crates/icy_board_engine/src/icy_board/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ impl IcyBoardState {
}
self.session.num_lines_printed += 1;
if self.session.page_len > 0 && self.session.num_lines_printed >= self.session.page_len as usize {
log::info!("Page length reached: {} --- {}", self.session.page_len, self.session.num_lines_printed);
if self.session.disp_options.non_stop() {
self.session.more_requested = true;
return Ok(());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ impl IcyBoardState {
if only_personal {
for msg in message_base.iter().flatten() {
if let Some(to) = msg.get_to() {
if to == &self.session.alias_name || to == &self.session.user_name {
let mut to = to.clone();
to.make_ascii_uppercase();
if to == self.session.alias_name.to_ascii_uppercase() || to == self.session.user_name.to_ascii_uppercase() {
messages.push(msg.message_number);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use crate::{icy_board::state::IcyBoardState, Res};

use crate::icy_board::{
icb_text::IceText,
state::{
functions::{display_flags, MASK_ASCII},
NodeStatus,
},
};

impl IcyBoardState {
pub async fn write_email(&mut self) -> Res<()> {
self.set_activity(NodeStatus::EnterMessage).await;
let to = self
.input_field(
IceText::To,
54,
&MASK_ASCII,
"",
None,
display_flags::NEWLINE | display_flags::LFBEFORE | display_flags::FIELDLEN,
)
.await?;
let lowercase_to = to.to_lowercase();
let user_exists = self
.board
.lock()
.await
.users
.iter()
.any(|user| user.name.to_ascii_lowercase() == to || user.alias.to_ascii_lowercase() == to)
|| self.board.lock().await.config.sysop.name.to_ascii_lowercase() == lowercase_to;
if !user_exists {
self.session.op_text = to;
self.display_text(IceText::NotInUsersFile, display_flags::NEWLINE | display_flags::LFBEFORE | display_flags::BELL)
.await?;
self.press_enter().await?;
self.display_current_menu = true;
return Ok(());
}

let subject = self
.input_field(
IceText::MessageSubject,
54,
&MASK_ASCII,
"",
None,
display_flags::NEWLINE | display_flags::LFBEFORE | display_flags::FIELDLEN,
)
.await?;

if subject.is_empty() {
self.new_line().await?;
self.press_enter().await?;
self.display_current_menu = true;
return Ok(());
};

self.write_message(-1, -1, &to, &subject, false, IceText::SavingMessage).await?;

self.press_enter().await?;
self.display_current_menu = true;
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod at_read_email;
pub mod atw_write_email;

0 comments on commit 519d35c

Please sign in to comment.