mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Set data2 in ConfigureProgress event
For now it is only set on error, but could contain user-readable log messages in the future.
This commit is contained in:
committed by
link2xt
parent
cdba74a027
commit
f5b16cf086
@@ -4669,7 +4669,7 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
* Inform about the configuration progress started by dc_configure().
|
* Inform about the configuration progress started by dc_configure().
|
||||||
*
|
*
|
||||||
* @param data1 (int) 0=error, 1-999=progress in permille, 1000=success and done
|
* @param data1 (int) 0=error, 1-999=progress in permille, 1000=success and done
|
||||||
* @param data2 0
|
* @param data2 (char*) progress comment, error message or NULL if not applicable
|
||||||
*/
|
*/
|
||||||
#define DC_EVENT_CONFIGURE_PROGRESS 2041
|
#define DC_EVENT_CONFIGURE_PROGRESS 2041
|
||||||
|
|
||||||
@@ -4733,7 +4733,7 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
|
|
||||||
|
|
||||||
#define DC_EVENT_DATA1_IS_STRING(e) 0 // not used anymore
|
#define DC_EVENT_DATA1_IS_STRING(e) 0 // not used anymore
|
||||||
#define DC_EVENT_DATA2_IS_STRING(e) ((e)==DC_EVENT_IMEX_FILE_WRITTEN || ((e)>=100 && (e)<=499))
|
#define DC_EVENT_DATA2_IS_STRING(e) ((e)==DC_EVENT_CONFIGURE_PROGRESS || (e)==DC_EVENT_IMEX_FILE_WRITTEN || ((e)>=100 && (e)<=499))
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ pub unsafe extern "C" fn dc_event_get_data1_int(event: *mut dc_event_t) -> libc:
|
|||||||
let id = id.unwrap_or_default();
|
let id = id.unwrap_or_default();
|
||||||
id as libc::c_int
|
id as libc::c_int
|
||||||
}
|
}
|
||||||
EventType::ConfigureProgress(progress) | EventType::ImexProgress(progress) => {
|
EventType::ConfigureProgress { progress, .. } | EventType::ImexProgress(progress) => {
|
||||||
*progress as libc::c_int
|
*progress as libc::c_int
|
||||||
}
|
}
|
||||||
EventType::ImexFileWritten(_) => 0,
|
EventType::ImexFileWritten(_) => 0,
|
||||||
@@ -405,7 +405,7 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
|
|||||||
| EventType::ErrorSelfNotInGroup(_)
|
| EventType::ErrorSelfNotInGroup(_)
|
||||||
| EventType::ContactsChanged(_)
|
| EventType::ContactsChanged(_)
|
||||||
| EventType::LocationChanged(_)
|
| EventType::LocationChanged(_)
|
||||||
| EventType::ConfigureProgress(_)
|
| EventType::ConfigureProgress { .. }
|
||||||
| EventType::ImexProgress(_)
|
| EventType::ImexProgress(_)
|
||||||
| EventType::ImexFileWritten(_)
|
| EventType::ImexFileWritten(_)
|
||||||
| EventType::ChatModified(_) => 0,
|
| EventType::ChatModified(_) => 0,
|
||||||
@@ -453,11 +453,17 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
|
|||||||
| EventType::ChatModified(_)
|
| EventType::ChatModified(_)
|
||||||
| EventType::ContactsChanged(_)
|
| EventType::ContactsChanged(_)
|
||||||
| EventType::LocationChanged(_)
|
| EventType::LocationChanged(_)
|
||||||
| EventType::ConfigureProgress(_)
|
|
||||||
| EventType::ImexProgress(_)
|
| EventType::ImexProgress(_)
|
||||||
| EventType::SecurejoinInviterProgress { .. }
|
| EventType::SecurejoinInviterProgress { .. }
|
||||||
| EventType::SecurejoinJoinerProgress { .. }
|
| EventType::SecurejoinJoinerProgress { .. }
|
||||||
| EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(),
|
| EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(),
|
||||||
|
EventType::ConfigureProgress { comment, .. } => {
|
||||||
|
if let Some(comment) = comment {
|
||||||
|
comment.to_c_string().unwrap_or_default().into_raw()
|
||||||
|
} else {
|
||||||
|
ptr::null_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
EventType::ImexFileWritten(file) => {
|
EventType::ImexFileWritten(file) => {
|
||||||
let data2 = file.to_c_string().unwrap_or_default();
|
let data2 = file.to_c_string().unwrap_or_default();
|
||||||
data2.into_raw()
|
data2.into_raw()
|
||||||
|
|||||||
@@ -80,12 +80,22 @@ fn receive_event(event: EventType) {
|
|||||||
yellow.paint(format!("Received LOCATION_CHANGED(contact={:?})", contact))
|
yellow.paint(format!("Received LOCATION_CHANGED(contact={:?})", contact))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
EventType::ConfigureProgress(progress) => {
|
EventType::ConfigureProgress { progress, comment } => {
|
||||||
|
if let Some(comment) = comment {
|
||||||
|
info!(
|
||||||
|
"{}",
|
||||||
|
yellow.paint(format!(
|
||||||
|
"Received CONFIGURE_PROGRESS({} ‰, {})",
|
||||||
|
progress, comment
|
||||||
|
))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"{}",
|
"{}",
|
||||||
yellow.paint(format!("Received CONFIGURE_PROGRESS({} ‰)", progress))
|
yellow.paint(format!("Received CONFIGURE_PROGRESS({} ‰)", progress))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
EventType::ImexProgress(progress) => {
|
EventType::ImexProgress(progress) => {
|
||||||
info!(
|
info!(
|
||||||
"{}",
|
"{}",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use deltachat::EventType;
|
|||||||
|
|
||||||
fn cb(event: EventType) {
|
fn cb(event: EventType) {
|
||||||
match event {
|
match event {
|
||||||
EventType::ConfigureProgress(progress) => {
|
EventType::ConfigureProgress { progress, .. } => {
|
||||||
log::info!("progress: {}", progress);
|
log::info!("progress: {}", progress);
|
||||||
}
|
}
|
||||||
EventType::Info(msg) => {
|
EventType::Info(msg) => {
|
||||||
|
|||||||
@@ -27,12 +27,18 @@ use auto_outlook::outlk_autodiscover;
|
|||||||
use server_params::{expand_param_vector, ServerParams};
|
use server_params::{expand_param_vector, ServerParams};
|
||||||
|
|
||||||
macro_rules! progress {
|
macro_rules! progress {
|
||||||
($context:tt, $progress:expr) => {
|
($context:tt, $progress:expr, $comment:expr) => {
|
||||||
assert!(
|
assert!(
|
||||||
$progress <= 1000,
|
$progress <= 1000,
|
||||||
"value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success"
|
"value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success"
|
||||||
);
|
);
|
||||||
$context.emit_event($crate::events::EventType::ConfigureProgress($progress));
|
$context.emit_event($crate::events::EventType::ConfigureProgress {
|
||||||
|
progress: $progress,
|
||||||
|
comment: $comment,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
($context:tt, $progress:expr) => {
|
||||||
|
progress!($context, $progress, None);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +117,7 @@ impl Context {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
progress!(self, 0);
|
progress!(self, 0, Some(err.to_string()));
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,10 +233,16 @@ pub enum EventType {
|
|||||||
LocationChanged(Option<u32>),
|
LocationChanged(Option<u32>),
|
||||||
|
|
||||||
/// Inform about the configuration progress started by configure().
|
/// Inform about the configuration progress started by configure().
|
||||||
///
|
|
||||||
/// @param data1 (usize) 0=error, 1-999=progress in permille, 1000=success and done
|
|
||||||
#[strum(props(id = "2041"))]
|
#[strum(props(id = "2041"))]
|
||||||
ConfigureProgress(usize),
|
ConfigureProgress {
|
||||||
|
/// Progress.
|
||||||
|
///
|
||||||
|
/// 0=error, 1-999=progress in permille, 1000=success and done
|
||||||
|
progress: usize,
|
||||||
|
|
||||||
|
/// Progress comment or error, something to display to the user.
|
||||||
|
comment: Option<String>,
|
||||||
|
},
|
||||||
|
|
||||||
/// Inform about the import/export progress started by imex().
|
/// Inform about the import/export progress started by imex().
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user