mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46: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 context The context object.
|
||||||
* @param msg_id The ID of the message with the webxdc instance.
|
* @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
|
* @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::SelfavatarChanged => 2110,
|
||||||
EventType::WebxdcStatusUpdate { .. } => 2120,
|
EventType::WebxdcStatusUpdate { .. } => 2120,
|
||||||
EventType::WebxdcInstanceDeleted { .. } => 2121,
|
EventType::WebxdcInstanceDeleted { .. } => 2121,
|
||||||
EventType::WebxdcBusyUpdating { .. } => 2022,
|
EventType::WebxdcUpdateStateChanged { .. } => 2022,
|
||||||
EventType::WebxdcUpToDate { .. } => 2023,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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::WebxdcStatusUpdate { msg_id, .. } => msg_id.to_u32() as libc::c_int,
|
||||||
EventType::WebxdcInstanceDeleted { 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::WebxdcUpdateStateChanged { msg_id, .. } => msg_id.to_u32() as libc::c_int,
|
||||||
EventType::WebxdcUpToDate { 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,
|
||||||
..
|
..
|
||||||
} => status_update_serial.to_u32() as libc::c_int,
|
} => 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::SelfavatarChanged
|
||||||
| EventType::WebxdcStatusUpdate { .. }
|
| EventType::WebxdcStatusUpdate { .. }
|
||||||
| EventType::WebxdcInstanceDeleted { .. }
|
| EventType::WebxdcInstanceDeleted { .. }
|
||||||
| EventType::WebxdcBusyUpdating { .. }
|
| EventType::WebxdcUpdateStateChanged { .. }
|
||||||
| EventType::WebxdcUpToDate { .. }
|
|
||||||
| EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(),
|
| EventType::ChatEphemeralTimerModified { .. } => ptr::null_mut(),
|
||||||
EventType::ConfigureProgress { comment, .. } => {
|
EventType::ConfigureProgress { comment, .. } => {
|
||||||
if let Some(comment) = comment {
|
if let Some(comment) = comment {
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ pub enum JSONRPCEventType {
|
|||||||
},
|
},
|
||||||
WebxdcBusyUpdating,
|
WebxdcBusyUpdating,
|
||||||
WebxdcUpToDate,
|
WebxdcUpToDate,
|
||||||
|
WebxdcUpdateStateChanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EventType> for JSONRPCEventType {
|
impl From<EventType> for JSONRPCEventType {
|
||||||
@@ -383,8 +384,9 @@ impl From<EventType> for JSONRPCEventType {
|
|||||||
EventType::WebxdcInstanceDeleted { msg_id } => WebxdcInstanceDeleted {
|
EventType::WebxdcInstanceDeleted { msg_id } => WebxdcInstanceDeleted {
|
||||||
msg_id: msg_id.to_u32(),
|
msg_id: msg_id.to_u32(),
|
||||||
},
|
},
|
||||||
EventType::WebxdcBusyUpdating { .. } => WebxdcBusyUpdating,
|
EventType::WebxdcStatusUpdate { .. } => WebxdcStatusUpdate,
|
||||||
EventType::WebxdcUpToDate { .. } => WebxdcUpToDate,
|
EventType::WebxdcInstanceDeleted { .. } => WebxdcInstanceDeleted,
|
||||||
|
EventType::WebxdcUpdateStateChanged { .. } => WebxdcUpdateStateChanged,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,11 +319,9 @@ pub enum EventType {
|
|||||||
msg_id: MsgId,
|
msg_id: MsgId,
|
||||||
},
|
},
|
||||||
|
|
||||||
WebxdcBusyUpdating {
|
/// Inform that the webxdc changed its update sending state
|
||||||
msg_id: MsgId,
|
WebxdcUpdateStateChanged {
|
||||||
},
|
|
||||||
|
|
||||||
WebxdcUpToDate {
|
|
||||||
msg_id: MsgId,
|
msg_id: MsgId,
|
||||||
|
is_sending: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,8 +380,9 @@ impl Context {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.emit_event(EventType::WebxdcBusyUpdating {
|
self.emit_event(EventType::WebxdcUpdateStateChanged {
|
||||||
msg_id: instance.id,
|
msg_id: instance.id,
|
||||||
|
is_sending: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if send_now {
|
if send_now {
|
||||||
@@ -449,7 +450,10 @@ impl Context {
|
|||||||
}
|
}
|
||||||
let update_needed_after_sending = get_busy_webxdc_instances(self).await?;
|
let update_needed_after_sending = get_busy_webxdc_instances(self).await?;
|
||||||
for msg_id in update_needed.difference(&update_needed_after_sending) {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -2423,14 +2427,30 @@ sth_for_the = "future""#
|
|||||||
.await?;
|
.await?;
|
||||||
alice
|
alice
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::WebxdcBusyUpdating { .. }))
|
.get_matching(|evt| {
|
||||||
|
matches!(
|
||||||
|
evt,
|
||||||
|
EventType::WebxdcUpdateStateChanged {
|
||||||
|
is_sending: true,
|
||||||
|
..
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
alice.flush_status_updates().await?;
|
alice.flush_status_updates().await?;
|
||||||
|
|
||||||
alice
|
alice
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::WebxdcUpToDate { .. }))
|
.get_matching(|evt| {
|
||||||
|
matches!(
|
||||||
|
evt,
|
||||||
|
EventType::WebxdcUpdateStateChanged {
|
||||||
|
is_sending: false,
|
||||||
|
..
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user