mirror of
https://github.com/chatmail/core.git
synced 2026-04-22 16:06:30 +03:00
make smtp/imap connect() return bool instead of c-int
This commit is contained in:
14
src/smtp.rs
14
src/smtp.rs
@@ -47,14 +47,14 @@ impl Smtp {
|
||||
}
|
||||
|
||||
/// Connect using the provided login params
|
||||
pub fn connect(&mut self, context: &Context, lp: *const dc_loginparam_t) -> usize {
|
||||
pub fn connect(&mut self, context: &Context, lp: *const dc_loginparam_t) -> bool {
|
||||
if lp.is_null() {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.is_connected() {
|
||||
warn!(context, 0, "SMTP already connected.");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Safe because we checked for null pointer above.
|
||||
@@ -78,7 +78,7 @@ impl Smtp {
|
||||
|
||||
if self.from.is_none() {
|
||||
// TODO: print error
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
let domain = unsafe {
|
||||
@@ -103,7 +103,7 @@ impl Smtp {
|
||||
let send_pw = as_str(lp.send_pw);
|
||||
let access_token = dc_get_oauth2_access_token(context, addr, send_pw, 0);
|
||||
if access_token.is_none() {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
let user = as_str(lp.send_user);
|
||||
|
||||
@@ -137,11 +137,11 @@ impl Smtp {
|
||||
"SMTP-LOGIN as {} ok",
|
||||
as_str(lp.send_user),
|
||||
);
|
||||
1
|
||||
true
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(context, 0, "SMTP: failed to establish connection {:?}", err);
|
||||
0
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user