diff --git a/python/install_py_bindings.sh b/python/install_py_bindings.sh index c145036fe..1b5c71cf6 100755 --- a/python/install_py_bindings.sh +++ b/python/install_py_bindings.sh @@ -3,4 +3,5 @@ set -ex cargo build -p deltachat_ffi --release +rm -rf build/ DCC_RS_DEV=`pwd`/.. pip install -e . diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 4189b02a5..ff1d4425c 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -142,8 +142,10 @@ def wait_successful_IMAP_SMTP_connection(account): account._evlogger.get_matching("DC_EVENT_(IMAP|SMTP)_CONNECTED") if evt_name == "DC_EVENT_IMAP_CONNECTED": imap_ok = True + print("** IMAP OK", account) if evt_name == "DC_EVENT_SMTP_CONNECTED": smtp_ok = True + print("** SMTP OK", account) print("** IMAP and SMTP logins successful", account) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index dc2e1c9ca..c9249675c 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -204,6 +204,43 @@ class TestOfflineAccount: class TestOnlineAccount: + def test_one_account_init(self, acfactory): + ac1 = acfactory.get_online_configuring_account() + wait_successful_IMAP_SMTP_connection(ac1) + wait_configuration_progress(ac1, 1000) + + def test_one_account_send(self, acfactory): + ac1 = acfactory.get_online_configuring_account() + c2 = ac1.create_contact(email=ac1.get_config("addr")) + chat = ac1.create_chat_by_contact(c2) + assert chat.id >= const.DC_CHAT_ID_LAST_SPECIAL + wait_successful_IMAP_SMTP_connection(ac1) + wait_configuration_progress(ac1, 1000) + + msg_out = chat.send_text("message2") + # wait for own account to receive + ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") + assert ev[1] == msg_out.id + + def test_two_acocunts_send_receive(self, acfactory): + ac1 = acfactory.get_online_configuring_account() + ac2 = acfactory.get_online_configuring_account() + c2 = ac1.create_contact(email=ac2.get_config("addr")) + chat = ac1.create_chat_by_contact(c2) + assert chat.id >= const.DC_CHAT_ID_LAST_SPECIAL + #wait_successful_IMAP_SMTP_connection(ac1) + wait_configuration_progress(ac1, 1000) + #wait_successful_IMAP_SMTP_connection(ac2) + wait_configuration_progress(ac2, 1000) + + msg_out = chat.send_text("message1") + + # wait for other account to receive + ev = ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") + assert ev[2] == msg_out.id + msg_in = ac2.get_message_by_id(msg_out.id) + assert msg_in.text == "message1" + def test_forward_messages(self, acfactory): ac1 = acfactory.get_online_configuring_account() ac2 = acfactory.get_online_configuring_account() diff --git a/src/imap.rs b/src/imap.rs index 43696b2ee..0e436d985 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -554,6 +554,13 @@ impl Imap { s }); + log_event!( + context, + Event::IMAP_CONNECTED, + 0, + "IMAP-LOGIN as {} ok", + as_str(lp.mail_user), + ); info!(context, 0, "IMAP-capabilities:{}", caps_list); let mut config = self.config.write().unwrap(); diff --git a/src/smtp.rs b/src/smtp.rs index 85f172d90..1c8bc235e 100644 --- a/src/smtp.rs +++ b/src/smtp.rs @@ -6,10 +6,10 @@ use lettre::*; use crate::constants::Event; use crate::constants::*; use crate::context::Context; -use crate::dc_log::*; use crate::dc_loginparam::*; use crate::dc_tools::*; use crate::oauth2::*; +use crate::types::*; pub struct Smtp { transport: Option, @@ -61,14 +61,7 @@ impl Smtp { let lp = unsafe { *lp }; if lp.addr.is_null() || lp.send_server.is_null() || lp.send_port == 0 { - unsafe { - dc_log_event( - context, - Event::ERROR_NETWORK, - 0, - b"SMTP bad parameters.\x00" as *const u8 as *const libc::c_char, - ); - } + log_event!(context, Event::ERROR_NETWORK, 0, "SMTP bad parameters.",); } let raw_addr = unsafe { @@ -137,6 +130,13 @@ impl Smtp { .credentials(creds) .connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited); self.transport = Some(client.transport()); + log_event!( + context, + Event::SMTP_CONNECTED, + 0, + "SMTP-LOGIN as {} ok", + as_str(lp.send_user), + ); 1 } Err(err) => { @@ -162,21 +162,17 @@ impl Smtp { match transport.send(mail) { Ok(_) => { - unsafe { - dc_log_event( - context, - Event::SMTP_MESSAGE_SENT, - 0, - b"Message was sent to SMTP server\x00" as *const u8 - as *const libc::c_char, - ); - } + log_event!( + context, + Event::SMTP_MESSAGE_SENT, + 0, + "Message was sent to SMTP server", + ); self.transport_connected = true; 1 } Err(err) => { warn!(context, 0, "SMTP failed to send message: {}", err); - 0 } }