make smtp/imap connect() return bool instead of c-int

This commit is contained in:
holger krekel
2019-07-17 10:25:25 +02:00
parent 8737c1d142
commit ad4be80b4e
4 changed files with 34 additions and 34 deletions

View File

@@ -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
}
}
}