Skip to content

Commit

Permalink
basic UI for iroh-share backup transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Aug 31, 2022
1 parent b7d8c76 commit 032acdb
Show file tree
Hide file tree
Showing 11 changed files with 547 additions and 190 deletions.
8 changes: 8 additions & 0 deletions DcCore/DcCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
30E8F2482449C98600CE2C90 /* UIView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30E8F2472449C98600CE2C90 /* UIView+Extensions.swift */; };
30E8F24B2449CF6500CE2C90 /* InitialsBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30E8F24A2449CF6500CE2C90 /* InitialsBadge.swift */; };
30E8F24D2449D30200CE2C90 /* DcColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30E8F24C2449D30200CE2C90 /* DcColors.swift */; };
78A8733F287766FA00690A0B /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 78A8733E287766FA00690A0B /* libc++.tbd */; };
78A873412877679B00690A0B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78A873402877679B00690A0B /* SystemConfiguration.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -69,13 +71,17 @@
30E8F2472449C98600CE2C90 /* UIView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extensions.swift"; sourceTree = "<group>"; };
30E8F24A2449CF6500CE2C90 /* InitialsBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialsBadge.swift; sourceTree = "<group>"; };
30E8F24C2449D30200CE2C90 /* DcColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DcColors.swift; sourceTree = "<group>"; };
78A8733E287766FA00690A0B /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libc++.tbd"; sourceTree = DEVELOPER_DIR; };
78A873402877679B00690A0B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
3042192E243DE0F200516852 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A873412877679B00690A0B /* SystemConfiguration.framework in Frameworks */,
78A8733F287766FA00690A0B /* libc++.tbd in Frameworks */,
30421959243DE6AD00516852 /* libdeltachat.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -149,6 +155,8 @@
30421957243DE61400516852 /* Frameworks */ = {
isa = PBXGroup;
children = (
78A873402877679B00690A0B /* SystemConfiguration.framework */,
78A8733E287766FA00690A0B /* libc++.tbd */,
30421958243DE61400516852 /* libdeltachat.a */,
);
name = Frameworks;
Expand Down
32 changes: 32 additions & 0 deletions DcCore/DcCore/DC/Wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,15 @@ public class DcContext {
public func imex(what: Int32, directory: String, passphrase: String? = nil) {
dc_imex(contextPointer, what, directory, passphrase)
}

public func send_backup(directory: String, passphrase: String? = nil) -> DcBackupSender? {
guard let dcBackupSenderPointer = dc_send_backup(contextPointer, directory, passphrase) else { return nil }
return DcBackupSender(dcBackupSenderPointer)
}

public func receiveBackup(qrCode: String, passphrase: String? = nil) {
dc_receive_backup(contextPointer, qrCode, passphrase)
}

public func imexHasBackup(filePath: String) -> String? {
var file: String?
Expand Down Expand Up @@ -1391,6 +1400,29 @@ public class DcLot {
}
}

public class DcBackupSender {
private var dcBackupSenderPointer: OpaquePointer?

// takes ownership of specified pointer
public init(_ dcBackupSenderPointer: OpaquePointer) {
print(">>>> 💙 init DcBackupSender")
self.dcBackupSenderPointer = dcBackupSenderPointer
}

deinit {
print(">>>> 💙 deinit DcBackupSender")
dc_backup_sender_unref(dcBackupSenderPointer)
}

public func qr_code(context: DcContext) -> String? {
guard let cString = dc_backup_sender_qr(context.contextPointer, dcBackupSenderPointer) else { return nil }
let swiftString = String(cString: cString)
dc_str_unref(cString)
return swiftString

}
}

public class DcProvider {
private var dcProviderPointer: OpaquePointer?

Expand Down
1 change: 1 addition & 0 deletions DcCore/DcCore/DC/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ typedef dc_msg_t dc_msg_t;
typedef dc_lot_t dc_lot_t;
typedef dc_array_t dc_array_t;
typedef dc_chatlist_t dc_chatlist_t;
typedef dc_backup_sender_t dc_backup_sender_t;

#endif /* wrapper_h */
Loading

0 comments on commit 032acdb

Please sign in to comment.