Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Pushes: each service refreshed on its own, so Notes never waits on Photos
Yashwanth Kamireddi4e97638394f1
diff --git a/probe/examples/notes_reach_live.rs b/probe/examples/notes_reach_live.rsnew file mode 100644index 0000000..12c7aec--- /dev/null+++ b/probe/examples/notes_reach_live.rs@@ -0,0 +1,87 @@+//! Live, throwaway note only: how fast a note written at Apple — as by another device — reaches+//! the running app's library. Made, then the library (read-only) watched for it; then sent to+//! Recently Deleted, and watched for that too. Pass the record name to notes_delete_now after.+use anyhow::{anyhow, Result};+use std::time::{Duration, Instant};++fn row(db: &rusqlite::Connection, guid: &str) -> Option<String> {+ db.query_row(+ "SELECT coalesce(folder_guid, '') FROM notes WHERE guid = ?1",+ [guid],+ |r| r.get(0),+ )+ .ok()+}++#[tokio::main]+async fn main() -> Result<()> {+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");+ let mut client = quince_auth::Client::new(&dir)?;+ if !client.resume().await? {+ return Err(anyhow!("no session"));+ }+ let root = client+ .session()+ .service_url("ckdatabasews")+ .ok_or_else(|| anyhow!("no ck"))?;+ let (http, p) = (client.http().clone(), client.service_params());+ let db = rusqlite::Connection::open_with_flags(+ std::path::PathBuf::from(std::env::var("HOME")?)+ .join(".local/share/dev.quince.client/library.db"),+ rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY,+ )?;+ let title = format!("Quince mount test {}", std::process::id());+ let t = Instant::now();+ let guid = quince_icloud::notes::create_cloudkit(+ &http,+ &root,+ p.clone(),+ None,+ &format!("{title}\nsafe to delete"),+ None,+ )+ .await?;+ println!("written at Apple in {} ms", t.elapsed().as_millis());+ let mut seen = None;+ while t.elapsed() < Duration::from_secs(90) {+ if row(&db, &guid).is_some() {+ seen = Some(t.elapsed());+ break;+ }+ tokio::time::sleep(Duration::from_millis(200)).await;+ }+ println!("in the app's library after: {seen:?}");+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &root, "com.apple.notes", p.clone());+ let rec = zc+ .lookup_record("Notes", &guid)+ .await?+ .ok_or_else(|| anyhow!("gone"))?;+ let note = quince_core::notes::Note {+ guid: guid.clone(),+ folder_guid: None,+ title,+ snippet: None,+ body: None,+ locked: false,+ pinned: false,+ created_at: None,+ modified_at: None,+ editable: true,+ etag: rec["recordChangeTag"].as_str().map(String::from),+ runs: None,+ };+ let before = row(&db, &guid);+ let t = Instant::now();+ quince_icloud::notes::delete_cloudkit(&http, &root, p, ¬e).await?;+ let mut moved = None;+ while t.elapsed() < Duration::from_secs(90) {+ if row(&db, &guid) != before {+ moved = Some(t.elapsed());+ break;+ }+ tokio::time::sleep(Duration::from_millis(200)).await;+ }+ println!("its deletion in the app's library after: {moved:?}");+ println!("RECORD {guid}");+ Ok(())+}diff --git a/src-tauri/src/push.rs b/src-tauri/src/push.rsindex eba4971..c4d1815 100644--- a/src-tauri/src/push.rs+++ b/src-tauri/src/push.rs@@ -186,14 +186,22 @@ async fn refresher(services.push(more);}}- let data = app.state::<Data>();- refresh::some(&client, &data.0, &services).await;- alerts::changed();- if services.contains(&"contacts") {- crate::warm_contact_photos(app.clone());+ // Each service refreshed on its own, side by side: one taken in turn kept a note+ // edited on the phone waiting behind a long Photos pass (measured: a deletion took 54 s+ // to show). Two refreshes of one service still take turns (its pass lock).+ for service in services {+ let (app, client) = (app.clone(), Arc::clone(&client));+ tauri::async_runtime::spawn(async move {+ let data = app.state::<Data>();+ refresh::some(&client, &data.0, &[service]).await;+ alerts::changed();+ if service == "contacts" {+ crate::warm_contact_photos(app.clone());+ }+ // Every service's freshness, not only this one: the window shows the whole.+ app.emit(SYNCED, refresh::status(&data.0).await).ok();+ });}- // Every service's freshness, not only the ones refreshed: the window shows the whole.- app.emit(SYNCED, refresh::status(&data.0).await).ok();}}