mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
imap: move IdleHandle from session.rs to idle.rs
This commit is contained in:
committed by
holger krekel
parent
4c42acc7e1
commit
793ebe1b0f
@@ -1,6 +1,8 @@
|
|||||||
use super::Imap;
|
use super::Imap;
|
||||||
|
|
||||||
use async_imap::extensions::idle::IdleResponse;
|
use async_imap::extensions::idle::{Handle as ImapIdleHandle, IdleResponse};
|
||||||
|
use async_native_tls::TlsStream;
|
||||||
|
use async_std::net::TcpStream;
|
||||||
use async_std::prelude::*;
|
use async_std::prelude::*;
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
@@ -9,7 +11,7 @@ use std::time::{Duration, SystemTime};
|
|||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
|
|
||||||
use super::select_folder;
|
use super::select_folder;
|
||||||
use super::session::{IdleHandle, Session};
|
use super::session::Session;
|
||||||
|
|
||||||
type Result<T> = std::result::Result<T, Error>;
|
type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
@@ -37,6 +39,27 @@ impl From<select_folder::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) enum IdleHandle {
|
||||||
|
Secure(ImapIdleHandle<TlsStream<TcpStream>>),
|
||||||
|
Insecure(ImapIdleHandle<TcpStream>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Session {
|
||||||
|
pub fn idle(self) -> IdleHandle {
|
||||||
|
match self {
|
||||||
|
Session::Secure(i) => {
|
||||||
|
let h = i.idle();
|
||||||
|
IdleHandle::Secure(h)
|
||||||
|
}
|
||||||
|
Session::Insecure(i) => {
|
||||||
|
let h = i.idle();
|
||||||
|
IdleHandle::Insecure(h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Imap {
|
impl Imap {
|
||||||
pub fn can_idle(&self) -> bool {
|
pub fn can_idle(&self) -> bool {
|
||||||
task::block_on(async move { self.config.read().await.can_idle })
|
task::block_on(async move { self.config.read().await.can_idle })
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use async_imap::{
|
use async_imap::{
|
||||||
error::Result as ImapResult,
|
error::Result as ImapResult,
|
||||||
extensions::idle::Handle as ImapIdleHandle,
|
|
||||||
types::{Capabilities, Fetch, Mailbox, Name},
|
types::{Capabilities, Fetch, Mailbox, Name},
|
||||||
Session as ImapSession,
|
Session as ImapSession,
|
||||||
};
|
};
|
||||||
@@ -14,12 +13,6 @@ pub(crate) enum Session {
|
|||||||
Insecure(ImapSession<TcpStream>),
|
Insecure(ImapSession<TcpStream>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub(crate) enum IdleHandle {
|
|
||||||
Secure(ImapIdleHandle<TlsStream<TcpStream>>),
|
|
||||||
Insecure(ImapIdleHandle<TcpStream>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Session {
|
impl Session {
|
||||||
pub async fn capabilities(&mut self) -> ImapResult<Capabilities> {
|
pub async fn capabilities(&mut self) -> ImapResult<Capabilities> {
|
||||||
let res = match self {
|
let res = match self {
|
||||||
@@ -130,19 +123,6 @@ impl Session {
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn idle(self) -> IdleHandle {
|
|
||||||
match self {
|
|
||||||
Session::Secure(i) => {
|
|
||||||
let h = i.idle();
|
|
||||||
IdleHandle::Secure(h)
|
|
||||||
}
|
|
||||||
Session::Insecure(i) => {
|
|
||||||
let h = i.idle();
|
|
||||||
IdleHandle::Insecure(h)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn uid_store<S1, S2>(&mut self, uid_set: S1, query: S2) -> ImapResult<Vec<Fetch>>
|
pub async fn uid_store<S1, S2>(&mut self, uid_set: S1, query: S2) -> ImapResult<Vec<Fetch>>
|
||||||
where
|
where
|
||||||
S1: AsRef<str>,
|
S1: AsRef<str>,
|
||||||
|
|||||||
Reference in New Issue
Block a user