浏览代码

add swift wrapper methods to add and open an encrypted account db

cyberta 3 年之前
父节点
当前提交
b22cc8bccd
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      DcCore/DcCore/DC/Wrapper.swift

+ 13 - 0
DcCore/DcCore/DC/Wrapper.swift

@@ -23,6 +23,10 @@ public class DcAccounts {
         return Int(dc_accounts_migrate_account(accountsPointer, dbLocation))
     }
 
+    public func addClosedAccount() -> Int {
+        return Int(dc_accounts_add_closed_account(accountsPointer))
+    }
+
     public func add() -> Int {
         return Int(dc_accounts_add_account(accountsPointer))
     }
@@ -119,6 +123,15 @@ public class DcContext {
         return swiftString
     }
 
+    // The passphrase can be ommited if the account db is not encrypted
+    public func open(passphrase: String? = nil) {
+        dc_context_open(contextPointer, passphrase)
+    }
+
+    public func isOpen() -> Bool {
+        return dc_context_is_open(contextPointer) == 1
+    }
+
     // viewType: one of DC_MSG_*
     public func newMessage(viewType: Int32) -> DcMsg {
         let messagePointer = dc_msg_new(contextPointer, viewType)