浏览代码

feat(wrapper): add methods for handling show_emails

dignifiedquire 6 年之前
父节点
当前提交
ce6f5042ba
共有 1 个文件被更改,包括 31 次插入1 次删除
  1. 31 1
      deltachat-ios/Wrapper.swift

+ 31 - 1
deltachat-ios/Wrapper.swift

@@ -497,7 +497,7 @@ class MRConfig {
 
     if let pSafe = p {
       let c = String(cString: pSafe)
-      if c == "" {
+      if c.isEmpty {
         return nil
       }
       return c
@@ -521,6 +521,22 @@ class MRConfig {
     setOptStr(key, vStr)
   }
 
+  private class func getInt(_ key: String) -> Int {
+    let vStr = getOptStr(key)
+    if vStr == nil {
+      return 0
+    }
+    let vInt = Int(vStr!)
+    if vInt == nil {
+      return 0
+    }
+    return vInt!
+  }
+
+  private class func setInt(_ key: String, _ value: Int) {
+    setOptStr(key, String(value))
+  }
+
   /**
    *  Address to display (always needed)
    */
@@ -749,6 +765,20 @@ class MRConfig {
     }
   }
 
+  /**
+   *  DC_SHOW_EMAILS_OFF (0)= show direct replies to chats only (default),
+   *  DC_SHOW_EMAILS_ACCEPTED_CONTACTS (1)= also show all mails of confirmed contacts,
+   *  DC_SHOW_EMAILS_ALL (2)= also show mails of unconfirmed contacts in the deaddrop.
+   */
+  class var showEmails: Bool {
+    set {
+      setBool("show_emails", newValue)
+    }
+    get {
+      return getBool("show_emails")
+    }
+  }
+  
   /**
    * 1=save mime headers and make dc_get_mime_headers() work for subsequent calls, 0=do not save mime headers (default)
    */