From 35555ca75306a2d0a7149db6c4c7183e9edc184f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 26 Jul 2026 17:06:45 +0200 Subject: [PATCH] api!: remove getPushState() and core's internal tracking of it. Since https://github.com/deltachat/deltachat-ios/pull/3224 pushstate is not used (android, desktop etc. never used it, only ios) --- deltachat-ffi/deltachat.h | 16 ------------ deltachat-ffi/src/lib.rs | 10 -------- deltachat-jsonrpc/src/api.rs | 7 ------ deltachat-jsonrpc/src/api/types/mod.rs | 2 -- .../src/api/types/notify_state.rs | 22 ---------------- .../typescript/scripts/generate-constants.js | 1 - .../src/deltachat_rpc_client/const.py | 7 ------ src/context.rs | 5 ---- src/imap.rs | 3 --- src/push.rs | 25 ------------------- 10 files changed, 98 deletions(-) delete mode 100644 deltachat-jsonrpc/src/api/types/notify_state.rs diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index b7c865360..e957bf423 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -638,22 +638,6 @@ int dc_get_connectivity (dc_context_t* context); char* dc_get_connectivity_html (dc_context_t* context); -#define DC_PUSH_NOT_CONNECTED 0 -#define DC_PUSH_CONNECTED 2 - -/** - * Get the current push notification state. - * One of: - * - DC_PUSH_NOT_CONNECTED - * - DC_PUSH_CONNECTED - * - * @memberof dc_context_t - * @param context The context object. - * @return Push notification state. - */ -int dc_get_push_state (dc_context_t* context); - - // connect /** diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index c43675444..b3ee79a33 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -397,16 +397,6 @@ pub unsafe extern "C" fn dc_get_connectivity_html( } } -#[unsafe(no_mangle)] -pub unsafe extern "C" fn dc_get_push_state(context: *const dc_context_t) -> libc::c_int { - if context.is_null() { - eprintln!("ignoring careless call to dc_get_push_state()"); - return 0; - } - let ctx = unsafe { &*context }; - ctx.push_state() as libc::c_int -} - fn spawn_configure(ctx: Context) { spawn(async move { ctx.configure() diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 499b860cc..84c2c994a 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -53,7 +53,6 @@ use types::contact::{ContactObject, VcardContact}; use types::events::Event; use types::http::HttpResponse; use types::message::{MessageData, MessageObject, MessageReadReceipt}; -use types::notify_state::JsonrpcNotifyState; use types::reactions::JsonrpcReactions; use types::webxdc::WebxdcMessageInfo; @@ -328,12 +327,6 @@ impl CommandApi { } } - /// Get the current push notification state. - async fn get_push_state(&self, account_id: u32) -> Result { - let ctx = self.get_context(account_id).await?; - Ok(ctx.push_state().into()) - } - /// Get the combined filesize of an account in bytes async fn get_account_file_size(&self, account_id: u32) -> Result { let ctx = self.get_context(account_id).await?; diff --git a/deltachat-jsonrpc/src/api/types/mod.rs b/deltachat-jsonrpc/src/api/types/mod.rs index 50397312b..f39aa2e02 100644 --- a/deltachat-jsonrpc/src/api/types/mod.rs +++ b/deltachat-jsonrpc/src/api/types/mod.rs @@ -8,8 +8,6 @@ pub mod http; pub mod location; pub mod login_param; pub mod message; -pub mod notify_state; - pub mod qr; pub mod reactions; pub mod webxdc; diff --git a/deltachat-jsonrpc/src/api/types/notify_state.rs b/deltachat-jsonrpc/src/api/types/notify_state.rs deleted file mode 100644 index 1ede71169..000000000 --- a/deltachat-jsonrpc/src/api/types/notify_state.rs +++ /dev/null @@ -1,22 +0,0 @@ -use deltachat::push::NotifyState; -use serde::Serialize; -use typescript_type_def::TypeDef; - -#[derive(Serialize, TypeDef, schemars::JsonSchema)] -#[serde(rename = "NotifyState")] -pub enum JsonrpcNotifyState { - /// Not subscribed to push notifications. - NotConnected, - - /// Subscribed to push notifications for new messages. - Connected, -} - -impl From for JsonrpcNotifyState { - fn from(state: NotifyState) -> Self { - match state { - NotifyState::NotConnected => Self::NotConnected, - NotifyState::Connected => Self::Connected, - } - } -} diff --git a/deltachat-jsonrpc/typescript/scripts/generate-constants.js b/deltachat-jsonrpc/typescript/scripts/generate-constants.js index e8b09d2e1..733543fb8 100755 --- a/deltachat-jsonrpc/typescript/scripts/generate-constants.js +++ b/deltachat-jsonrpc/typescript/scripts/generate-constants.js @@ -44,7 +44,6 @@ const constants = data key.startsWith("DC_CERTCK_") || key.startsWith("DC_SOCKET_") || key.startsWith("DC_LP_AUTH_") || - key.startsWith("DC_PUSH_") || key.startsWith("DC_TEXT1_") || key.startsWith("DC_CHAT_TYPE") ); diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/const.py b/deltachat-rpc-client/src/deltachat_rpc_client/const.py index 360d0f54d..846475b0e 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/const.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/const.py @@ -246,13 +246,6 @@ class ProviderStatus(IntEnum): BROKEN = 3 -class PushNotifyState(IntEnum): - """Push notifications state.""" - - NOT_CONNECTED = 0 - CONNECTED = 2 - - class ShowEmails(IntEnum): """Show emails mode.""" diff --git a/src/context.rs b/src/context.rs index ed822448b..14031055c 100644 --- a/src/context.rs +++ b/src/context.rs @@ -4,7 +4,6 @@ use std::collections::{BTreeMap, HashMap}; use std::ffi::OsString; use std::ops::Deref; use std::path::{Path, PathBuf}; -use std::sync::atomic::AtomicBool; use std::sync::{Arc, OnceLock, Weak}; use std::time::Duration; @@ -296,9 +295,6 @@ pub struct InnerContext { /// Push subscriber to store device token. pub(crate) push_subscriber: PushSubscriber, - /// True if account has subscribed to push notifications via IMAP. - pub(crate) push_subscribed: AtomicBool, - /// TLS session resumption cache. pub(crate) tls_session_store: TlsSessionStore, @@ -497,7 +493,6 @@ impl Context { migration_error: parking_lot::RwLock::new(None), debug_logging: std::sync::RwLock::new(None), push_subscriber, - push_subscribed: AtomicBool::new(false), tls_session_store: TlsSessionStore::new(), spki_hash_store: SpkiHashStore::new(), iroh: Arc::new(RwLock::new(None)), diff --git a/src/imap.rs b/src/imap.rs index 63896bd82..08ba89e88 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -10,7 +10,6 @@ use std::{ iter::Peekable, mem::take, str::FromStr, - sync::atomic::Ordering, time::{Duration, UNIX_EPOCH}, }; @@ -1509,8 +1508,6 @@ impl Session { context, "Transport {transport_id}: Failed to store device token: {err:#}." ); - } else { - context.push_subscribed.store(true, Ordering::Relaxed); } Ok(()) diff --git a/src/push.rs b/src/push.rs index d61522d17..a9ffd95a1 100644 --- a/src/push.rs +++ b/src/push.rs @@ -7,14 +7,12 @@ //! which holds push notification token for the device, //! shared by all accounts. use std::sync::Arc; -use std::sync::atomic::Ordering; use anyhow::{Context as _, Result}; use base64::Engine as _; use pgp::crypto::aead::{AeadAlgorithm, ChunkSize}; use pgp::crypto::sym::SymmetricKeyAlgorithm; -use crate::context::Context; use crate::key::DcKey; /// Manages subscription to Apple Push Notification services. @@ -117,29 +115,6 @@ impl PushSubscriber { } } -/// Push notification state -#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)] -#[repr(i8)] -pub enum NotifyState { - /// Not subscribed to push notifications. - #[default] - NotConnected = 0, - - /// Subscribed to push notifications for new messages. - Connected = 2, -} - -impl Context { - /// Returns push notification subscriber state. - pub fn push_state(&self) -> NotifyState { - if self.push_subscribed.load(Ordering::Relaxed) { - NotifyState::Connected - } else { - NotifyState::NotConnected - } - } -} - #[cfg(test)] mod tests { use super::*;