Added type DownloadState

This commit is contained in:
flipsimon
2022-07-26 11:51:04 +02:00
parent 15019ce02b
commit 8160a3c60a
2 changed files with 41 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
use anyhow::{anyhow, Result};
use deltachat::contact::Contact;
use deltachat::context::Context;
use deltachat::download::DownloadState;
use deltachat::message::Message;
use deltachat::message::MsgId;
use deltachat::message::Viewtype;
@@ -53,6 +54,8 @@ pub struct MessageObject {
file_mime: Option<String>,
file_bytes: u64,
file_name: Option<String>,
download_state: MessageDownloadState
}
impl MessageObject {
@@ -121,6 +124,8 @@ impl MessageObject {
file_mime: message.get_filemime(),
file_bytes,
file_name: message.get_filename(),
download_state: message.download_state().try_into().unwrap()
})
}
}
@@ -165,6 +170,7 @@ pub enum MessageViewtype {
Webxdc,
}
impl From<Viewtype> for MessageViewtype {
fn from(viewtype: Viewtype) -> Self {
match viewtype {
@@ -200,3 +206,36 @@ impl From<MessageViewtype> for Viewtype {
}
}
}
#[derive(Serialize, Deserialize, TypeDef)]
#[serde(rename = "DownloadState")]
pub enum MessageDownloadState {
Done,
Available,
Failure,
InProgress
}
impl From<DownloadState> for MessageDownloadState{
fn from(download_state: DownloadState) -> Self {
match download_state {
DownloadState::Done => MessageDownloadState::Done,
DownloadState::Available => MessageDownloadState::Available,
DownloadState::Failure => MessageDownloadState::Failure,
DownloadState::InProgress => MessageDownloadState::InProgress
}
}
}
impl From<MessageDownloadState> for DownloadState {
fn from(message_download_state: MessageDownloadState) -> Self {
match message_download_state {
MessageDownloadState::Done => DownloadState::Done,
MessageDownloadState::Available => DownloadState::Available,
MessageDownloadState::Failure => DownloadState::Failure,
MessageDownloadState::InProgress => DownloadState::InProgress
}
}
}

View File

@@ -60,7 +60,8 @@ export type Viewtype=("Unknown"|
"Webxdc");
export type I32=number;
export type U64=number;
export type Message={"id":U32;"chatId":U32;"fromId":U32;"quotedText":(string|null);"quotedMessageId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);};
export type DownloadState=("Done"|"Available"|"Failure"|"InProgress");
export type Message={"id":U32;"chatId":U32;"fromId":U32;"quotedText":(string|null);"quotedMessageId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);"downloadState":DownloadState;};
export type WebxdcMessageInfo={
/**
* The name of the app.