Fix spawning task and introduce ProviderInfo event

This commit is contained in:
jikstra
2022-03-04 12:52:43 -05:00
parent 420a9fbd9f
commit 0b03331f0d
2 changed files with 9 additions and 6 deletions

View File

@@ -3928,18 +3928,18 @@ pub type dc_provider_t = provider::Provider;
#[no_mangle]
pub unsafe extern "C" fn dc_provider_new_from_email(
context: *const dc_context_t,
addr: *const libc::c_char,
context: *mut dc_context_t,
addr: *mut libc::c_char,
) {
if context.is_null() || addr.is_null() {
eprintln!("ignoring careless call to dc_provider_new_from_email()");
return;
}
let addr = to_string_lossy(addr);
let ctx = &*context;
let addr = to_string_lossy(addr);
async_std::task::spawn(async move {
let ctx = &*context;
spawn(async move {
let socks5_enabled = ctx.get_config_bool(config::Config::Socks5Enabled)
.await
.log_err(ctx, "Can't get config");
@@ -3959,7 +3959,7 @@ pub unsafe extern "C" fn dc_provider_new_from_email(
};
}
Err(err) => {
context.as_ref().unwrap().emit_event(EventType::Error(format!(
ctx.emit_event(EventType::Error(format!(
"Failed to get provider info: {:#}",
err
)));

View File

@@ -333,4 +333,7 @@ pub enum EventType {
msg_id: MsgId,
status_update_id: StatusUpdateId,
},
#[strum(props(id = "2201"))]
ProviderInfo(String),
}