mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 23:52:11 +03:00
Add Params::set_cmd and use SystemMessage constants
This commit is contained in:
committed by
Floris Bruynooghe
parent
dced1932b3
commit
cfa69cf35a
@@ -1419,7 +1419,7 @@ pub(crate) fn add_contact_to_chat_ex(
|
||||
"",
|
||||
DC_CONTACT_ID_SELF as u32,
|
||||
));
|
||||
msg.param.set_int(Param::Cmd, 4);
|
||||
msg.param.set_cmd(SystemMessage::MemberAddedToGroup);
|
||||
msg.param.set(Param::Arg, contact.get_addr());
|
||||
msg.param.set_int(Param::Arg2, from_handshake.into());
|
||||
msg.id = send_msg(context, chat_id, &mut msg)?;
|
||||
@@ -1531,7 +1531,7 @@ pub fn remove_contact_from_chat(
|
||||
DC_CONTACT_ID_SELF,
|
||||
));
|
||||
}
|
||||
msg.param.set_int(Param::Cmd, 5);
|
||||
msg.param.set_cmd(SystemMessage::MemberRemovedFromGroup);
|
||||
msg.param.set(Param::Arg, contact.get_addr());
|
||||
msg.id = send_msg(context, chat_id, &mut msg)?;
|
||||
context.call_cb(Event::MsgsChanged {
|
||||
@@ -1626,7 +1626,7 @@ pub fn set_chat_name(
|
||||
new_name.as_ref(),
|
||||
DC_CONTACT_ID_SELF,
|
||||
));
|
||||
msg.param.set_int(Param::Cmd, 2);
|
||||
msg.param.set_cmd(SystemMessage::GroupNameChanged);
|
||||
if !chat.name.is_empty() {
|
||||
msg.param.set(Param::Arg, &chat.name);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::config::Config;
|
||||
use crate::configure::*;
|
||||
use crate::constants::*;
|
||||
use crate::context::Context;
|
||||
use crate::dc_mimeparser::SystemMessage;
|
||||
use crate::dc_tools::*;
|
||||
use crate::e2ee;
|
||||
use crate::error::*;
|
||||
@@ -136,7 +137,7 @@ fn do_initiate_key_transfer(context: &Context) -> Result<String> {
|
||||
|
||||
msg.param
|
||||
.set(Param::MimeType, "application/autocrypt-setup");
|
||||
msg.param.set_int(Param::Cmd, 6);
|
||||
msg.param.set_cmd(SystemMessage::AutocryptSetupMessage);
|
||||
msg.param
|
||||
.set_int(Param::ForcePlaintext, DC_FP_NO_AUTOCRYPT_HEADER);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::chat;
|
||||
use crate::config::Config;
|
||||
use crate::constants::*;
|
||||
use crate::context::*;
|
||||
use crate::dc_mimeparser::SystemMessage;
|
||||
use crate::dc_tools::*;
|
||||
use crate::error::Error;
|
||||
use crate::events::Event;
|
||||
@@ -218,7 +219,7 @@ pub fn send_locations_to_chat(context: &Context, chat_id: u32, seconds: i64) {
|
||||
msg = Message::new(Viewtype::Text);
|
||||
msg.text =
|
||||
Some(context.stock_system_msg(StockMessage::MsgLocationEnabled, "", "", 0));
|
||||
msg.param.set_int(Param::Cmd, 8);
|
||||
msg.param.set_cmd(SystemMessage::LocationStreamingEnabled);
|
||||
chat::send_msg(context, chat_id, &mut msg).unwrap_or_default();
|
||||
} else if 0 == seconds && is_sending_locations_before {
|
||||
let stock_str =
|
||||
@@ -603,7 +604,7 @@ pub fn job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: &Job) {
|
||||
// and dc_set_location() is typically called periodically, this is ok)
|
||||
let mut msg = Message::new(Viewtype::Text);
|
||||
msg.hidden = true;
|
||||
msg.param.set_int(Param::Cmd, 9);
|
||||
msg.param.set_cmd(SystemMessage::LocationOnly);
|
||||
Some((chat_id, msg))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -189,6 +189,11 @@ impl Params {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Set the parameter behind `Param::Cmd`.
|
||||
pub fn set_cmd(&mut self, value: SystemMessage) {
|
||||
self.set_int(Param::Cmd, value as i32);
|
||||
}
|
||||
|
||||
/// Get the given parameter and parse as `f64`.
|
||||
pub fn get_float(&self, key: Param) -> Option<f64> {
|
||||
self.get(key).and_then(|s| s.parse().ok())
|
||||
|
||||
@@ -257,7 +257,7 @@ fn send_handshake_msg(
|
||||
msg.type_0 = Viewtype::Text;
|
||||
msg.text = Some(format!("Secure-Join: {}", step));
|
||||
msg.hidden = true;
|
||||
msg.param.set_int(Param::Cmd, 7);
|
||||
msg.param.set_cmd(SystemMessage::SecurejoinMessage);
|
||||
if step.is_empty() {
|
||||
msg.param.remove(Param::Arg);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user