feat: cm interface

This commit is contained in:
Kingtous 2023-02-06 12:53:57 +08:00
parent 850c4bcbbf
commit 040396b3f8
5 changed files with 53 additions and 0 deletions

View File

@ -537,6 +537,18 @@ pub mod connection_manager {
fn show_elevation(&self, show: bool) { fn show_elevation(&self, show: bool) {
self.push_event("show_elevation", vec![("show", &show.to_string())]); self.push_event("show_elevation", vec![("show", &show.to_string())]);
} }
fn voice_call_started(&self, id: i32) {
self.push_event("voice_call_started", vec![("show", &id.to_string())]);
}
fn voice_call_incoming(&self, id: i32) {
self.push_event("voice_call_incoming", vec![("id", &id.to_string())]);
}
fn voice_call_closed(&self, id: i32, reason: &str) {
self.push_event("voice_call_closed", vec![("id", &id.to_string()), ("reason", &reason.to_string())]);
}
} }
impl FlutterHandler { impl FlutterHandler {

View File

@ -212,6 +212,7 @@ pub enum Data {
SwitchSidesBack, SwitchSidesBack,
UrlLink(String), UrlLink(String),
VoiceCallIncoming, VoiceCallIncoming,
StartVoiceCall,
VoiceCallResponse(bool), VoiceCallResponse(bool),
CloseVoiceCall(String), CloseVoiceCall(String),
} }

View File

@ -1624,6 +1624,7 @@ impl Connection {
if let Some(device) = default_sound_device { if let Some(device) = default_sound_device {
set_sound_input(device); set_sound_input(device);
} }
self.send_to_cm(Data::StartVoiceCall);
} }
} else { } else {
log::warn!("Possible a voice call attack."); log::warn!("Possible a voice call attack.");

View File

@ -55,6 +55,18 @@ impl InvokeUiCM for SciterHandler {
fn show_elevation(&self, show: bool) { fn show_elevation(&self, show: bool) {
self.call("showElevation", &make_args!(show)); self.call("showElevation", &make_args!(show));
} }
fn voice_call_started(&self, id: i32) {
self.call("voice_call_started", &make_args!(id));
}
fn voice_call_incoming(&self, id: i32) {
self.call("voice_call_incoming", &make_args!(id));
}
fn voice_call_closed(&self, id: i32, reason: &str) {
self.call("voice_call_incoming", &make_args!(id, reason));
}
} }
impl SciterHandler { impl SciterHandler {

View File

@ -88,6 +88,12 @@ pub trait InvokeUiCM: Send + Clone + 'static + Sized {
fn change_language(&self); fn change_language(&self);
fn show_elevation(&self, show: bool); fn show_elevation(&self, show: bool);
fn voice_call_started(&self, id: i32);
fn voice_call_incoming(&self, id: i32);
fn voice_call_closed(&self, id: i32, reason: &str);
} }
impl<T: InvokeUiCM> Deref for ConnectionManager<T> { impl<T: InvokeUiCM> Deref for ConnectionManager<T> {
@ -180,6 +186,18 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
fn show_elevation(&self, show: bool) { fn show_elevation(&self, show: bool) {
self.ui_handler.show_elevation(show); self.ui_handler.show_elevation(show);
} }
fn voice_call_started(&self, id: i32) {
self.ui_handler.voice_call_started(id);
}
fn voice_call_incoming(&self, id: i32) {
self.ui_handler.voice_call_incoming(id);
}
fn voice_call_closed(&self, id: i32, reason: &str) {
self.ui_handler.voice_call_closed(id, reason);
}
} }
#[inline] #[inline]
@ -389,6 +407,15 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
Data::DataPortableService(ipc::DataPortableService::CmShowElevation(show)) => { Data::DataPortableService(ipc::DataPortableService::CmShowElevation(show)) => {
self.cm.show_elevation(show); self.cm.show_elevation(show);
} }
Data::StartVoiceCall => {
self.cm.voice_call_started(self.conn_id);
}
Data::VoiceCallIncoming => {
self.cm.voice_call_incoming(self.conn_id);
}
Data::CloseVoiceCall(reason) => {
self.cm.voice_call_closed(self.conn_id, reason.as_str());
}
_ => { _ => {
} }