aboutsummaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-07 13:27:26 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-07 13:27:26 +0200
commit93f943aa802163eb47feef592c1504112e4588c5 (patch)
tree2b5759214e2f8c91cd3e6f94fbad3795c8e2ffa5 /src/command.rs
parentc03be0a8c335c462bcc2f171145aef779a652736 (diff)
downloadaerogramme-93f943aa802163eb47feef592c1504112e4588c5.tar.gz
aerogramme-93f943aa802163eb47feef592c1504112e4588c5.zip
Add some more commands
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/command.rs b/src/command.rs
index 24c452b..2ee1a07 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -2,23 +2,27 @@ use std::sync::{Arc, Mutex};
use boitalettres::errors::Error as BalError;
use boitalettres::proto::{Request, Response};
-use imap_codec::types::core::AString;
+use imap_codec::types::core::{Tag, AString};
use imap_codec::types::response::{Capability, Data};
+use imap_codec::types::mailbox::{Mailbox, ListMailbox};
+use imap_codec::types::sequence::SequenceSet;
+use imap_codec::types::fetch_attributes::MacroOrFetchAttributes;
-use crate::mailstore;
-use crate::service;
+use crate::mailstore::Mailstore;
+use crate::service::Session;
pub struct Command {
- mailstore: Arc<mailstore::Mailstore>,
- session: Arc<Mutex<service::Session>>,
+ tag: Tag,
+ mailstore: Arc<Mailstore>,
+ session: Arc<Mutex<Session>>,
}
impl Command {
- pub fn new(mailstore: Arc<mailstore::Mailstore>, session: Arc<Mutex<service::Session>>) -> Self {
- Self { mailstore, session }
+ pub fn new(tag: Tag, mailstore: Arc<Mailstore>, session: Arc<Mutex<Session>>) -> Self {
+ Self { tag, mailstore, session }
}
- pub async fn capability(self) -> Result<Response, BalError> {
+ pub async fn capability(&self) -> Result<Response, BalError> {
let capabilities = vec![Capability::Imap4Rev1, Capability::Idle];
let body = vec![Data::Capability(capabilities)];
let r = Response::ok("Pre-login capabilities listed, post-login capabilities have more.")?
@@ -26,7 +30,7 @@ impl Command {
Ok(r)
}
- pub async fn login(self, username: AString, password: AString) -> Result<Response, BalError> {
+ pub async fn login(&self, username: AString, password: AString) -> Result<Response, BalError> {
let (u, p) = match (String::try_from(username), String::try_from(password)) {
(Ok(u), Ok(p)) => (u, p),
_ => return Response::bad("Invalid characters"),
@@ -46,4 +50,20 @@ impl Command {
Response::ok("Logged in")
}
+
+ pub async fn lsub(&self, reference: Mailbox, mailbox_wildcard: ListMailbox) -> Result<Response, BalError> {
+ Response::bad("Not implemented")
+ }
+
+ pub async fn list(&self, reference: Mailbox, mailbox_wildcard: ListMailbox) -> Result<Response, BalError> {
+ Response::bad("Not implemented")
+ }
+
+ pub async fn select(&self, mailbox: Mailbox) -> Result<Response, BalError> {
+ Response::bad("Not implemented")
+ }
+
+ pub async fn fetch(&self, sequence_set: SequenceSet, attributes: MacroOrFetchAttributes, uid: bool) -> Result<Response, BalError> {
+ Response::bad("Not implemented")
+ }
}