Struct deltachat::imap::Imap

source ·
pub struct Imap {
    pub(crate) idle_interrupt_receiver: Receiver<()>,
    config: ImapConfig,
    pub(crate) session: Option<Session>,
    login_failed_once: bool,
    pub(crate) connectivity: ConnectivityStore,
    ratelimit: RwLock<Ratelimit>,
}

Fields§

§idle_interrupt_receiver: Receiver<()>§config: ImapConfig§session: Option<Session>§login_failed_once: bool§connectivity: ConnectivityStore§ratelimit: RwLock<Ratelimit>

Rate limit for IMAP connection usage attempts.

Rate limit is checked before connecting and updated right before login attempt. It does not limit the number of connection attempts if the network is bad as only successful connections are counted.

Main purpose of this rate limit is to prevent busy loop in case connection gets dropped over and over due to IMAP bug, e.g. the server returning invalid response to SELECT command immediately after logging in or returning an error in response to LOGIN command due to internal server error.

Implementations§

source§

impl Imap

source

async fn fetch_single_msg( &mut self, context: &Context, folder: &str, uidvalidity: u32, uid: u32, rfc724_mid: String ) -> ImapActionResult

Download a single message and pipe it to receive_imf().

receive_imf() is not directly aware that this is a result of a call to download_msg(), however, implicitly knows that as the existing message is flagged as being partly.

source§

impl Imap

source

pub(crate) async fn fake_idle( &mut self, context: &Context, watch_folder: Option<String>, folder_meaning: FolderMeaning )

source§

impl Imap

source

pub(crate) async fn scan_folders(&mut self, context: &Context) -> Result<bool>

Returns true if folders were scanned, false if scanning was postponed.

source

pub async fn list_folders(self: &mut Imap) -> Result<Vec<Name>>

Returns the names of all folders on the IMAP server.

source§

impl Imap

source

pub fn new( lp: &ServerLoginParam, socks5_config: Option<Socks5Config>, addr: &str, provider_strict_tls: bool, idle_interrupt_receiver: Receiver<()> ) -> Result<Self>

Creates new disconnected IMAP client using the specific login parameters.

addr is used to renew token if OAuth2 authentication is used.

source

pub async fn new_configured( context: &Context, idle_interrupt_receiver: Receiver<()> ) -> Result<Self>

Creates new disconnected IMAP client using configured parameters.

source

pub async fn connect(&mut self, context: &Context) -> Result<()>

Connects or reconnects if needed.

It is safe to call this function if already connected, actions are performed only as needed.

Calling this function is not enough to perform IMAP operations. Use Imap::prepare instead if you are going to actually use connection rather than trying connection parameters.

source

pub async fn prepare(&mut self, context: &Context) -> Result<()>

Prepare for IMAP operation.

Ensure that IMAP client is connected, folders are created and IMAP capabilities are determined.

source

pub fn trigger_reconnect(&mut self, context: &Context)

Drops the session without disconnecting properly. Useful in case of an IMAP error, when it’s unclear if it’s in a correct state and it’s easier to setup a new connection.

source

pub async fn fetch_move_delete( &mut self, context: &Context, watch_folder: &str, folder_meaning: FolderMeaning ) -> Result<()>

FETCH-MOVE-DELETE iteration.

Prefetches headers and downloads new message from the folder, moves messages away from the folder and deletes messages in the folder.

source

pub(crate) async fn resync_folder_uids( &mut self, context: &Context, folder: &str, folder_meaning: FolderMeaning ) -> Result<()>

Synchronizes UIDs in the database with UIDs on the server.

It is assumed that no operations are taking place on the same folder at the moment. Make sure to run it in the same thread/task as other network operations on this folder to avoid race conditions.

source

pub(crate) async fn select_with_uidvalidity( &mut self, context: &Context, folder: &str ) -> Result<bool>

Selects a folder and takes care of UIDVALIDITY changes.

When selecting a folder for the first time, sets the uid_next to the current mailbox.uid_next so that no old emails are fetched.

Returns Result<new_emails> (i.e. whether new emails arrived), if in doubt, returns new_emails=true so emails are fetched.

source

pub(crate) async fn fetch_new_messages( &mut self, context: &Context, folder: &str, folder_meaning: FolderMeaning, fetch_existing_msgs: bool ) -> Result<bool>

Fetches new messages.

Returns true if at least one message was fetched.

source

pub(crate) async fn fetch_existing_msgs( &mut self, context: &Context ) -> Result<()>

Read the recipients from old emails sent by the user and add them as contacts. This way, we can already offer them some email addresses they can write to.

Then, Fetch the last messages DC_FETCH_EXISTING_MSGS_COUNT emails from the server and show them in the chat list.

source

pub(crate) async fn resync_folders(&mut self, context: &Context) -> Result<()>

Synchronizes UIDs for all folders.

source§

impl Imap

source

pub(crate) async fn sync_seen_flags( &mut self, context: &Context, folder: &str ) -> Result<()>

Synchronizes \Seen flags using CONDSTORE extension.

source

pub async fn get_all_recipients( &mut self, context: &Context ) -> Result<Vec<SingleInfo>>

Gets the from, to and bcc addresses from all existing outgoing emails.

source

async fn prefetch(&mut self, uid_next: u32) -> Result<Vec<(u32, Fetch)>>

Prefetch all messages greater than or equal to uid_next. Returns a list of fetch results in the order of ascending delivery time to the server (INTERNALDATE).

source

async fn prefetch_existing_msgs(&mut self) -> Result<Vec<(u32, Fetch)>>

Like fetch_after(), but not for new messages but existing ones (the DC_FETCH_EXISTING_MSGS_COUNT newest messages)

source

pub(crate) async fn fetch_many_msgs( &mut self, context: &Context, folder: &str, uidvalidity: u32, request_uids: Vec<u32>, uid_message_ids: &BTreeMap<u32, String>, fetch_partially: bool, fetching_existing_messages: bool ) -> Result<(Option<u32>, Vec<ReceivedMsg>)>

Fetches a list of messages by server UID.

Returns the last UID fetched successfully and the info about each downloaded message. If the message is incorrect or there is a failure to write a message to the database, it is skipped and the error is logged.

source

pub(crate) async fn fetch_metadata(&mut self, context: &Context) -> Result<()>

Retrieves server metadata if it is supported.

We get /shared/comment and /shared/admin metadata.

source§

impl Imap

source

pub(crate) async fn prepare_imap_operation_on_msg( &mut self, context: &Context, folder: &str, uid: u32 ) -> Option<ImapActionResult>

source

pub async fn ensure_configured_folders( &mut self, context: &Context, create_mvbox: bool ) -> Result<()>

source

async fn configure_mvbox<'a>( &mut self, context: &Context, folders: &[&'a str], create_mvbox: bool ) -> Result<Option<&'a str>>

Attempts to configure mvbox.

Tries to find any folder in the given list of folders. If none is found, tries to create folders[0]. This method does not use LIST command to ensure that configuration works even if mailbox lookup is forbidden via Access Control List (see https://datatracker.ietf.org/doc/html/rfc4314).

Returns first found or created folder name.

source

pub async fn configure_folders( &mut self, context: &Context, create_mvbox: bool ) -> Result<()>

Trait Implementations§

source§

impl Debug for Imap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Imap

§

impl Send for Imap

§

impl Sync for Imap

§

impl !Unpin for Imap

§

impl !UnwindSafe for Imap

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more