From 6d37924399dd5d04f5be2506e3e044dd165f6399 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 3 Jan 2024 12:29:19 +0100 Subject: rework capability --- src/imap/session.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/imap/session.rs') diff --git a/src/imap/session.rs b/src/imap/session.rs index 5c67f8e..c4f062f 100644 --- a/src/imap/session.rs +++ b/src/imap/session.rs @@ -1,19 +1,22 @@ use crate::imap::command::{anonymous, authenticated, examined, selected}; use crate::imap::flow; use crate::imap::response::Response; +use crate::imap::capability::ServerCapability; use crate::login::ArcLoginProvider; use imap_codec::imap_types::command::Command; //----- pub struct Instance { pub login_provider: ArcLoginProvider, + pub server_capabilities: ServerCapability, pub state: flow::State, } impl Instance { - pub fn new(login_provider: ArcLoginProvider) -> Self { + pub fn new(login_provider: ArcLoginProvider, cap: ServerCapability) -> Self { Self { login_provider, state: flow::State::NotAuthenticated, + server_capabilities: cap, } } @@ -25,16 +28,21 @@ impl Instance { let ctx = anonymous::AnonymousContext { req: &cmd, login_provider: &self.login_provider, + server_capabilities: &self.server_capabilities, }; anonymous::dispatch(ctx).await } flow::State::Authenticated(ref user) => { - let ctx = authenticated::AuthenticatedContext { req: &cmd, user }; + let ctx = authenticated::AuthenticatedContext { + req: &cmd, + server_capabilities: &self.server_capabilities, + user }; authenticated::dispatch(ctx).await } flow::State::Selected(ref user, ref mut mailbox) => { let ctx = selected::SelectedContext { req: &cmd, + server_capabilities: &self.server_capabilities, user, mailbox, }; @@ -43,6 +51,7 @@ impl Instance { flow::State::Examined(ref user, ref mut mailbox) => { let ctx = examined::ExaminedContext { req: &cmd, + server_capabilities: &self.server_capabilities, user, mailbox, }; -- cgit v1.2.3 From ef257e286a5377031bfde9645629825d3223b3d4 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 3 Jan 2024 15:00:05 +0100 Subject: implement move --- src/imap/session.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/imap/session.rs') diff --git a/src/imap/session.rs b/src/imap/session.rs index c4f062f..55026b9 100644 --- a/src/imap/session.rs +++ b/src/imap/session.rs @@ -1,7 +1,7 @@ +use crate::imap::capability::ServerCapability; use crate::imap::command::{anonymous, authenticated, examined, selected}; use crate::imap::flow; use crate::imap::response::Response; -use crate::imap::capability::ServerCapability; use crate::login::ArcLoginProvider; use imap_codec::imap_types::command::Command; @@ -33,10 +33,11 @@ impl Instance { anonymous::dispatch(ctx).await } flow::State::Authenticated(ref user) => { - let ctx = authenticated::AuthenticatedContext { - req: &cmd, + let ctx = authenticated::AuthenticatedContext { + req: &cmd, server_capabilities: &self.server_capabilities, - user }; + user, + }; authenticated::dispatch(ctx).await } flow::State::Selected(ref user, ref mut mailbox) => { -- cgit v1.2.3 From a6a0e1994db2b43f559e5c2e8ae5c58342e5136f Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 3 Jan 2024 20:53:07 +0100 Subject: ENABLE is now supported --- src/imap/session.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/imap/session.rs') diff --git a/src/imap/session.rs b/src/imap/session.rs index 55026b9..6b26478 100644 --- a/src/imap/session.rs +++ b/src/imap/session.rs @@ -1,4 +1,4 @@ -use crate::imap::capability::ServerCapability; +use crate::imap::capability::{ClientCapability, ServerCapability}; use crate::imap::command::{anonymous, authenticated, examined, selected}; use crate::imap::flow; use crate::imap::response::Response; @@ -9,14 +9,17 @@ use imap_codec::imap_types::command::Command; pub struct Instance { pub login_provider: ArcLoginProvider, pub server_capabilities: ServerCapability, + pub client_capabilities: ClientCapability, pub state: flow::State, } impl Instance { pub fn new(login_provider: ArcLoginProvider, cap: ServerCapability) -> Self { + let client_cap = ClientCapability::new(&cap); Self { login_provider, state: flow::State::NotAuthenticated, server_capabilities: cap, + client_capabilities: client_cap, } } @@ -36,6 +39,7 @@ impl Instance { let ctx = authenticated::AuthenticatedContext { req: &cmd, server_capabilities: &self.server_capabilities, + client_capabilities: &mut self.client_capabilities, user, }; authenticated::dispatch(ctx).await @@ -44,6 +48,7 @@ impl Instance { let ctx = selected::SelectedContext { req: &cmd, server_capabilities: &self.server_capabilities, + client_capabilities: &mut self.client_capabilities, user, mailbox, }; @@ -53,6 +58,7 @@ impl Instance { let ctx = examined::ExaminedContext { req: &cmd, server_capabilities: &self.server_capabilities, + client_capabilities: &mut self.client_capabilities, user, mailbox, }; -- cgit v1.2.3