pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
Expand description
The context for a single DeltaChat account.
This contains all the state for a single DeltaChat account, including background tasks
running in Tokio to operate the account. The Context
can be cheaply cloned.
Each context, and thus each account, must be associated with an directory where all the state is kept. This state is also preserved between restarts.
To use multiple accounts it is best to look at the accounts manager which handles storing multiple accounts in a single directory structure and handles loading them all concurrently.
Fields§
§inner: Arc<InnerContext>
Implementations§
source§impl Context
impl Context
sourcepub fn set_last_error(&self, error: &str)
pub fn set_last_error(&self, error: &str)
Set last error string. Implemented as blocking as used from macros in different, not always async blocks.
sourcepub fn get_last_error(&self) -> String
pub fn get_last_error(&self) -> String
Get last error string.
source§impl Context
impl Context
sourcepub(crate) async fn sync_alter_chat(
&self,
id: &SyncId,
action: &SyncAction,
) -> Result<()>
pub(crate) async fn sync_alter_chat( &self, id: &SyncId, action: &SyncAction, ) -> Result<()>
Executes SyncData::AlterChat
item sent by other device.
sourcepub(crate) fn on_archived_chats_maybe_noticed(&self)
pub(crate) fn on_archived_chats_maybe_noticed(&self)
Emits the appropriate MsgsChanged
event. Should be called if the number of unnoticed
archived chats could decrease. In general we don’t want to make an extra db query to know if
a noticied chat is archived. Emitting events should be cheap, a false-positive MsgsChanged
is ok.
source§impl Context
impl Context
sourcepub(crate) async fn config_exists(&self, key: Config) -> Result<bool>
pub(crate) async fn config_exists(&self, key: Config) -> Result<bool>
Returns true if configuration value is set in the db for the given key.
NB: Don’t use this to check if the key is configured because this doesn’t look into environment. The proper use of this function is e.g. checking a key before setting it.
sourcepub(crate) async fn get_config_opt(&self, key: Config) -> Result<Option<String>>
pub(crate) async fn get_config_opt(&self, key: Config) -> Result<Option<String>>
Get a config key value. Returns None
if no value is set.
sourcepub async fn get_config(&self, key: Config) -> Result<Option<String>>
pub async fn get_config(&self, key: Config) -> Result<Option<String>>
Get a config key value if set, or a default value. Returns None
if no value exists.
sourcepub(crate) async fn get_config_opt_parsed<T: FromStr>(
&self,
key: Config,
) -> Result<Option<T>>
pub(crate) async fn get_config_opt_parsed<T: FromStr>( &self, key: Config, ) -> Result<Option<T>>
Returns Some(T) if a value for the given key is set and was successfully parsed. Returns None if could not parse.
sourcepub async fn get_config_parsed<T: FromStr>(
&self,
key: Config,
) -> Result<Option<T>>
pub async fn get_config_parsed<T: FromStr>( &self, key: Config, ) -> Result<Option<T>>
Returns Some(T) if a value for the given key exists (incl. default value) and was successfully parsed. Returns None if could not parse.
sourcepub async fn get_config_int(&self, key: Config) -> Result<i32>
pub async fn get_config_int(&self, key: Config) -> Result<i32>
Returns 32-bit signed integer configuration value for the given key.
sourcepub async fn get_config_u32(&self, key: Config) -> Result<u32>
pub async fn get_config_u32(&self, key: Config) -> Result<u32>
Returns 32-bit unsigned integer configuration value for the given key.
sourcepub async fn get_config_i64(&self, key: Config) -> Result<i64>
pub async fn get_config_i64(&self, key: Config) -> Result<i64>
Returns 64-bit signed integer configuration value for the given key.
sourcepub async fn get_config_u64(&self, key: Config) -> Result<u64>
pub async fn get_config_u64(&self, key: Config) -> Result<u64>
Returns 64-bit unsigned integer configuration value for the given key.
sourcepub(crate) async fn get_config_bool_opt(
&self,
key: Config,
) -> Result<Option<bool>>
pub(crate) async fn get_config_bool_opt( &self, key: Config, ) -> Result<Option<bool>>
Returns boolean configuration value (if set) for the given key.
sourcepub async fn get_config_bool(&self, key: Config) -> Result<bool>
pub async fn get_config_bool(&self, key: Config) -> Result<bool>
Returns boolean configuration value for the given key.
sourcepub(crate) async fn should_watch_mvbox(&self) -> Result<bool>
pub(crate) async fn should_watch_mvbox(&self) -> Result<bool>
Returns true if movebox (“DeltaChat” folder) should be watched.
sourcepub(crate) async fn should_watch_sentbox(&self) -> Result<bool>
pub(crate) async fn should_watch_sentbox(&self) -> Result<bool>
Returns true if sentbox (“Sent” folder) should be watched.
sourcepub(crate) async fn should_send_sync_msgs(&self) -> Result<bool>
pub(crate) async fn should_send_sync_msgs(&self) -> Result<bool>
Returns true if sync messages should be sent.
sourcepub(crate) async fn should_move_sync_msgs(&self) -> Result<bool>
pub(crate) async fn should_move_sync_msgs(&self) -> Result<bool>
Returns whether sync messages should be uploaded to the mvbox.
sourcepub(crate) async fn should_request_mdns(&self) -> Result<bool>
pub(crate) async fn should_request_mdns(&self) -> Result<bool>
Returns whether MDNs should be requested.
sourcepub(crate) async fn should_send_mdns(&self) -> Result<bool>
pub(crate) async fn should_send_mdns(&self) -> Result<bool>
Returns whether MDNs should be sent.
sourcepub async fn get_config_delete_server_after(&self) -> Result<Option<i64>>
pub async fn get_config_delete_server_after(&self) -> Result<Option<i64>>
Gets configured “delete_server_after” value.
None
means never delete the message, Some(0)
means delete
at once, Some(x)
means delete after x
seconds.
sourcepub async fn get_configured_provider(&self) -> Result<Option<&'static Provider>>
pub async fn get_configured_provider(&self) -> Result<Option<&'static Provider>>
Gets the configured provider, as saved in the configured_provider
value.
The provider is determined by get_provider_info()
during configuration and then saved
to the db in param.save_to_database()
, together with all the other configured_*
values.
sourcepub async fn get_config_delete_device_after(&self) -> Result<Option<i64>>
pub async fn get_config_delete_device_after(&self) -> Result<Option<i64>>
Gets configured “delete_device_after” value.
None
means never delete the message, Some(x)
means delete
after x
seconds.
sourcepub(crate) async fn sync_config(&self, key: &Config, value: &str) -> Result<()>
pub(crate) async fn sync_config(&self, key: &Config, value: &str) -> Result<()>
Executes SyncData::Config
item sent by other device.
fn check_config(key: Config, value: Option<&str>) -> Result<()>
sourcepub async fn set_config(&self, key: Config, value: Option<&str>) -> Result<()>
pub async fn set_config(&self, key: Config, value: Option<&str>) -> Result<()>
Set the given config key and make it effective.
This may restart the IO scheduler. If None
is passed as a value the value is cleared and
set to the default if there is one.
pub(crate) async fn set_config_internal( &self, key: Config, value: Option<&str>, ) -> Result<()>
pub(crate) async fn set_config_ex( &self, sync: Sync, key: Config, value: Option<&str>, ) -> Result<()>
sourcepub async fn set_config_u32(&self, key: Config, value: u32) -> Result<()>
pub async fn set_config_u32(&self, key: Config, value: u32) -> Result<()>
Set the given config to an unsigned 32-bit integer value.
sourcepub async fn set_config_bool(&self, key: Config, value: bool) -> Result<()>
pub async fn set_config_bool(&self, key: Config, value: bool) -> Result<()>
Set the given config to a boolean value.
source§impl Context
impl Context
sourcepub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool>
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool>
Determine whether the specified addr maps to the/a self addr.
Returns false
if no addresses are configured.
sourcepub(crate) async fn set_primary_self_addr(
&self,
primary_new: &str,
) -> Result<()>
pub(crate) async fn set_primary_self_addr( &self, primary_new: &str, ) -> Result<()>
Sets primary_new
as the new primary self address and saves the old
primary address (if exists) as a secondary address.
This should only be used by test code and during configure.
sourcepub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>>
pub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>>
Returns all primary and secondary self addresses.
sourcepub(crate) async fn get_secondary_self_addrs(&self) -> Result<Vec<String>>
pub(crate) async fn get_secondary_self_addrs(&self) -> Result<Vec<String>>
Returns all secondary self addresses.
sourcepub async fn get_primary_self_addr(&self) -> Result<String>
pub async fn get_primary_self_addr(&self) -> Result<String>
Returns the primary self address. Returns an error if no self addr is configured.
source§impl Context
impl Context
sourcepub async fn new(
dbfile: &Path,
id: u32,
events: Events,
stock_strings: StockStrings,
) -> Result<Context>
pub async fn new( dbfile: &Path, id: u32, events: Events, stock_strings: StockStrings, ) -> Result<Context>
Creates new context and opens the database.
sourcepub async fn new_closed(
dbfile: &Path,
id: u32,
events: Events,
stockstrings: StockStrings,
push_subscriber: PushSubscriber,
) -> Result<Context>
pub async fn new_closed( dbfile: &Path, id: u32, events: Events, stockstrings: StockStrings, push_subscriber: PushSubscriber, ) -> Result<Context>
Creates new context without opening the database.
sourcepub async fn open(&self, passphrase: String) -> Result<bool>
pub async fn open(&self, passphrase: String) -> Result<bool>
Opens the database with the given passphrase.
Returns true if passphrase is correct, false is passphrase is not correct. Fails on other errors.
sourcepub async fn change_passphrase(&self, passphrase: String) -> Result<()>
pub async fn change_passphrase(&self, passphrase: String) -> Result<()>
Changes encrypted database passphrase.
sourcepub(crate) async fn check_passphrase(&self, passphrase: String) -> Result<bool>
pub(crate) async fn check_passphrase(&self, passphrase: String) -> Result<bool>
Tests the database passphrase.
Returns true if passphrase is correct.
Fails if database is already open.
pub(crate) fn with_blobdir( dbfile: PathBuf, blobdir: PathBuf, id: u32, events: Events, stockstrings: StockStrings, push_subscriber: PushSubscriber, ) -> Result<Context>
sourcepub async fn restart_io_if_running(&self)
pub async fn restart_io_if_running(&self)
Restarts the IO scheduler if it was running before when it is not running this is an no-op
sourcepub async fn maybe_network(&self)
pub async fn maybe_network(&self)
Indicate that the network likely has come back.
sourcepub async fn is_chatmail(&self) -> Result<bool>
pub async fn is_chatmail(&self) -> Result<bool>
Returns true if an account is on a chatmail server.
sourcepub(crate) async fn get_max_smtp_rcpt_to(&self) -> Result<usize>
pub(crate) async fn get_max_smtp_rcpt_to(&self) -> Result<usize>
Returns maximum number of recipients the provider allows to send a single email to.
sourcepub async fn background_fetch(&self) -> Result<()>
pub async fn background_fetch(&self) -> Result<()>
Does a single round of fetching from IMAP and returns.
Can be used even if I/O is currently stopped. If I/O is currently stopped, starts a new IMAP connection and fetches from Inbox and DeltaChat folders.
pub(crate) async fn schedule_resync(&self) -> Result<()>
sourcepub fn get_dbfile(&self) -> &Path
pub fn get_dbfile(&self) -> &Path
Returns database file path.
sourcepub fn get_blobdir(&self) -> &Path
pub fn get_blobdir(&self) -> &Path
Returns blob directory path.
sourcepub fn emit_event(&self, event: EventType)
pub fn emit_event(&self, event: EventType)
Emits a single event.
sourcepub fn emit_msgs_changed_without_ids(&self)
pub fn emit_msgs_changed_without_ids(&self)
Emits a generic MsgsChanged event (without chat or message id)
sourcepub fn emit_msgs_changed(&self, chat_id: ChatId, msg_id: MsgId)
pub fn emit_msgs_changed(&self, chat_id: ChatId, msg_id: MsgId)
Emits a MsgsChanged event with specified chat and message ids
sourcepub fn emit_incoming_msg(&self, chat_id: ChatId, msg_id: MsgId)
pub fn emit_incoming_msg(&self, chat_id: ChatId, msg_id: MsgId)
Emits an IncomingMsg event with specified chat and message ids
sourcepub async fn emit_location_changed(
&self,
contact_id: Option<ContactId>,
) -> Result<()>
pub async fn emit_location_changed( &self, contact_id: Option<ContactId>, ) -> Result<()>
Emits an LocationChanged event and a WebxdcStatusUpdate in case there is a maps integration
sourcepub fn get_event_emitter(&self) -> EventEmitter
pub fn get_event_emitter(&self) -> EventEmitter
Returns a receiver for emitted events.
Multiple emitters can be created, but note that in this case each emitted event will only be received by one of the emitters, not by all of them.
sourcepub(crate) async fn alloc_ongoing(&self) -> Result<Receiver<()>>
pub(crate) async fn alloc_ongoing(&self) -> Result<Receiver<()>>
Tries to acquire the global UI “ongoing” mutex.
This is for modal operations during which no other user actions are allowed. Only one such operation is allowed at any given time.
The return value is a cancel token, which will release the ongoing mutex when dropped.
pub(crate) async fn free_ongoing(&self)
sourcepub async fn stop_ongoing(&self)
pub async fn stop_ongoing(&self)
Signal an ongoing process to stop.
pub(crate) async fn shall_stop_ongoing(&self) -> bool
sourcepub async fn get_info(&self) -> Result<BTreeMap<&'static str, String>>
pub async fn get_info(&self) -> Result<BTreeMap<&'static str, String>>
Returns information about the context as key-value pairs.
async fn get_self_report(&self) -> Result<String>
sourcepub async fn draft_self_report(&self) -> Result<ChatId>
pub async fn draft_self_report(&self) -> Result<ChatId>
Drafts a message with statistics about the usage of Delta Chat. The user can inspect the message if they want, and then hit “Send”.
On the other end, a bot will receive the message and make it available to Delta Chat’s developers.
sourcepub async fn get_fresh_msgs(&self) -> Result<Vec<MsgId>>
pub async fn get_fresh_msgs(&self) -> Result<Vec<MsgId>>
Get a list of fresh, unmuted messages in unblocked chats.
The list starts with the most recent message and is typically used to show notifications. Moreover, the number of returned messages can be used for a badge counter on the app icon.
sourcepub async fn get_next_msgs(&self) -> Result<Vec<MsgId>>
pub async fn get_next_msgs(&self) -> Result<Vec<MsgId>>
Returns a list of messages with database ID higher than requested.
Blocked contacts and chats are excluded, but self-sent messages and contact requests are included in the results.
sourcepub async fn wait_next_msgs(&self) -> Result<Vec<MsgId>>
pub async fn wait_next_msgs(&self) -> Result<Vec<MsgId>>
Returns a list of messages with database ID higher than last marked as seen.
This function is supposed to be used by bot to request messages that are not processed yet.
Waits for notification and returns a result.
Note that the result may be empty if the message is deleted
shortly after notification or notification is manually triggered
to interrupt waiting.
Notification may be manually triggered by calling Self::stop_io
.
sourcepub async fn search_msgs(
&self,
chat_id: Option<ChatId>,
query: &str,
) -> Result<Vec<MsgId>>
pub async fn search_msgs( &self, chat_id: Option<ChatId>, query: &str, ) -> Result<Vec<MsgId>>
Searches for messages containing the query string case-insensitively.
If chat_id
is provided this searches only for messages in this chat, if chat_id
is None
this searches messages from all chats.
NB: Wrt the search in long messages which are shown truncated with the “Show Full Message…” button, we only look at the first several kilobytes. Let’s not fix this – one can send a dictionary in the message that matches any reasonable search request, but the user won’t see the match because they should tap on “Show Full Message…” for that. Probably such messages would only clutter search results.
sourcepub async fn is_inbox(&self, folder_name: &str) -> Result<bool>
pub async fn is_inbox(&self, folder_name: &str) -> Result<bool>
Returns true if given folder name is the name of the inbox.
sourcepub async fn is_sentbox(&self, folder_name: &str) -> Result<bool>
pub async fn is_sentbox(&self, folder_name: &str) -> Result<bool>
Returns true if given folder name is the name of the “sent” folder.
sourcepub async fn is_mvbox(&self, folder_name: &str) -> Result<bool>
pub async fn is_mvbox(&self, folder_name: &str) -> Result<bool>
Returns true if given folder name is the name of the “DeltaChat” folder.
sourcepub async fn is_trash(&self, folder_name: &str) -> Result<bool>
pub async fn is_trash(&self, folder_name: &str) -> Result<bool>
Returns true if given folder name is the name of the trash folder.
pub(crate) async fn should_delete_to_trash(&self) -> Result<bool>
sourcepub(crate) async fn get_delete_msgs_target(&self) -> Result<String>
pub(crate) async fn get_delete_msgs_target(&self) -> Result<String>
Returns target
for deleted messages as per imap
table. Empty string means “delete w/o
moving to trash”.
pub(crate) fn derive_blobdir(dbfile: &Path) -> PathBuf
pub(crate) fn derive_walfile(dbfile: &Path) -> PathBuf
source§impl Context
impl Context
sourcepub(crate) async fn quota_needs_update(&self, ratelimit_secs: u64) -> bool
pub(crate) async fn quota_needs_update(&self, ratelimit_secs: u64) -> bool
Returns whether the quota value needs an update. If so, update_recent_quota()
should be
called.
sourcepub(crate) async fn update_recent_quota(
&self,
session: &mut ImapSession,
) -> Result<()>
pub(crate) async fn update_recent_quota( &self, session: &mut ImapSession, ) -> Result<()>
Updates quota.recent
, sets quota.modified
to the current time
and emits an event to let the UIs update connectivity view.
Moreover, once each time quota gets larger than QUOTA_WARN_THRESHOLD_PERCENTAGE
,
a device message is added.
As the message is added only once, the user is not spammed
in case for some providers the quota is always at ~100%
and new space is allocated as needed.
source§impl Context
impl Context
sourcepub async fn get_connectivity(&self) -> Connectivity
pub async fn get_connectivity(&self) -> Connectivity
Get the current connectivity, i.e. whether the device is connected to the IMAP server. One of:
- DC_CONNECTIVITY_NOT_CONNECTED (1000-1999): Show e.g. the string “Not connected” or a red dot
- DC_CONNECTIVITY_CONNECTING (2000-2999): Show e.g. the string “Connecting…” or a yellow dot
- DC_CONNECTIVITY_WORKING (3000-3999): Show e.g. the string “Updating…” or a spinning wheel
- DC_CONNECTIVITY_CONNECTED (>=4000): Show e.g. the string “Connected” or a green dot
We don’t use exact values but ranges here so that we can split up states into multiple states in the future.
Meant as a rough overview that can be shown e.g. in the title of the main screen.
If the connectivity changes, a DC_EVENT_CONNECTIVITY_CHANGED will be emitted.
sourcepub async fn get_connectivity_html(&self) -> Result<String>
pub async fn get_connectivity_html(&self) -> Result<String>
Get an overview of the current connectivity, and possibly more statistics. Meant to give the user more insight about the current status than the basic connectivity info returned by dc_get_connectivity(); show this e.g., if the user taps on said basic connectivity info.
If this page changes, a DC_EVENT_CONNECTIVITY_CHANGED will be emitted.
This comes as an HTML from the core so that we can easily improve it and the improvement instantly reaches all UIs.
sourcepub async fn all_work_done(&self) -> bool
pub async fn all_work_done(&self) -> bool
Returns true if all background work is done.
source§impl Context
impl Context
sourcepub async fn set_stock_translation(
&self,
id: StockMessage,
stockstring: String,
) -> Result<()>
pub async fn set_stock_translation( &self, id: StockMessage, stockstring: String, ) -> Result<()>
Set the stock string for the StockMessage.
sourcepub(crate) async fn stock_protection_msg(
&self,
protect: ProtectionStatus,
contact_id: Option<ContactId>,
) -> String
pub(crate) async fn stock_protection_msg( &self, protect: ProtectionStatus, contact_id: Option<ContactId>, ) -> String
Returns a stock message saying that protection status has changed.
pub(crate) async fn update_device_chats(&self) -> Result<()>
source§impl Context
impl Context
sourcepub(crate) async fn add_sync_item(&self, data: SyncData) -> Result<()>
pub(crate) async fn add_sync_item(&self, data: SyncData) -> Result<()>
Adds an item to the list of items that should be synchronized to other devices.
NB: Private and pub(crate)
functions shouldn’t call this unless Sync::Sync
is explicitly
passed to them. This way it’s always clear whether the code performs synchronisation.
sourceasync fn add_sync_item_with_timestamp(
&self,
data: SyncData,
timestamp: i64,
) -> Result<()>
async fn add_sync_item_with_timestamp( &self, data: SyncData, timestamp: i64, ) -> Result<()>
Adds item and timestamp to the list of items that should be synchronized to other devices. If device synchronization is disabled, the function does nothing.
sourcepub(crate) async fn sync_qr_code_tokens(
&self,
grpid: Option<&str>,
) -> Result<()>
pub(crate) async fn sync_qr_code_tokens( &self, grpid: Option<&str>, ) -> Result<()>
Adds most recent qr-code tokens for the given group or self-contact to the list of items to
be synced. If device synchronization is disabled,
no tokens exist or the chat is unpromoted, the function does nothing.
The caller should call SchedulerState::interrupt_inbox()
on its own to trigger sending.
sourcepub(crate) async fn sync_qr_code_token_deletion(
&self,
invitenumber: String,
auth: String,
) -> Result<()>
pub(crate) async fn sync_qr_code_token_deletion( &self, invitenumber: String, auth: String, ) -> Result<()>
Adds deleted qr-code token to the list of items to be synced so that the token also gets deleted on the other devices. This interrupts SMTP on its own.
sourcepub async fn send_sync_msg(&self) -> Result<Option<MsgId>>
pub async fn send_sync_msg(&self) -> Result<Option<MsgId>>
Sends out a self-sent message with items to be synchronized, if any.
Mustn’t be called from multiple tasks in parallel to avoid sending the same sync items twice
because sync items are removed from the db only after successful sending. We guarantee this
by calling send_sync_msg()
only from the SMTP loop.
sourcepub(crate) async fn build_sync_json(&self) -> Result<Option<(String, String)>>
pub(crate) async fn build_sync_json(&self) -> Result<Option<(String, String)>>
Copies all sync items to a JSON string and clears the sync-table. Returns the JSON string and a comma-separated string of the IDs used.
pub(crate) fn build_sync_part(&self, json: String) -> PartBuilder
sourcepub(crate) fn parse_sync_items(&self, serialized: String) -> Result<SyncItems>
pub(crate) fn parse_sync_items(&self, serialized: String) -> Result<SyncItems>
Takes a JSON string created by build_sync_json()
and construct SyncItems
from it.
sourcepub(crate) async fn execute_sync_items(&self, items: &SyncItems)
pub(crate) async fn execute_sync_items(&self, items: &SyncItems)
Executes sync items sent by other device.
CAVE: When changing the code to handle other sync items,
take care that does not result in calls to add_sync_item()
as otherwise we would add in a dead-loop between two devices
sending message back and forth.
If an error is returned, the caller shall not try over because some sync items could be already executed. Sync items are considered independent and executed in the given order but regardless of whether executing of the previous items succeeded.
async fn add_qr_token(&self, token: &QrTokenData) -> Result<()>
async fn delete_qr_token(&self, token: &QrTokenData) -> Result<()>
source§impl Context
impl Context
sourcepub(crate) async fn update_contacts_timestamp(
&self,
contact_id: ContactId,
scope: Param,
new_timestamp: i64,
) -> Result<bool>
pub(crate) async fn update_contacts_timestamp( &self, contact_id: ContactId, scope: Param, new_timestamp: i64, ) -> Result<bool>
Updates a contact’s timestamp, if reasonable. Returns true if the caller shall update the settings belonging to the scope. (if we have a ContactId type at some point, the function should go there)
source§impl Context
impl Context
sourcepub async fn set_webxdc_integration(&self, file: &str) -> Result<()>
pub async fn set_webxdc_integration(&self, file: &str) -> Result<()>
Sets Webxdc file as integration.
file
is the .xdc to use as Webxdc integration.
sourcepub async fn init_webxdc_integration(
&self,
integrate_for: Option<ChatId>,
) -> Result<Option<MsgId>>
pub async fn init_webxdc_integration( &self, integrate_for: Option<ChatId>, ) -> Result<Option<MsgId>>
Returns Webxdc instance used for optional integrations.
UI can open the Webxdc as usual.
Returns None
if there is no integration; the caller can add one using set_webxdc_integration
then.
integrate_for
is the chat to get the integration for.
pub(crate) async fn update_webxdc_integration_database( &self, msg: &Message, ) -> Result<()>
pub(crate) async fn intercept_send_webxdc_status_update( &self, instance: Message, status_update: StatusUpdateItem, ) -> Result<()>
pub(crate) async fn intercept_get_webxdc_status_updates( &self, instance: Message, last_known_serial: StatusUpdateSerial, ) -> Result<String>
source§impl Context
impl Context
sourcepub(crate) async fn is_webxdc_file(
&self,
filename: &str,
file: &[u8],
) -> Result<bool>
pub(crate) async fn is_webxdc_file( &self, filename: &str, file: &[u8], ) -> Result<bool>
check if a file is an acceptable webxdc for sending or receiving.
sourcepub(crate) async fn ensure_sendable_webxdc_file(
&self,
path: &Path,
) -> Result<()>
pub(crate) async fn ensure_sendable_webxdc_file( &self, path: &Path, ) -> Result<()>
Ensure that a file is an acceptable webxdc for sending.
sourceasync fn get_overwritable_info_msg_id(
&self,
instance: &Message,
from_id: ContactId,
) -> Result<Option<MsgId>>
async fn get_overwritable_info_msg_id( &self, instance: &Message, from_id: ContactId, ) -> Result<Option<MsgId>>
Check if the last message of a chat is an info message belonging to the given instance and sender. If so, the id of this message is returned.
sourceasync fn create_status_update_record(
&self,
instance: &Message,
status_update_item: StatusUpdateItem,
timestamp: i64,
can_info_msg: bool,
from_id: ContactId,
) -> Result<Option<StatusUpdateSerial>>
async fn create_status_update_record( &self, instance: &Message, status_update_item: StatusUpdateItem, timestamp: i64, can_info_msg: bool, from_id: ContactId, ) -> Result<Option<StatusUpdateSerial>>
Takes an update-json as {payload: PAYLOAD}
writes it to the database and handles events, info-messages, document name and summary.
sourcepub(crate) async fn write_status_update_inner(
&self,
instance_id: &MsgId,
status_update_item: &StatusUpdateItem,
timestamp: i64,
) -> Result<Option<StatusUpdateSerial>>
pub(crate) async fn write_status_update_inner( &self, instance_id: &MsgId, status_update_item: &StatusUpdateItem, timestamp: i64, ) -> Result<Option<StatusUpdateSerial>>
Inserts a status update item into msgs_status_updates
table.
Returns serial ID of the status update if a new item is inserted.
sourcepub async fn get_status_update(
&self,
msg_id: MsgId,
status_update_serial: StatusUpdateSerial,
) -> Result<String>
pub async fn get_status_update( &self, msg_id: MsgId, status_update_serial: StatusUpdateSerial, ) -> Result<String>
Returns the update_item with status_update_serial
from the webxdc with message id msg_id
.
sourcepub async fn send_webxdc_status_update(
&self,
instance_msg_id: MsgId,
update_str: &str,
descr: &str,
) -> Result<()>
pub async fn send_webxdc_status_update( &self, instance_msg_id: MsgId, update_str: &str, descr: &str, ) -> Result<()>
Sends a status update for an webxdc instance.
If the instance is a draft, the status update is sent once the instance is actually sent. Otherwise, the update is sent as soon as possible.
sourcepub async fn send_webxdc_status_update_struct(
&self,
instance_msg_id: MsgId,
status_update: StatusUpdateItem,
descr: &str,
) -> Result<()>
pub async fn send_webxdc_status_update_struct( &self, instance_msg_id: MsgId, status_update: StatusUpdateItem, descr: &str, ) -> Result<()>
Sends a status update for an webxdc instance. Also see Self::send_webxdc_status_update
sourceasync fn smtp_status_update_get(
&self,
) -> Result<Option<(MsgId, i64, StatusUpdateSerial, String)>>
async fn smtp_status_update_get( &self, ) -> Result<Option<(MsgId, i64, StatusUpdateSerial, String)>>
Returns one record of the queued webxdc status updates.
async fn smtp_status_update_pop_serials( &self, msg_id: MsgId, first: i64, first_new: StatusUpdateSerial, ) -> Result<()>
sourcepub(crate) async fn flush_status_updates(&self) -> Result<()>
pub(crate) async fn flush_status_updates(&self) -> Result<()>
Attempts to send queued webxdc status updates.
pub(crate) fn build_status_update_part(&self, json: &str) -> PartBuilder
sourcepub(crate) async fn receive_status_update(
&self,
from_id: ContactId,
instance: &Message,
timestamp: i64,
can_info_msg: bool,
json: &str,
) -> Result<()>
pub(crate) async fn receive_status_update( &self, from_id: ContactId, instance: &Message, timestamp: i64, can_info_msg: bool, json: &str, ) -> Result<()>
Receives status updates from receive_imf to the database and sends out an event.
instance
is a webxdc instance.
from_id
is the sender.
timestamp
is the timestamp of the update.
json
is an array containing one or more update items as created by send_webxdc_status_update(),
the array is parsed using serde, the single payloads are used as is.
sourcepub async fn get_webxdc_status_updates(
&self,
instance_msg_id: MsgId,
last_known_serial: StatusUpdateSerial,
) -> Result<String>
pub async fn get_webxdc_status_updates( &self, instance_msg_id: MsgId, last_known_serial: StatusUpdateSerial, ) -> Result<String>
Returns status updates as an JSON-array, ready to be consumed by a webxdc.
Example: [{"serial":1, "max_serial":3, "payload":"any update data"}, {"serial":3, "max_serial":3, "payload":"another update data"}]
Updates with serials larger than last_known_serial
are returned.
If no last serial is known, set last_known_serial
to 0.
If no updates are available, an empty JSON-array is returned.
sourcepub(crate) async fn render_webxdc_status_update_object(
&self,
instance_msg_id: MsgId,
first: StatusUpdateSerial,
last: StatusUpdateSerial,
size_max: Option<usize>,
) -> Result<(Option<String>, StatusUpdateSerial)>
pub(crate) async fn render_webxdc_status_update_object( &self, instance_msg_id: MsgId, first: StatusUpdateSerial, last: StatusUpdateSerial, size_max: Option<usize>, ) -> Result<(Option<String>, StatusUpdateSerial)>
Renders JSON-object for status updates as used on the wire.
Returns optional JSON and the first serial of updates not included due to a JSON size limit. If all requested updates are included, returns the first not requested serial.
Example JSON: {"updates": [{"payload":"any update data"}, {"payload":"another update data"}]}
(first, last)
: range of status update serials to send.
source§impl Context
impl Context
sourcepub async fn push_state(&self) -> NotifyState
pub async fn push_state(&self) -> NotifyState
Returns push notification subscriber state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.