فهرست منبع

Merge pull request #341 from deltachat/add-bcc-self-switch

add switch to set the bcc_self option
björn petersen 5 سال پیش
والد
کامیت
84034fae75

+ 7 - 0
deltachat-ios/Controller/SettingsController.swift

@@ -223,6 +223,13 @@ internal final class SettingsViewController: QuickTableViewController {
                                     DcConfig.mvboxWatch = row.switchValue
                                 }
                     }),
+                    SwitchRow(text: String.localized("pref_send_copy_to_self"),
+                              switchValue: dcContext.getConfigBool("bcc_self"),
+                              action: { row in
+                                if let row = row as? SwitchRow {
+                                    self.dcContext.setConfigBool("bcc_self", row.switchValue)
+                                }
+                    }),
                     SwitchRow(text: String.localized("pref_auto_folder_moves"),
                               switchValue: DcConfig.mvboxMove,
                               action: { row in

+ 38 - 0
deltachat-ios/DC/Wrapper.swift

@@ -78,9 +78,47 @@ class DcContext {
     func continueKeyTransfer(msgId: Int, setupCode: String) -> Bool {
         return dc_continue_key_transfer(self.contextPointer, UInt32(msgId), setupCode) != 0
     }
+
+    func getConfig(_ key: String) -> String? {
+        guard let cString = dc_get_config(self.contextPointer, key) else { return nil }
+        let value = String(cString: cString)
+        dc_str_unref(cString)
+        if value.isEmpty {
+            return nil
+        }
+        return value
+    }
+
+    func setConfig(_ key: String, _ value: String?) {
+        if let v = value {
+            dc_set_config(self.contextPointer, key, v)
+        } else {
+            dc_set_config(self.contextPointer, key, nil)
+        }
+    }
+
+    func getConfigBool(_ key: String) -> Bool {
+        return strToBool(getConfig(key))
+    }
+
+    func setConfigBool(_ key: String, _ value: Bool) {
+        let vStr = value ? "1" : "0"
+        setConfig(key, vStr)
+    }
 }
 
 class DcConfig {
+
+    // it is fine to use existing functionality of DcConfig,
+    // however, as DcConfig uses a global pointer,
+    // new functionality should be added to DcContext.
+
+    // also, there is no much worth in adding a separate function or so
+    // for each config option - esp. if they are just forwarded to the core
+    // and set/get only at one line of code each.
+    // this adds a complexity that can be avoided -
+    // and makes grep harder as these names are typically named following different guidelines.
+
     private class func getConfig(_ key: String) -> String? {
         guard let cString = dc_get_config(mailboxPointer, key) else { return nil }
         let value = String(cString: cString)

+ 1 - 0
deltachat-ios/de.lproj/Localizable.strings

@@ -395,6 +395,7 @@
 "pref_watch_inbox_folder" = "Posteingang beobachten";
 "pref_watch_sent_folder" = "Gesendet-Ordner beobachten";
 "pref_watch_mvbox_folder" = "DeltaChat-Ordner beobachten";
+"pref_send_copy_to_self" = "Kopie an mich selbst senden";
 "pref_auto_folder_moves" = "Autom. Verschieben in den DeltaChat-Ordner";
 "pref_auto_folder_moves_explain" = "Nachrichten verschieben, um einen unübersichtlichen Posteingang zu verhindern.";
 "pref_email_interaction_title" = "E-Mail-Zusammenspiel";

+ 1 - 0
deltachat-ios/en.lproj/Localizable.strings

@@ -395,6 +395,7 @@
 "pref_watch_inbox_folder" = "Watch Inbox folder";
 "pref_watch_sent_folder" = "Watch Sent folder";
 "pref_watch_mvbox_folder" = "Watch DeltaChat folder";
+"pref_send_copy_to_self" = "Send copy to self";
 "pref_auto_folder_moves" = "Automatic moves to DeltaChat folder";
 "pref_auto_folder_moves_explain" = "Chat conversations are moved to avoid cluttering the Inbox folder";
 "pref_email_interaction_title" = "Email interaction";