diff --git a/DcCore/DcCore.xcodeproj/project.pbxproj b/DcCore/DcCore.xcodeproj/project.pbxproj index 58a39061f..1009c51fc 100644 --- a/DcCore/DcCore.xcodeproj/project.pbxproj +++ b/DcCore/DcCore.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 30E8F24D2449D30200CE2C90 /* DcColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30E8F24C2449D30200CE2C90 /* DcColors.swift */; }; 78072F172A040ED800EB7C98 /* libdeltachat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78072F162A040ED800EB7C98 /* libdeltachat.a */; }; 7871729629BA495200F110DC /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7871729529BA495200F110DC /* SystemConfiguration.framework */; }; + B2F691252C0790140010D9B1 /* DcVcard.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2F691242C0790140010D9B1 /* DcVcard.swift */; }; D8BBF0032B57D8E5008C96FD /* DcAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BBF0022B57D8E5008C96FD /* DcAccount.swift */; }; D8BBF0052B57D904008C96FD /* DcContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BBF0042B57D904008C96FD /* DcContext.swift */; }; D8BBF0072B57D91B008C96FD /* DcEventEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BBF0062B57D91B008C96FD /* DcEventEmitter.swift */; }; @@ -68,6 +69,7 @@ 7827C8882A04089900B8470D /* libraries */ = {isa = PBXFileReference; lastKnownFileType = folder; name = libraries; path = "../deltachat-ios/libraries"; sourceTree = ""; }; 7827C88A2A0408A700B8470D /* libdeltachat.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdeltachat.a; path = "../deltachat-ios/libraries/deltachat-core-rust/libdeltachat.a"; sourceTree = ""; }; 7871729529BA495200F110DC /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + B2F691242C0790140010D9B1 /* DcVcard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DcVcard.swift; sourceTree = ""; }; D8BBF0022B57D8E5008C96FD /* DcAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DcAccount.swift; sourceTree = ""; }; D8BBF0042B57D904008C96FD /* DcContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DcContext.swift; sourceTree = ""; }; D8BBF0062B57D91B008C96FD /* DcEventEmitter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DcEventEmitter.swift; sourceTree = ""; }; @@ -142,6 +144,7 @@ D8BBF0102B57D96F008C96FD /* DcMsg.swift */, D8BBF0182B57D9AE008C96FD /* DcProvider.swift */, D8BBF01A2B57D9BE008C96FD /* DcReaction.swift */, + B2F691242C0790140010D9B1 /* DcVcard.swift */, 30421985243F209E00516852 /* events.swift */, 30421961243E26C800516852 /* Logger.swift */, 3042194E243DE15D00516852 /* wrapper.c */, @@ -318,6 +321,7 @@ D8BBF0132B57D97B008C96FD /* DcContact.swift in Sources */, D8BBF0112B57D96F008C96FD /* DcMsg.swift in Sources */, D8BBF00B2B57D93D008C96FD /* DcChatlist.swift in Sources */, + B2F691252C0790140010D9B1 /* DcVcard.swift in Sources */, D8BBF0052B57D904008C96FD /* DcContext.swift in Sources */, D8BBF0172B57D99F008C96FD /* DcBackupProvider.swift in Sources */, 304F5E41244F2F3200462538 /* UIImage+Extensions.swift in Sources */, diff --git a/deltachat-ios/Chat/ChatViewController.swift b/deltachat-ios/Chat/ChatViewController.swift index 920457019..dec99c7dc 100644 --- a/deltachat-ios/Chat/ChatViewController.swift +++ b/deltachat-ios/Chat/ChatViewController.swift @@ -2120,7 +2120,10 @@ extension ChatViewController { } func didTapVcard(msg: DcMsg) { + guard let file = msg.file else { return } + let vcard = dcContext.parseVcard(path: file) let name = "foo bar" + let alert = UIAlertController(title: String.localizedStringWithFormat(String.localized("ask_start_chat_with"), name), message: nil, preferredStyle: .safeActionSheet) alert.addAction(UIAlertAction(title: String.localized("start_chat"), style: .default, handler: { _ in })) diff --git a/deltachat-ios/DC/DcContext.swift b/deltachat-ios/DC/DcContext.swift index e4983d787..0afbd8fa2 100644 --- a/deltachat-ios/DC/DcContext.swift +++ b/deltachat-ios/DC/DcContext.swift @@ -388,6 +388,13 @@ public class DcContext { } } + public func parseVcard(path: String) -> DcVcardContact? { + if let data = DcAccounts.shared.blockingCall(method: "parse_vcard", params: [path as AnyObject]) { + return try? JSONDecoder().decode(DcVcardContactResult.self, from: data).result + } + return nil + } + public func deleteMessage(msgId: Int) { dc_delete_msgs(contextPointer, [UInt32(msgId)], 1) } diff --git a/deltachat-ios/DC/DcVcard.swift b/deltachat-ios/DC/DcVcard.swift new file mode 100644 index 000000000..71cee595d --- /dev/null +++ b/deltachat-ios/DC/DcVcard.swift @@ -0,0 +1,34 @@ +import Foundation + +public struct DcVcardContact: Decodable { + /// Email address. + public let addr: String + + /// The contact's name, or the email address if no name was given. + public let displayName: String + + /// Public PGP key in Base64. + public let key: String? + + /// Profile image in Base64. + public let profileImage: String? + + /// Contact color as hex string. + public let contactColor: String + + // Last update timestamp. + public let timestamp: Int64 + + public init(addr: String, displayName: String, key: String? = nil, profileImage: String? = nil, contactColor: String, timestamp: Int64) { + self.addr = addr + self.displayName = displayName + self.key = key + self.profileImage = profileImage + self.contactColor = contactColor + self.timestamp = timestamp + } +} + +struct DcVcardContactResult: Decodable { + let result: DcVcardContact +}