convert the last two unsafe event emissions in smtp.rs

This commit is contained in:
holger krekel
2019-07-01 22:56:47 +02:00
parent 7a053b9f93
commit 2c26f4f2ab
2 changed files with 9 additions and 21 deletions

View File

@@ -214,14 +214,13 @@ class TestOnlineAccount:
c2 = ac1.create_contact(email=ac1.get_config("addr")) c2 = ac1.create_contact(email=ac1.get_config("addr"))
chat = ac1.create_chat_by_contact(c2) chat = ac1.create_chat_by_contact(c2)
assert chat.id >= const.DC_CHAT_ID_LAST_SPECIAL assert chat.id >= const.DC_CHAT_ID_LAST_SPECIAL
#wait_successful_IMAP_SMTP_connection(ac1) wait_successful_IMAP_SMTP_connection(ac1)
wait_configuration_progress(ac1, 1000) wait_configuration_progress(ac1, 1000)
msg_out = chat.send_text("message2") msg_out = chat.send_text("message2")
# wait for other account to receive # wait for other account to receive
ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
assert ev[1] == msg_out.id assert ev[1] == msg_out.id
assert 0
def test_two_acocunts_send_receive(self, acfactory): def test_two_acocunts_send_receive(self, acfactory):
ac1 = acfactory.get_online_configuring_account() ac1 = acfactory.get_online_configuring_account()

View File

@@ -6,7 +6,6 @@ use lettre::*;
use crate::constants::Event; use crate::constants::Event;
use crate::constants::*; use crate::constants::*;
use crate::context::Context; use crate::context::Context;
use crate::dc_log::*;
use crate::dc_loginparam::*; use crate::dc_loginparam::*;
use crate::dc_tools::*; use crate::dc_tools::*;
use crate::oauth2::*; use crate::oauth2::*;
@@ -62,14 +61,10 @@ impl Smtp {
let lp = unsafe { *lp }; let lp = unsafe { *lp };
if lp.addr.is_null() || lp.send_server.is_null() || lp.send_port == 0 { if lp.addr.is_null() || lp.send_server.is_null() || lp.send_port == 0 {
unsafe { log_event!(
dc_log_event( context, Event::ERROR_NETWORK, 0,
context, "SMTP bad parameters.",
Event::ERROR_NETWORK, );
0,
b"SMTP bad parameters.\x00" as *const u8 as *const libc::c_char,
);
}
} }
let raw_addr = unsafe { let raw_addr = unsafe {
@@ -166,21 +161,15 @@ impl Smtp {
match transport.send(mail) { match transport.send(mail) {
Ok(_) => { Ok(_) => {
unsafe { log_event!(
dc_log_event( context, Event::SMTP_MESSAGE_SENT, 0,
context, "Message was sent to SMTP server",
Event::SMTP_MESSAGE_SENT, );
0,
b"Message was sent to SMTP server\x00" as *const u8
as *const libc::c_char,
);
}
self.transport_connected = true; self.transport_connected = true;
1 1
} }
Err(err) => { Err(err) => {
warn!(context, 0, "SMTP failed to send message: {}", err); warn!(context, 0, "SMTP failed to send message: {}", err);
0 0
} }
} }