aboutsummaryrefslogtreecommitdiff
path: root/src/imap/session.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/imap/session.rs')
-rw-r--r--src/imap/session.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/imap/session.rs b/src/imap/session.rs
index 5c67f8e..6b26478 100644
--- a/src/imap/session.rs
+++ b/src/imap/session.rs
@@ -1,3 +1,4 @@
+use crate::imap::capability::{ClientCapability, ServerCapability};
use crate::imap::command::{anonymous, authenticated, examined, selected};
use crate::imap::flow;
use crate::imap::response::Response;
@@ -7,13 +8,18 @@ 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) -> Self {
+ 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,
}
}
@@ -25,16 +31,24 @@ 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,
+ client_capabilities: &mut self.client_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,
+ client_capabilities: &mut self.client_capabilities,
user,
mailbox,
};
@@ -43,6 +57,8 @@ impl Instance {
flow::State::Examined(ref user, ref mut mailbox) => {
let ctx = examined::ExaminedContext {
req: &cmd,
+ server_capabilities: &self.server_capabilities,
+ client_capabilities: &mut self.client_capabilities,
user,
mailbox,
};