Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ hex = "0.4.0"
hickory-resolver = "0.24"
humansize = "2"
image = { version = "0.25.1", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] }
iroh = { version = "0.4.2", default-features = false }
kamadak-exif = "0.5.3"
lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" }
libc = "0.2"
Expand Down Expand Up @@ -110,6 +109,9 @@ uuid = { version = "1", features = ["serde", "v4"] }
# 3.1 branch will be supported until 2025-03-14.
openssl-src = "~300.1"

[target.'cfg(not(target_os = "openbsd"))'.dependencies]
iroh = { version = "0.4.2", default-features = false }

[dev-dependencies]
ansi_term = "0.12.0"
anyhow = { version = "1", features = ["backtrace"] } # Enable `backtrace` feature in tests.
Expand Down
2 changes: 2 additions & 0 deletions src/imex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ use crate::tools::{
create_folder, delete_file, get_filesuffix_lc, open_file_std, read_file, time, write_file,
};

#[cfg(not(target_os = "openbsd"))]
mod transfer;

#[cfg(not(target_os = "openbsd"))]
pub use transfer::{get_backup, BackupProvider};

// Name of the database file in the backup.
Expand Down
14 changes: 14 additions & 0 deletions src/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub enum Qr {
///
/// This contains all the data needed to connect to a device and download a backup from
/// it to configure the receiving device with the same account.
#[cfg(not(target_os = "openbsd"))]
Backup {
/// Printable version of the provider information.
///
Expand Down Expand Up @@ -291,13 +292,20 @@ pub async fn check_qr(context: &Context, qr: &str) -> Result<Qr> {
///
/// TODO: Refactor this so all variants have a correct [`Display`] and transform `check_qr`
/// into `FromStr`.
#[cfg(not(target_os = "openbsd"))]
pub fn format_backup(qr: &Qr) -> Result<String> {
match qr {
Qr::Backup { ref ticket } => Ok(format!("{DCBACKUP_SCHEME}{ticket}")),
_ => Err(anyhow!("Not a backup QR code")),
}
}

/// Placeholder for OpenBSD which does not support iroh backup transfer.
#[cfg(target_os = "openbsd")]
pub fn format_backup(_qr: &Qr) -> Result<String> {
Err(anyhow!("Backup is not supported on OpenBSD"))
}

/// scheme: `OPENPGP4FPR:FINGERPRINT#a=ADDR&n=NAME&i=INVITENUMBER&s=AUTH`
/// or: `OPENPGP4FPR:FINGERPRINT#a=ADDR&g=GROUPNAME&x=GROUPID&i=INVITENUMBER&s=AUTH`
/// or: `OPENPGP4FPR:FINGERPRINT#a=ADDR`
Expand Down Expand Up @@ -520,6 +528,7 @@ fn decode_webrtc_instance(_context: &Context, qr: &str) -> Result<Qr> {
///
/// The format of this scheme is `DCBACKUP:<encoded ticket>`. The encoding is the
/// [`iroh::provider::Ticket`]'s `Display` impl.
#[cfg(not(target_os = "openbsd"))]
fn decode_backup(qr: &str) -> Result<Qr> {
let payload = qr
.strip_prefix(DCBACKUP_SCHEME)
Expand All @@ -528,6 +537,11 @@ fn decode_backup(qr: &str) -> Result<Qr> {
Ok(Qr::Backup { ticket })
}

#[cfg(target_os = "openbsd")]
fn decode_backup(_qr: &str) -> Result<Qr> {
bail!("Backup transfer is not supported on OpenBSD");
}

#[derive(Debug, Deserialize)]
struct CreateAccountSuccessResponse {
/// Email address.
Expand Down
9 changes: 6 additions & 3 deletions src/qr_code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,9 @@ fn inner_generate_secure_join_qr_code(

#[cfg(test)]
mod tests {
use testdir::testdir;

#[cfg(not(target_os = "openbsd"))]
use crate::imex::BackupProvider;
use crate::qr::format_backup;
use crate::test_utils::TestContextManager;

use super::*;

Expand All @@ -318,7 +316,12 @@ mod tests {
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[cfg(not(target_os = "openbsd"))]
async fn test_generate_backup_qr() {
use crate::qr::format_backup;
use crate::test_utils::TestContextManager;
use testdir::testdir;

let dir = testdir!();
let mut tcm = TestContextManager::new();
let ctx = tcm.alice().await;
Expand Down
1 change: 1 addition & 0 deletions src/stock_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ pub(crate) async fn backup_transfer_qr(context: &Context) -> Result<String> {
.replace1(&full_name))
}

#[cfg(not(target_os = "openbsd"))]
pub(crate) async fn backup_transfer_msg_body(context: &Context) -> String {
translated(context, StockMessage::BackupTransferMsgBody).await
}
Expand Down