mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 18:36:30 +03:00
change event usage
This commit is contained in:
@@ -1084,13 +1084,12 @@ char* dc_get_webxdc_status_updates (dc_context_t* context, uint32_t msg_id, uint
|
||||
|
||||
|
||||
/**
|
||||
* List all webxdc that have updates in the queue
|
||||
* Return wether webxdc with `msg_id` is updating
|
||||
* @param context The context object.
|
||||
* @param msg_id The ID of the message with the webxdc instance.
|
||||
* @return 1=contact ID is member of chat ID, 0=contact is not in chat
|
||||
*
|
||||
*/
|
||||
int dc_get_updating_webxdc (dc_context_t* context, uint32_t chat_id);
|
||||
int dc_is_webxdc_updating (dc_context_t* context, uint32_t chat_id);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -521,8 +521,7 @@ pub unsafe extern "C" fn dc_event_get_id(event: *mut dc_event_t) -> libc::c_int
|
||||
EventType::SelfavatarChanged => 2110,
|
||||
EventType::WebxdcStatusUpdate { .. } => 2120,
|
||||
EventType::WebxdcInstanceDeleted { .. } => 2121,
|
||||
EventType::WebxdcBusyUpdating { .. } => 2022,
|
||||
EventType::WebxdcUpToDate { .. } => 2023,
|
||||
EventType::WebxdcUpdateStateChanged { .. } => 2022,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,8 +571,7 @@ pub unsafe extern "C" fn dc_event_get_data1_int(event: *mut dc_event_t) -> libc:
|
||||
}
|
||||
EventType::WebxdcStatusUpdate { msg_id, .. } => msg_id.to_u32() as libc::c_int,
|
||||
EventType::WebxdcInstanceDeleted { msg_id, .. } => msg_id.to_u32() as libc::c_int,
|
||||
EventType::WebxdcBusyUpdating { msg_id } => msg_id.to_u32() as libc::c_int,
|
||||
EventType::WebxdcUpToDate { msg_id } => msg_id.to_u32() as libc::c_int,
|
||||
EventType::WebxdcUpdateStateChanged { msg_id, .. } => msg_id.to_u32() as libc::c_int,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,6 +622,10 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
|
||||
status_update_serial,
|
||||
..
|
||||
} => status_update_serial.to_u32() as libc::c_int,
|
||||
EventType::WebxdcUpdateStateChanged {
|
||||
is_sending: is_send,
|
||||
..
|
||||
} => *is_send as libc::c_int,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,8 +670,7 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
|
||||
| EventType::SelfavatarChanged
|
||||
| EventType::WebxdcStatusUpdate { .. }
|
||||
| EventType::WebxdcInstanceDeleted { .. }
|
||||
| EventType::WebxdcBusyUpdating { .. }
|
||||
| EventType::WebxdcUpToDate { .. }
|
||||
| EventType::WebxdcUpdateStateChanged { .. }
|
||||
| EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(),
|
||||
EventType::ConfigureProgress { comment, .. } => {
|
||||
if let Some(comment) = comment {
|
||||
|
||||
@@ -283,6 +283,7 @@ pub enum JSONRPCEventType {
|
||||
},
|
||||
WebxdcBusyUpdating,
|
||||
WebxdcUpToDate,
|
||||
WebxdcUpdateStateChanged,
|
||||
}
|
||||
|
||||
impl From<EventType> for JSONRPCEventType {
|
||||
@@ -383,8 +384,9 @@ impl From<EventType> for JSONRPCEventType {
|
||||
EventType::WebxdcInstanceDeleted { msg_id } => WebxdcInstanceDeleted {
|
||||
msg_id: msg_id.to_u32(),
|
||||
},
|
||||
EventType::WebxdcBusyUpdating { .. } => WebxdcBusyUpdating,
|
||||
EventType::WebxdcUpToDate { .. } => WebxdcUpToDate,
|
||||
EventType::WebxdcStatusUpdate { .. } => WebxdcStatusUpdate,
|
||||
EventType::WebxdcInstanceDeleted { .. } => WebxdcInstanceDeleted,
|
||||
EventType::WebxdcUpdateStateChanged { .. } => WebxdcUpdateStateChanged,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,11 +319,9 @@ pub enum EventType {
|
||||
msg_id: MsgId,
|
||||
},
|
||||
|
||||
WebxdcBusyUpdating {
|
||||
msg_id: MsgId,
|
||||
},
|
||||
|
||||
WebxdcUpToDate {
|
||||
/// Inform that the webxdc changed its update sending state
|
||||
WebxdcUpdateStateChanged {
|
||||
msg_id: MsgId,
|
||||
is_sending: bool,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -380,8 +380,9 @@ impl Context {
|
||||
)
|
||||
.await?;
|
||||
|
||||
self.emit_event(EventType::WebxdcBusyUpdating {
|
||||
self.emit_event(EventType::WebxdcUpdateStateChanged {
|
||||
msg_id: instance.id,
|
||||
is_sending: true,
|
||||
});
|
||||
|
||||
if send_now {
|
||||
@@ -449,7 +450,10 @@ impl Context {
|
||||
}
|
||||
let update_needed_after_sending = get_busy_webxdc_instances(self).await?;
|
||||
for msg_id in update_needed.difference(&update_needed_after_sending) {
|
||||
self.emit_event(EventType::WebxdcUpToDate { msg_id: *msg_id })
|
||||
self.emit_event(EventType::WebxdcUpdateStateChanged {
|
||||
msg_id: *msg_id,
|
||||
is_sending: false,
|
||||
})
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -2423,14 +2427,30 @@ sth_for_the = "future""#
|
||||
.await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_matching(|evt| matches!(evt, EventType::WebxdcBusyUpdating { .. }))
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
EventType::WebxdcUpdateStateChanged {
|
||||
is_sending: true,
|
||||
..
|
||||
}
|
||||
)
|
||||
})
|
||||
.await;
|
||||
|
||||
alice.flush_status_updates().await?;
|
||||
|
||||
alice
|
||||
.evtracker
|
||||
.get_matching(|evt| matches!(evt, EventType::WebxdcUpToDate { .. }))
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
EventType::WebxdcUpdateStateChanged {
|
||||
is_sending: false,
|
||||
..
|
||||
}
|
||||
)
|
||||
})
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user